-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement MergeSources and BindReturn (#4)
* Implement MergeSources and BindReturn * Make execute in parallel
1 parent
74847e9
commit 274fb6c
Showing
3 changed files
with
92 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,56 @@ | ||
module Tests | ||
|
||
open Expecto | ||
open Task.TaskWriterResult | ||
|
||
let tests = | ||
testList "Group of tests" | ||
[ test "A simple test" | ||
{ let subject = "Hello World" | ||
Expect.equal subject "Hello World" "The strings should equal" | ||
[ test "asyncWriterResult and! should run in parallel" { | ||
let mutable acc : int list = [] | ||
let append x = acc <- acc @ [x] | ||
|
||
asyncWriterResult { | ||
let! _ = | ||
async { | ||
append 1 | ||
do! Async.Sleep 1500 | ||
append 2 | ||
} | ||
and! _ = | ||
async { | ||
append 3 | ||
do! Async.Sleep 1000 | ||
append 4 | ||
} | ||
return () | ||
} | ||
|> Async.RunSynchronously | ||
|> ignore | ||
|
||
Expect.equal acc [1; 3; 4; 2] "" | ||
} | ||
|
||
testProperty "Reverse of reverse of a list is the original list" (fun (xs: list<int>) -> | ||
List.rev (List.rev xs) = xs) ] | ||
test "taskWriterResult and! should run in parallel" { | ||
let mutable acc : int list = [] | ||
let append x = acc <- acc @ [x] | ||
|
||
taskWriterResult { | ||
let! _ = | ||
task { | ||
append 1 | ||
do! Async.Sleep 1500 | ||
append 2 | ||
} | ||
and! _ = | ||
task { | ||
append 3 | ||
do! Async.Sleep 1000 | ||
append 4 | ||
} | ||
return () | ||
} | ||
|> fun x -> x.Result | ||
|> ignore | ||
|
||
Expect.equal acc [1; 3; 4; 2] "" | ||
} ] |