Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup: Spelling, unused bindings #226

Merged
merged 5 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="Nunit.Extensions.fs" />
<Compile Include="Xunit.Extensions.fs" />
<Compile Include="TestUtils.fs" />
<Compile Include="TaskSeq.Append.Tests.fs" />
<Compile Include="TaskSeq.Cast.Tests.fs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ module EmptySeq =
}

[<Fact>]
let ``Async-for CE must execute side effect in empty taskseq`` () = async {
let ``Async-for CE must execute side effect in empty taskSeq`` () = async {
let mutable data = 0
let values = taskSeq { do data <- 42 }

for x in values do
for _ in values do
()

data |> should equal 42
Expand Down Expand Up @@ -121,7 +121,7 @@ module Other =
let disposed = ref 0
let values = Gen.getEmptyDisposableTaskSeq disposed

for x in values do
for _ in values do
()

// the DisposeAsync should be called by now
Expand Down
24 changes: 12 additions & 12 deletions src/FSharp.Control.TaskSeq.Test/TaskSeq.Collect.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ module SideEffects =
// point of this test: just calling 'map' won't execute anything of the sequence!
let _ =
ts
|> TaskSeq.collect (fun x -> taskSeq { yield 10 })
|> TaskSeq.collect (fun x -> taskSeq { yield 10 })
|> TaskSeq.collect (fun x -> taskSeq { yield 10 })
|> TaskSeq.collect (fun _ -> taskSeq { yield 10 })
|> TaskSeq.collect (fun _ -> taskSeq { yield 10 })
|> TaskSeq.collect (fun _ -> taskSeq { yield 10 })

// multiple maps have no effect unless executed
i |> should equal 0
Expand All @@ -201,9 +201,9 @@ module SideEffects =
// point of this test: just calling 'map' won't execute anything of the sequence!
let _ =
ts
|> TaskSeq.collectAsync (fun x -> task { return taskSeq { yield 10 } })
|> TaskSeq.collectAsync (fun x -> task { return taskSeq { yield 10 } })
|> TaskSeq.collectAsync (fun x -> task { return taskSeq { yield 10 } })
|> TaskSeq.collectAsync (fun _ -> task { return taskSeq { yield 10 } })
|> TaskSeq.collectAsync (fun _ -> task { return taskSeq { yield 10 } })
|> TaskSeq.collectAsync (fun _ -> task { return taskSeq { yield 10 } })

// multiple maps have no effect unless executed
i |> should equal 0
Expand All @@ -222,9 +222,9 @@ module SideEffects =
// point of this test: just calling 'map' won't execute anything of the sequence!
let _ =
ts
|> TaskSeq.collectSeq (fun x -> seq { yield 10 })
|> TaskSeq.collectSeq (fun x -> seq { yield 10 })
|> TaskSeq.collectSeq (fun x -> seq { yield 10 })
|> TaskSeq.collectSeq (fun _ -> seq { yield 10 })
|> TaskSeq.collectSeq (fun _ -> seq { yield 10 })
|> TaskSeq.collectSeq (fun _ -> seq { yield 10 })

// multiple maps have no effect unless executed
i |> should equal 0
Expand All @@ -243,9 +243,9 @@ module SideEffects =
// point of this test: just calling 'map' won't execute anything of the sequence!
let _ =
ts
|> TaskSeq.collectSeqAsync (fun x -> task { return seq { yield 10 } })
|> TaskSeq.collectSeqAsync (fun x -> task { return seq { yield 10 } })
|> TaskSeq.collectSeqAsync (fun x -> task { return seq { yield 10 } })
|> TaskSeq.collectSeqAsync (fun _ -> task { return seq { yield 10 } })
|> TaskSeq.collectSeqAsync (fun _ -> task { return seq { yield 10 } })
|> TaskSeq.collectSeqAsync (fun _ -> task { return seq { yield 10 } })

// multiple maps have no effect unless executed
i |> should equal 0
6 changes: 3 additions & 3 deletions src/FSharp.Control.TaskSeq.Test/TaskSeq.Do.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ let ``CE taskSeq: use 'do!' with a task<unit>`` () =
|> Task.map (fun _ -> value |> should equal 1)

[<Fact>]
let ``CE taskSeq: use 'do!' with a valuetask<unit>`` () =
let ``CE taskSeq: use 'do!' with a ValueTask<unit>`` () =
let mutable value = 0

taskSeq { do! ValueTask.ofTask (task { do value <- value + 1 }) }
|> verifyEmpty
|> Task.map (fun _ -> value |> should equal 1)

[<Fact>]
let ``CE taskSeq: use 'do!' with a non-generic valuetask`` () =
let ``CE taskSeq: use 'do!' with a non-generic ValueTask`` () =
let mutable value = 0

taskSeq { do! ValueTask(task { do value <- value + 1 }) }
Expand Down Expand Up @@ -92,7 +92,7 @@ let ``CE taskSeq: use 'do!' with all kinds of overloads at once`` () =
do! task { do value <- value + 1 } |> Task.ignore
do! ValueTask <| task { do value <- value + 1 }
do! ValueTask.ofTask (task { do value <- value + 1 })
do! ValueTask<_>(()) // unit valuetask that completes immediately
do! ValueTask<_>(()) // unit ValueTask that completes immediately
do! Task.fromResult (()) // unit Task that completes immediately
do! Task.Delay 0
do! Async.Sleep 0
Expand Down
2 changes: 0 additions & 2 deletions src/FSharp.Control.TaskSeq.Test/TaskSeq.Filter.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module TaskSeq.Tests.Filter

open System

open Xunit
open FsUnit.Xunit

Expand Down
8 changes: 4 additions & 4 deletions src/FSharp.Control.TaskSeq.Test/TaskSeq.Head.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ module SideEffects =
x <- x + 1 // we never get here
}

let! fortytwo = one |> TaskSeq.head
let! fortyTwo = one |> TaskSeq.head
let! stillFortyTwo = one |> TaskSeq.head // the statement after 'yield' will never be reached

fortytwo |> should equal 42
fortyTwo |> should equal 42
stillFortyTwo |> should equal 42
}

