File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed
src/FSharp.Control.TaskSeq.Test Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,10 @@ let validateSequence ts =
24
24
25
25
module EmptySeq =
26
26
[<Fact>]
27
- let ``Null source is invalid`` () = assertNullArg <| fun () -> TaskSeq.box null
27
+ let ``Null source is invalid`` () =
28
+ assertNullArg <| fun () -> TaskSeq.box null
29
+ assertNullArg <| fun () -> TaskSeq.unbox null
30
+ assertNullArg <| fun () -> TaskSeq.cast null
28
31
29
32
[<Theory; ClassData( typeof< TestEmptyVariants>) >]
30
33
let ``TaskSeq - box empty`` variant = Gen.getEmptyVariant variant |> TaskSeq.box |> verifyEmpty
Original file line number Diff line number Diff line change 1
1
module TaskSeq.Tests.Singleton
2
2
3
- open System.Threading .Tasks
4
3
open Xunit
5
4
open FsUnit.Xunit
6
5
open FsToolkit.ErrorHandling
7
6
8
7
open FSharp.Control
9
8
9
+ //
10
+ // TaskSeq.singleton
11
+ //
12
+
10
13
module EmptySeq =
11
14
12
15
[<Theory; ClassData( typeof< TestEmptyVariants>) >]
@@ -18,13 +21,39 @@ module EmptySeq =
18
21
|> TaskSeq.exactlyOne
19
22
|> Task.map ( should equal 10 )
20
23
24
+ module SideEffects =
25
+ [<Fact>]
26
+ let ``TaskSeq - singleton with a mutable value`` () =
27
+ let mutable x = 0
28
+ let ts = TaskSeq.singleton x
29
+ x <- x + 1
30
+
31
+ // mutable value is dereferenced when passed to a function
32
+ ts |> TaskSeq.exactlyOne |> Task.map ( should equal 0 )
33
+
34
+ [<Fact>]
35
+ let ``TaskSeq - singleton with a ref cell`` () =
36
+ let x = ref 0
37
+ let ts = TaskSeq.singleton x
38
+ x.Value <- x.Value + 1
39
+
40
+ ts
41
+ |> TaskSeq.exactlyOne
42
+ |> Task.map ( fun x -> x.Value |> should equal 1 )
43
+
21
44
module Other =
22
45
[<Fact>]
23
46
let ``TaskSeq - singleton creates a sequence of one`` () =
24
47
TaskSeq.singleton 42
25
48
|> TaskSeq.exactlyOne
26
49
|> Task.map ( should equal 42 )
27
50
51
+ [<Fact>]
52
+ let ``TaskSeq - singleton with null as value`` () =
53
+ TaskSeq.singleton null
54
+ |> TaskSeq.exactlyOne
55
+ |> Task.map ( should be Null)
56
+
28
57
[<Fact>]
29
58
let ``TaskSeq - singleton can be yielded multiple times`` () =
30
59
let singleton = TaskSeq.singleton 42
You can’t perform that action at this time.
0 commit comments