Skip to content

Commit

Permalink
Implement TaskSeq.findIndex/tryFindIndex/findIndexAsync/tryFindIndexA…
Browse files Browse the repository at this point in the history
…sync and add tests, docs
  • Loading branch information
abelbraaksma committed Nov 3, 2022
1 parent db64dbc commit 1f547ca
Show file tree
Hide file tree
Showing 6 changed files with 559 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/FSharpy.TaskSeq.Test/FSharpy.TaskSeq.Test.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<Compile Include="TaskSeq.Empty.Tests.fs" />
<Compile Include="TaskSeq.ExactlyOne.Tests.fs" />
<Compile Include="TaskSeq.Filter.Tests.fs" />
<Compile Include="TaskSeq.FindIndex.Tests.fs" />
<Compile Include="TaskSeq.Find.Tests.fs" />
<Compile Include="TaskSeq.Fold.Tests.fs" />
<Compile Include="TaskSeq.Head.Tests.fs" />
Expand Down
8 changes: 4 additions & 4 deletions src/FSharpy.TaskSeq.Test/TaskSeq.Find.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ module SideEffects =
found |> should equal 3
i |> should equal 3 // only partial evaluation!

// find next item. We do get a new iterator, but mutable state is now starting at '3'
// find next item. We do get a new iterator, but mutable state is now starting at '3', so first item now returned is '4'.
let! found = ts |> TaskSeq.find ((=) 4)
found |> should equal 4
i |> should equal 4 // only partial evaluation!
Expand All @@ -226,7 +226,7 @@ module SideEffects =
found |> should equal 3
i |> should equal 3 // only partial evaluation!

// find next item. We do get a new iterator, but mutable state is now starting at '3'
// find next item. We do get a new iterator, but mutable state is now starting at '3', so first item now returned is '4'.
let! found = ts |> TaskSeq.findAsync (fun x -> task { return x = 4 })
found |> should equal 4
i |> should equal 4
Expand Down Expand Up @@ -360,7 +360,7 @@ module SideEffects =
found |> should equal (Some 3)
i |> should equal 3 // only partial evaluation!

// find next item. We do get a new iterator, but mutable state is now starting at '3'
// find next item. We do get a new iterator, but mutable state is now starting at '3', so first item now returned is '4'.
let! found = ts |> TaskSeq.tryFind ((=) 4)
found |> should equal (Some 4)
i |> should equal 4 // only partial evaluation!
Expand All @@ -380,7 +380,7 @@ module SideEffects =
found |> should equal (Some 3)
i |> should equal 3 // only partial evaluation!

// find next item. We do get a new iterator, but mutable state is now starting at '3'
// find next item. We do get a new iterator, but mutable state is now starting at '3', so first item now returned is '4'.
let! found = ts |> TaskSeq.tryFindAsync (fun x -> task { return x = 4 })
found |> should equal (Some 4)
i |> should equal 4
Expand Down
Loading

0 comments on commit 1f547ca

Please sign in to comment.