Expand All @@ -114,8 +114,8 @@ module SideEffects =
x <- x + 1 // we never get here
}

let! fortytwo = one |> TaskSeq.tryHead
fortytwo |> should equal (Some 42)
let! fortyTwo = one |> TaskSeq.tryHead
fortyTwo |> should equal (Some 42)

// the statement after 'yield' will never be reached, the mutable will not be updated
let! stillFortyTwo = one |> TaskSeq.tryHead
Expand Down
17 changes: 8 additions & 9 deletions src/FSharp.Control.TaskSeq.Test/TaskSeq.Last.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ module SideEffects =
x <- x + 1
}

let! fortytwo = one |> TaskSeq.last
let! fortythree = one |> TaskSeq.last // side effect, re-iterating!
let! fortyTwo = one |> TaskSeq.last
let! fortyThree = one |> TaskSeq.last // side effect, re-iterating!

fortytwo |> should equal 42
fortythree |> should equal 43
fortyTwo |> should equal 42
fortyThree |> should equal 43
}

[<Fact>]
Expand All @@ -125,13 +125,12 @@ module SideEffects =
x <- x + 1
}

let! fortytwo = one |> TaskSeq.tryLast
fortytwo |> should equal (Some 42)
let! fortyTwo = one |> TaskSeq.tryLast
fortyTwo |> should equal (Some 42)

// side effect, reiterating causes it to execute again!
let! fortythree = one |> TaskSeq.tryLast
fortythree |> should equal (Some 43)

let! fortyThree = one |> TaskSeq.tryLast
fortyThree |> should equal (Some 43)
}

[<Theory; ClassData(typeof<TestSideEffectTaskSeq>)>]
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Control.TaskSeq.Test/TaskSeq.Length.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ module Immutable =
do! run (fun x -> x % 3 = 2) |> Task.map (should equal 3) // [2; 5; 8]
}

