File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
src/FSharp.Control.TaskSeq.Test Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -99,14 +99,19 @@ let ``CE taskSeq: use 'let!' with Async - mutables`` () =
99
99
100
100
taskSeq {
101
101
do ! async { value <- value + 1 }
102
+ do value |> should equal 1
102
103
let! x = async { return value + 1 }
104
+ do x |> should equal 2
103
105
do ! Async.Sleep 50
104
106
do ! async { value <- value + 1 }
107
+ do value |> should equal 2
105
108
let! ret = async { return value + 1 }
106
- yield x + ret // eq 6
109
+ do value |> should equal 2
110
+ do ret |> should equal 3
111
+ yield x + ret // eq 5
107
112
}
108
113
|> TaskSeq.exactlyOne
109
- |> Task.map ( fun _ -> value |> should equal 6 )
114
+ |> Task.map ( should equal 5 )
110
115
111
116
[<Fact>]
112
117
let ``CE taskSeq : use 'let ! ' with all kinds of overloads at once`` () =
@@ -132,16 +137,16 @@ let ``CE taskSeq: use 'let!' with all kinds of overloads at once`` () =
132
137
133
138
let! c = ValueTask<_>( 4 ) // valuetask that completes immediately
134
139
let! _ = Task.Factory.StartNew( fun () -> value <- value + 1 ) // non-generic Task with side effect
135
- let! d = Task.fromResult ( 4 ) // normal Task that completes immediately
140
+ let! d = Task.fromResult 99 // normal Task that completes immediately
136
141
let! _ = Async.Sleep 0 // unit Async
137
142
138
143
let! e = async {
139
144
do ! Async.Sleep 40
140
- do value <- value + 1
145
+ do value <- value + 1 // eq 4 now
141
146
return value
142
147
}
143
148
144
149
yield ! [ a; b; c; d; e ]
145
150
}
146
151
|> TaskSeq.toListAsync
147
- |> Task.map ( fun x -> should equal [ 1 ; 2 ; 4 ; 4 ; 3 ])
152
+ |> Task.map ( should equal [ 1 ; 2 ; 4 ; 99 ; 4 ])
You can’t perform that action at this time.
0 commit comments