Skip to content

Commit 6d4f991

Browse files
committed
Add inital tests
1 parent 0a354dd commit 6d4f991

File tree

2 files changed

+67
-3
lines changed

2 files changed

+67
-3
lines changed

src/FSharp.Control.TaskSeq.Test/FSharp.Control.TaskSeq.Test.fsproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
<PropertyGroup>
44
<TargetFramework>net6.0</TargetFramework>
5-
6-
<IsPackable>false</IsPackable>
7-
<GenerateProgramFile>false</GenerateProgramFile>
85
</PropertyGroup>
96

107
<ItemGroup>
@@ -23,6 +20,7 @@
2320
<Compile Include="TaskSeq.Except.Tests.fs" />
2421
<Compile Include="TaskSeq.Exists.Tests.fs" />
2522
<Compile Include="TaskSeq.Filter.Tests.fs" />
23+
<Compile Include="TaskSeq.TakeWhile.Tests.fs" />
2624
<Compile Include="TaskSeq.FindIndex.Tests.fs" />
2725
<Compile Include="TaskSeq.Find.Tests.fs" />
2826
<Compile Include="TaskSeq.Fold.Tests.fs" />
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
module TaskSeq.Tests.TakeWhile
2+
3+
open System
4+
open Xunit
5+
open FsUnit.Xunit
6+
open FsToolkit.ErrorHandling
7+
8+
open FSharp.Control
9+
10+
//
11+
// TaskSeq.takeWhile
12+
// TaskSeq.takeWhileAsync
13+
//
14+
15+
module EmptySeq =
16+
[<Theory; ClassData(typeof<TestEmptyVariants>)>]
17+
let ``TaskSeq-takeWhile has no effect`` variant =
18+
Gen.getEmptyVariant variant
19+
|> TaskSeq.takeWhile ((=) 12)
20+
|> TaskSeq.toListAsync
21+
|> Task.map (List.isEmpty >> should be True)
22+
23+
[<Theory; ClassData(typeof<TestEmptyVariants>)>]
24+
let ``TaskSeq-takeWhileAsync has no effect`` variant =
25+
Gen.getEmptyVariant variant
26+
|> TaskSeq.takeWhileAsync (fun x -> task { return x = 12 })
27+
|> TaskSeq.toListAsync
28+
|> Task.map (List.isEmpty >> should be True)
29+
30+
module Immutable =
31+
[<Theory; ClassData(typeof<TestImmTaskSeq>)>]
32+
let ``TaskSeq-takeWhile filters correctly`` variant =
33+
Gen.getSeqImmutable variant
34+
|> TaskSeq.takeWhile (fun x -> x <= 5)
35+
|> TaskSeq.map char
36+
|> TaskSeq.map ((+) '@')
37+
|> TaskSeq.toArrayAsync
38+
|> Task.map (String >> should equal "ABCDE")
39+
40+
[<Theory; ClassData(typeof<TestImmTaskSeq>)>]
41+
let ``TaskSeq-takeWhileAsync filters correctly`` variant =
42+
Gen.getSeqImmutable variant
43+
|> TaskSeq.takeWhileAsync (fun x -> task { return x <= 5 })
44+
|> TaskSeq.map char
45+
|> TaskSeq.map ((+) '@')
46+
|> TaskSeq.toArrayAsync
47+
|> Task.map (String >> should equal "ABCDE")
48+
49+
module SideEffects =
50+
[<Theory; ClassData(typeof<TestSideEffectTaskSeq>)>]
51+
let ``TaskSeq-takeWhile filters correctly`` variant =
52+
Gen.getSeqWithSideEffect variant
53+
|> TaskSeq.takeWhile (fun x -> x <= 5)
54+
|> TaskSeq.map char
55+
|> TaskSeq.map ((+) '@')
56+
|> TaskSeq.toArrayAsync
57+
|> Task.map (String >> should equal "ABCDE")
58+
59+
[<Theory; ClassData(typeof<TestSideEffectTaskSeq>)>]
60+
let ``TaskSeq-takeWhileAsync filters correctly`` variant =
61+
Gen.getSeqWithSideEffect variant
62+
|> TaskSeq.takeWhileAsync (fun x -> task { return x <= 5 })
63+
|> TaskSeq.map char
64+
|> TaskSeq.map ((+) '@')
65+
|> TaskSeq.toArrayAsync
66+
|> Task.map (String >> should equal "ABCDE")

0 commit comments

Comments
 (0)