Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Dec 24, 2023
1 parent 5274abb commit 4638a19
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/FSharp.Control.TaskSeq.Test/Nunit.Extensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ module ExtraCustomMatchers =

CustomMatcher<obj>(
$"Throws %s{ex.Name} (Below, XUnit does not show actual value properly)",
(fun fn -> (testForThrowing (fn :?> (unit -> Task))).Result)
(fun fn -> (testForThrowing (fn :?> unit -> Task)).Result)
)

/// <summary>
Expand Down Expand Up @@ -170,7 +170,7 @@ module ExtraCustomMatchers =

CustomMatcher<obj>(
$"Throws %s{ex.Name} (Below, XUnit does not show actual value properly)",
(fun fn -> (testForThrowing (fn :?> (unit -> Task))).Result)
(fun fn -> (testForThrowing (fn :?> unit -> Task)).Result)
)

let inline assertThrows ty (f: unit -> 'U) = f >> ignore |> should throw ty
Expand Down
24 changes: 13 additions & 11 deletions src/FSharp.Control.TaskSeq.Test/TestUtils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,25 @@ type DummyTaskFactory(µsecMin: int64<µs>, µsecMax: int64<µs>) =
/// <summary>
/// Creates dummy tasks with a randomized delay and a mutable state,
/// to ensure we properly test whether processing is done ordered or not.
/// Uses the defaults for <paramref name="µsecMin" /> and <paramref name="µsecMax" />
/// Uses the defaults for <paramref name="minMs" /> and <paramref name="maxMs" />
/// with 10,000µs and 30,000µs respectively (or 10ms and 30ms).
/// </summary>
new() = new DummyTaskFactory(10_000L<µs>, 30_000L<µs>)
new() = DummyTaskFactory(10_000L<µs>, 30_000L<µs>)

/// <summary>
/// Creates dummy tasks with a randomized delay and a mutable state,
/// to ensure we properly test whether processing is done ordered or not.
/// Values <paramref name="msecMin" /> and <paramref name="msecMax" /> can be
/// Values <paramref name="minMs" /> and <paramref name="maxMs" /> can be
/// given in milliseconds.
/// </summary>
new(msecMin: int<ms>, msecMax: int<ms>) = new DummyTaskFactory(int64 msecMin * 1000L<µs>, int64 msecMax * 1000L<µs>)
/// <param name="minMs">Minimum delay</param>
/// <param name="maxMs">Maximum delay</param>
new(minMs: int<ms>, maxMs: int<ms>) = DummyTaskFactory(int64 minMs * 1000L<µs>, int64 maxMs * 1000L<µs>)


/// Bunch of delayed tasks that randomly have a yielding delay of 10-30ms, therefore having overlapping execution times.
member _.CreateDelayedTasks_SideEffect total = [
for i in 0 .. total - 1 do
for _ in 0 .. total - 1 do
fun () -> runTaskDelayed ()
]

Expand All @@ -123,7 +125,7 @@ type DummyTaskFactory(µsecMin: int64<µs>, µsecMax: int64<µs>) =

/// Bunch of delayed tasks without internally using Task.Delay, therefore hot-started and immediately finished.
member _.CreateDirectTasks_SideEffect total = [
for i in 0 .. total - 1 do
for _ in 0 .. total - 1 do
fun () -> runTaskDirect ()
]

Expand Down Expand Up @@ -316,10 +318,10 @@ module TestUtils =
let getEmptyVariant variant : IAsyncEnumerable<int> =
match variant with
| EmptyVariant.CallEmpty -> TaskSeq.empty
| EmptyVariant.Do -> taskSeq { do ignore () }
| EmptyVariant.Do -> taskSeq { do () }
| EmptyVariant.DoBang -> taskSeq { do! task { return () } }
| EmptyVariant.YieldBang -> taskSeq { yield! Seq.empty<int> }
| EmptyVariant.YieldBangNested -> taskSeq { yield! taskSeq { do ignore () } }
| EmptyVariant.YieldBangNested -> taskSeq { yield! taskSeq { do () } }
| EmptyVariant.DelayDoBang -> taskSeq {
do! microDelay ()
do! microDelay ()
Expand Down Expand Up @@ -468,7 +470,7 @@ module TestUtils =

| SeqWithSideEffect.Sequential_For -> taskSeq {
// F# BUG? coloring disappears?
for x = 0 to 9 do
for _ = 0 to 9 do
i <- i + 1
yield i
}
Expand Down Expand Up @@ -528,7 +530,7 @@ module TestUtils =
/// Will add 1 to the passed integer upon disposing.
let getEmptyDisposableTaskSeq (disposed: int ref) =
{ new IAsyncEnumerable<'T> with
member _.GetAsyncEnumerator(_) =
member _.GetAsyncEnumerator _ =
{ new IAsyncEnumerator<'T> with
member _.MoveNextAsync() = ValueTask.False
member _.Current = Unchecked.defaultof<'T>
Expand All @@ -540,7 +542,7 @@ module TestUtils =
/// The singleton value is '42'. Will add 1 to the passed integer upon disposing.
let getSingletonDisposableTaskSeq (disposed: int ref) =
{ new IAsyncEnumerable<int> with
member _.GetAsyncEnumerator(_) =
member _.GetAsyncEnumerator _ =
let mutable status = BeforeAll

{ new IAsyncEnumerator<int> with
Expand Down

0 comments on commit 4638a19

Please sign in to comment.