diff --git a/src/FSharp.Control.TaskSeq.Test/TaskSeq.Skip.Tests.fs b/src/FSharp.Control.TaskSeq.Test/TaskSeq.Skip.Tests.fs index dc0cfa1e..c44e4841 100644 --- a/src/FSharp.Control.TaskSeq.Test/TaskSeq.Skip.Tests.fs +++ b/src/FSharp.Control.TaskSeq.Test/TaskSeq.Skip.Tests.fs @@ -14,15 +14,6 @@ open FSharp.Control exception SideEffectPastEnd of string -[] -module With = - /// Turns a sequence of numbers into a string, starting with A for '1' - let verifyAsString expected = - TaskSeq.map char - >> TaskSeq.map ((+) '@') - >> TaskSeq.toArrayAsync - >> Task.map (String >> should equal expected) - module EmptySeq = [)>] let ``TaskSeq-skip(0) has no effect on empty input`` variant = @@ -100,17 +91,17 @@ module Immutable = do! Gen.getSeqImmutable variant |> TaskSeq.skip 0 - |> verifyAsString "ABCDEFGHIJ" + |> verifyDigitsAsString "ABCDEFGHIJ" do! Gen.getSeqImmutable variant |> TaskSeq.skip 1 - |> verifyAsString "BCDEFGHIJ" + |> verifyDigitsAsString "BCDEFGHIJ" do! Gen.getSeqImmutable variant |> TaskSeq.skip 5 - |> verifyAsString "FGHIJ" + |> verifyDigitsAsString "FGHIJ" do! Gen.getSeqImmutable variant @@ -143,17 +134,17 @@ module Immutable = do! Gen.getSeqImmutable variant |> TaskSeq.drop 0 - |> verifyAsString "ABCDEFGHIJ" + |> verifyDigitsAsString "ABCDEFGHIJ" do! Gen.getSeqImmutable variant |> TaskSeq.drop 1 - |> verifyAsString "BCDEFGHIJ" + |> verifyDigitsAsString "BCDEFGHIJ" do! Gen.getSeqImmutable variant |> TaskSeq.drop 5 - |> verifyAsString "FGHIJ" + |> verifyDigitsAsString "FGHIJ" do! Gen.getSeqImmutable variant @@ -176,13 +167,13 @@ module SideEffects = let ``TaskSeq-skip skips over enough items`` variant = Gen.getSeqWithSideEffect variant |> TaskSeq.skip 5 - |> verifyAsString "FGHIJ" + |> verifyDigitsAsString "FGHIJ" [)>] let ``TaskSeq-drop skips over enough items`` variant = Gen.getSeqWithSideEffect variant |> TaskSeq.drop 5 - |> verifyAsString "FGHIJ" + |> verifyDigitsAsString "FGHIJ" [] let ``TaskSeq-skip prove we do not skip side effects`` () = task { diff --git a/src/FSharp.Control.TaskSeq.Test/TaskSeq.Take.Tests.fs b/src/FSharp.Control.TaskSeq.Test/TaskSeq.Take.Tests.fs index 13297e4c..9e633a38 100644 --- a/src/FSharp.Control.TaskSeq.Test/TaskSeq.Take.Tests.fs +++ b/src/FSharp.Control.TaskSeq.Test/TaskSeq.Take.Tests.fs @@ -14,15 +14,6 @@ open FSharp.Control exception SideEffectPastEnd of string -[] -module With = - /// Turns a sequence of numbers into a string, starting with A for '1' - let verifyAsString expected = - TaskSeq.map char - >> TaskSeq.map ((+) '@') - >> TaskSeq.toArrayAsync - >> Task.map (String >> should equal expected) - module EmptySeq = [)>] let ``TaskSeq-take(0) has no effect on empty input`` variant = @@ -105,17 +96,17 @@ module Immutable = do! Gen.getSeqImmutable variant |> TaskSeq.take 1 - |> verifyAsString "A" + |> verifyDigitsAsString "A" do! Gen.getSeqImmutable variant |> TaskSeq.take 5 - |> verifyAsString "ABCDE" + |> verifyDigitsAsString "ABCDE" do! Gen.getSeqImmutable variant |> TaskSeq.take 10 - |> verifyAsString "ABCDEFGHIJ" + |> verifyDigitsAsString "ABCDEFGHIJ" } [)>] @@ -148,27 +139,27 @@ module Immutable = do! Gen.getSeqImmutable variant |> TaskSeq.truncate 1 - |> verifyAsString "A" + |> verifyDigitsAsString "A" do! Gen.getSeqImmutable variant |> TaskSeq.truncate 5 - |> verifyAsString "ABCDE" + |> verifyDigitsAsString "ABCDE" do! Gen.getSeqImmutable variant |> TaskSeq.truncate 10 - |> verifyAsString "ABCDEFGHIJ" + |> verifyDigitsAsString "ABCDEFGHIJ" do! Gen.getSeqImmutable variant |> TaskSeq.truncate 11 - |> verifyAsString "ABCDEFGHIJ" + |> verifyDigitsAsString "ABCDEFGHIJ" do! Gen.getSeqImmutable variant |> TaskSeq.truncate 10_000_000 - |> verifyAsString "ABCDEFGHIJ" + |> verifyDigitsAsString "ABCDEFGHIJ" } module SideEffects = @@ -176,13 +167,13 @@ module SideEffects = let ``TaskSeq-take gets enough items`` variant = Gen.getSeqWithSideEffect variant |> TaskSeq.take 5 - |> verifyAsString "ABCDE" + |> verifyDigitsAsString "ABCDE" [)>] let ``TaskSeq-truncate gets enough items`` variant = Gen.getSeqWithSideEffect variant |> TaskSeq.truncate 5 - |> verifyAsString "ABCDE" + |> verifyDigitsAsString "ABCDE" [] let ``TaskSeq-take prove it does not read beyond the last yield`` () = task { @@ -212,7 +203,7 @@ module SideEffects = do SideEffectPastEnd "at the end" |> raise // we SHOULD NOT get here } - items |> TaskSeq.take 3 |> verifyAsString "ABC" + items |> TaskSeq.take 3 |> verifyDigitsAsString "ABC" [] diff --git a/src/FSharp.Control.TaskSeq.Test/TaskSeq.TakeWhile.Tests.fs b/src/FSharp.Control.TaskSeq.Test/TaskSeq.TakeWhile.Tests.fs index de1ac77d..a68e29ea 100644 --- a/src/FSharp.Control.TaskSeq.Test/TaskSeq.TakeWhile.Tests.fs +++ b/src/FSharp.Control.TaskSeq.Test/TaskSeq.TakeWhile.Tests.fs @@ -25,13 +25,6 @@ module With = | true, false -> TaskSeq.takeWhileInclusive | true, true -> fun pred -> TaskSeq.takeWhileInclusiveAsync (pred >> Task.fromResult) - /// Turns a sequence of numbers into a string, starting with A for '1' - let verifyAsString expected = - TaskSeq.map char - >> TaskSeq.map ((+) '@') - >> TaskSeq.toArrayAsync - >> Task.map (String >> should equal expected) - /// This is the base condition as one would expect in actual code let inline cond x = x <> 6 @@ -82,12 +75,12 @@ module Immutable = do! Gen.getSeqImmutable variant |> TaskSeq.takeWhile condWithGuard - |> verifyAsString "ABCDE" + |> verifyDigitsAsString "ABCDE" do! Gen.getSeqImmutable variant |> TaskSeq.takeWhileAsync (fun x -> task { return condWithGuard x }) - |> verifyAsString "ABCDE" + |> verifyDigitsAsString "ABCDE" } [)>] @@ -95,12 +88,12 @@ module Immutable = do! Gen.getSeqImmutable variant |> TaskSeq.takeWhile ((=) 0) - |> verifyAsString "" + |> verifyDigitsAsString "" do! Gen.getSeqImmutable variant |> TaskSeq.takeWhileAsync ((=) 0 >> Task.fromResult) - |> verifyAsString "" + |> verifyDigitsAsString "" } [)>] @@ -108,12 +101,12 @@ module Immutable = do! Gen.getSeqImmutable variant |> TaskSeq.takeWhileInclusive condWithGuard - |> verifyAsString "ABCDEF" + |> verifyDigitsAsString "ABCDEF" do! Gen.getSeqImmutable variant |> TaskSeq.takeWhileInclusiveAsync (fun x -> task { return condWithGuard x }) - |> verifyAsString "ABCDEF" + |> verifyDigitsAsString "ABCDEF" } [)>] @@ -121,12 +114,12 @@ module Immutable = do! Gen.getSeqImmutable variant |> TaskSeq.takeWhileInclusive ((=) 0) - |> verifyAsString "A" + |> verifyDigitsAsString "A" do! Gen.getSeqImmutable variant |> TaskSeq.takeWhileInclusiveAsync ((=) 0 >> Task.fromResult) - |> verifyAsString "A" + |> verifyDigitsAsString "A" } module SideEffects = @@ -134,13 +127,13 @@ module SideEffects = let ``TaskSeq-takeWhile filters correctly`` variant = Gen.getSeqWithSideEffect variant |> TaskSeq.takeWhile condWithGuard - |> verifyAsString "ABCDE" + |> verifyDigitsAsString "ABCDE" [)>] let ``TaskSeq-takeWhileAsync filters correctly`` variant = Gen.getSeqWithSideEffect variant |> TaskSeq.takeWhileAsync (fun x -> task { return condWithGuard x }) - |> verifyAsString "ABCDE" + |> verifyDigitsAsString "ABCDE" [] [] @@ -246,7 +239,7 @@ module Other = [ 1; 2; 2; 3; 3; 2; 1 ] |> TaskSeq.ofSeq |> functionToTest (fun x -> x <= 2) - |> verifyAsString (if inclusive then "ABBC" else "ABB") + |> verifyDigitsAsString (if inclusive then "ABBC" else "ABB") [] [] @@ -262,4 +255,4 @@ module Other = } |> TaskSeq.ofSeq |> functionToTest (fun x -> x <= 2) - |> verifyAsString (if inclusive then "ABBC" else "ABB") + |> verifyDigitsAsString (if inclusive then "ABBC" else "ABB") diff --git a/src/FSharp.Control.TaskSeq.Test/TestUtils.fs b/src/FSharp.Control.TaskSeq.Test/TestUtils.fs index c98b4797..d81b8bf9 100644 --- a/src/FSharp.Control.TaskSeq.Test/TestUtils.fs +++ b/src/FSharp.Control.TaskSeq.Test/TestUtils.fs @@ -141,10 +141,10 @@ module TestUtils = |> TaskSeq.toArrayAsync |> Task.map (should equal [| 1..10 |]) - /// Turns a sequence of numbers into a string, starting with A for '1' + /// Turns a sequence of integers into a string, starting with A for '1', Z for 26 etc. let verifyDigitsAsString expected = - TaskSeq.map char - >> TaskSeq.map ((+) '@') + TaskSeq.map (char: int -> char) + >> TaskSeq.map ((+) '@') // turns int(1) into char('A') etc >> TaskSeq.toArrayAsync >> Task.map (String >> should equal expected)