module SideSeffects =
module SideEffects =
[<Fact>]
let ``TaskSeq-length prove we execute after-effects`` () = task {
let mutable i = 0
Expand Down
9 changes: 4 additions & 5 deletions src/FSharp.Control.TaskSeq.Test/TaskSeq.Let.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module TaskSeq.Tests.Let

open System
open System.Threading.Tasks

open FsUnit
Expand Down Expand Up @@ -41,7 +40,7 @@ let ``CE taskSeq: use 'let!' with a task<string>`` () =
|> Task.map (should equal "test")

[<Fact>]
let ``CE taskSeq: use 'let!' with a valuetask<unit>`` () =
let ``CE taskSeq: use 'let!' with a ValueTask<unit>`` () =
let mutable value = 0

taskSeq {
Expand All @@ -52,7 +51,7 @@ let ``CE taskSeq: use 'let!' with a valuetask<unit>`` () =
|> Task.map (fun _ -> value |> should equal 1)

[<Fact>]
let ``CE taskSeq: use 'let!' with a valuetask<string>`` () =
let ``CE taskSeq: use 'let!' with a ValueTask<string>`` () =
taskSeq {
let! test = ValueTask.ofTask (task { return "test" })
yield test
Expand All @@ -61,7 +60,7 @@ let ``CE taskSeq: use 'let!' with a valuetask<string>`` () =
|> Task.map (should equal "test")

[<Fact>]
let ``CE taskSeq: use 'let!' with a non-generic valuetask`` () =
let ``CE taskSeq: use 'let!' with a non-generic ValueTask`` () =
let mutable value = 0

taskSeq {
Expand Down Expand Up @@ -136,7 +135,7 @@ let ``CE taskSeq: use 'let!' with all kinds of overloads at once`` () =
}
|> ValueTask<int>

let! c = ValueTask<_>(4) // valuetask that completes immediately
let! c = ValueTask<_>(4) // ValueTask that completes immediately
let! _ = Task.Factory.StartNew(fun () -> value <- value + 1) // non-generic Task with side effect
let! d = Task.fromResult 99 // normal Task that completes immediately
let! _ = Async.Sleep 0 // unit Async
Expand Down
6 changes: 3 additions & 3 deletions src/FSharp.Control.TaskSeq.Test/TaskSeq.Map.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ module SideEffects =


[<Theory; ClassData(typeof<TestSideEffectTaskSeq>)>]
let ``TaskSeq-map can access mutables which are mutated in correct order`` variant =
let ``TaskSeq-map can access mutables that are mutated in correct order`` variant =
let mutable sum = 0

Gen.getSeqWithSideEffect variant
|> TaskSeq.map (fun item ->
|> TaskSeq.map (fun _ ->
sum <- sum + 1
char (sum + 64))
|> validateSequence
Expand Down Expand Up @@ -221,7 +221,7 @@ module SideEffects =
let mutable sum = 0

Gen.getSeqWithSideEffect variant
|> TaskSeq.mapAsync (fun item -> task {
|> TaskSeq.mapAsync (fun _ -> task {
sum <- sum + 1
return char (sum + 64)
})
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Control.TaskSeq.Test/TaskSeq.MaxMin.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ module Immutable =
min |> should equal 10 // because -10 maps to item 10
}

module SideSeffects =
module SideEffects =
[<Fact>]
let ``TaskSeq-max, maxBy, maxByAsync prove we execute after-effects`` () = task {
let mutable i = 0
Expand Down
4 changes: 2 additions & 2 deletions src/FSharp.Control.TaskSeq.Test/TaskSeq.Realworld.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ open Xunit.Abstractions

/// Just a naive, simple in-memory reader that acts as an IAsyncEnumerable to use with tests
/// IMPORTANT: currently this is not thread-safe!!!
type AsyncBufferedReader(output: ITestOutputHelper, data, blockSize) =
type AsyncBufferedReader(_output: ITestOutputHelper, data, blockSize) =
let stream = new MemoryStream(data: byte[])
let buffered = new BufferedStream(stream, blockSize)
let mutable current = ValueNone
let mutable lastPos = 0L

interface IAsyncEnumerable<byte[]> with
member reader.GetAsyncEnumerator(ct) =
member reader.GetAsyncEnumerator _ =
{ new IAsyncEnumerator<_> with
member this.Current = (reader :> IAsyncEnumerator<_>).Current
member this.MoveNextAsync() = (reader :> IAsyncEnumerator<_>).MoveNextAsync()
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Control.TaskSeq.Test/TaskSeq.Skip.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ module SideEffects =
}

[<Fact>]
let ``TaskSeq-skip prove that an exception from the taskseq is thrown instead of exception from function`` () =
let ``TaskSeq-skip prove that an exception from the taskSeq is thrown instead of exception from function`` () =
let items = taskSeq {
yield 42
yield! [ 1; 2 ]
Expand Down
2 changes: 0 additions & 2 deletions src/FSharp.Control.TaskSeq.Test/TaskSeq.SkipWhile.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module TaskSeq.Tests.skipWhile

open System

open Xunit
open FsUnit.Xunit

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ let ``CE taskSeq, MoveNext too far`` () = task {
do! Assert.moveNextAndCheck false enum // third item: false

// then call it bunch of times to ensure we don't get an InvalidOperationException, see issue #39 and PR #42
for i in 0..100 do
for _ in 0..100 do
do! Assert.moveNextAndCheck false enum

// after whatever amount of time MoveNextAsync, we can still safely call Current
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ open FSharp.Control

[<Fact>]
let ``CE empty taskSeq with MoveNextAsync -- untyped`` () = task {
let tskSeq = taskSeq { do ignore () }
let tskSeq = taskSeq { do () }

Assert.IsAssignableFrom<IAsyncEnumerable<obj>>(tskSeq)
|> ignore
Expand All @@ -32,16 +32,16 @@ let ``CE empty taskSeq with MoveNextAsync -- typed`` variant = task {
[<Theory; ClassData(typeof<TestEmptyVariants>)>]
let ``CE empty taskSeq, GetAsyncEnumerator multiple times`` variant = task {
let tskSeq = Gen.getEmptyVariant variant
use _e = tskSeq.GetAsyncEnumerator()
use _e = tskSeq.GetAsyncEnumerator()
use _e = tskSeq.GetAsyncEnumerator()
use _ = tskSeq.GetAsyncEnumerator()
use _ = tskSeq.GetAsyncEnumerator()
use _ = tskSeq.GetAsyncEnumerator()
()
}

[<Theory; ClassData(typeof<TestEmptyVariants>)>]
let ``CE empty taskSeq, GetAsyncEnumerator multiple times and then MoveNextAsync`` variant = task {
let tskSeq = Gen.getEmptyVariant variant
use enumerator = tskSeq.GetAsyncEnumerator()
use _ = tskSeq.GetAsyncEnumerator()
use enumerator = tskSeq.GetAsyncEnumerator()
do! Assert.moveNextAndCheck false enumerator
}
Expand Down Expand Up @@ -86,7 +86,7 @@ let ``CE empty taskSeq, GetAsyncEnumerator + MoveNextAsync 100x in a loop`` vari
let tskSeq = Gen.getEmptyVariant variant

// let's get the enumerator a few times
for i in 0..100 do
for _ in 0..100 do
use enumerator = tskSeq.GetAsyncEnumerator()
do! Assert.moveNextAndCheck false enumerator // these are all empty
}
Expand Down Expand Up @@ -202,7 +202,7 @@ let ``CE taskSeq, MoveNext too far`` () = task {
do! Assert.moveNextAndCheck false enum // third item: false

// then call it bunch of times to ensure we don't get an InvalidOperationException, see issue #39 and PR #42
for i in 0..100 do
for _ in 0..100 do
do! Assert.moveNextAndCheck false enum

// after whatever amount of time MoveNextAsync, we can still safely call Current
Expand Down Expand Up @@ -234,7 +234,7 @@ let ``CE taskSeq, call GetAsyncEnumerator twice, both should have equal behavior

[<Fact>]
let ``CE seq -- comparison --, call GetEnumerator twice`` () = task {
// this test is for behavioral comparisoni between the same Async test above with TaskSeq
// this test is for behavioral comparison between the same Async test above with TaskSeq
let sq = seq {
yield 1
yield 2
Expand Down
6 changes: 3 additions & 3 deletions src/FSharp.Control.TaskSeq.Test/TaskSeq.Take.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ module SideEffects =

first |> should equal expected
repeat |> should equal expected // if we read too far, this is now [|43, 86|]
x |> should equal 42 // expect: side-effect at end of taskseq not executed
x |> should equal 42 // expect: side-effect at end of taskSeq not executed
}

[<Fact>]
Expand All @@ -207,7 +207,7 @@ module SideEffects =


[<Fact>]
let ``TaskSeq-take prove that an exception from the taskseq is thrown instead of exception from function`` () =
let ``TaskSeq-take prove that an exception from the taskSeq is thrown instead of exception from function`` () =
let items = taskSeq {
yield 42
yield! [ 1; 2 ]
Expand Down Expand Up @@ -235,5 +235,5 @@ module SideEffects =

first |> should equal expected
repeat |> should equal expected // if we read too far, this is now [|43, 86|]
x |> should equal 42 // expect: side-effect at end of taskseq not executed
x |> should equal 42 // expect: side-effect at end of taskSeq not executed
}
2 changes: 0 additions & 2 deletions src/FSharp.Control.TaskSeq.Test/TaskSeq.TakeWhile.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module TaskSeq.Tests.TakeWhile

open System

open Xunit
open FsUnit.Xunit

Expand Down
Loading