Skip to content

Commit 231da23

Browse files
committed
+ More tests
1 parent 7070c94 commit 231da23

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

tests/FSharpPlus.Tests/ListT.fs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,30 @@ module BasicTests =
1717
CollectionAssert.AreEqual (res, exp)
1818

1919
[<Test>]
20-
let infiniteLists =
20+
let infiniteLists () =
2121
let (infinite: ListT<Lazy<_>>) = ListT.unfold (fun x -> monad { return (Some (x, x + 1) ) }) 0
2222
let finite = take 12 infinite
2323
let res = finite <|> infinite
24-
CollectionAssert.AreEqual (res |> take 13 |> ListT.run |> extract, [0;1;2;3;4;5;6;7;8;9;10;11;0])
24+
CollectionAssert.AreEqual (res |> take 13 |> ListT.run |> extract, [0;1;2;3;4;5;6;7;8;9;10;11;0])
25+
26+
// Compile tests
27+
let binds () =
28+
let res = listT ( [| [1..4] |]) >>= fun x -> listT ( [| [x * 2] |])
29+
() // but for some reason it doesn't work for Task, ResizeArray, Lazy and seq
30+
31+
let bind_for_ideantity () =
32+
let res = listT (Identity [1..4]) >>= fun x -> listT (Identity [x * 2])
33+
()
34+
35+
let computation_expressions () =
36+
let oneTwoThree : ListT<_> = monad.plus {
37+
do! lift <| Async.Sleep 10
38+
yield 1
39+
do! lift <| Async.Sleep 50
40+
yield 2
41+
yield 3}
42+
()
43+
44+
let applicative_with_options () =
45+
let x = (+) <!> listT None <*> listT (Some [1;2;3;4])
46+
() // It doesn't work with asyncs

0 commit comments

Comments
 (0)