Skip to content

Commit 4e49d8e

Browse files
bartelinkabelbraaksma
authored andcommitted
Small code cleanup refactorings
1 parent 2692bb1 commit 4e49d8e

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/FSharp.Control.TaskSeq.Test/Nunit.Extensions.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ module ExtraCustomMatchers =
134134

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

140140
/// <summary>
@@ -170,7 +170,7 @@ module ExtraCustomMatchers =
170170

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

176176
let inline assertThrows ty (f: unit -> 'U) = f >> ignore |> should throw ty

src/FSharp.Control.TaskSeq.Test/TestUtils.fs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ module DelayHelper =
7979
/// Default for <paramref name="µsecMin" /> and <paramref name="µsecMax" />
8080
/// are 10,000µs and 30,000µs respectively (or 10ms and 30ms).
8181
/// </summary>
82+
/// <param name="µsecMin">Minimum delay in µs</param>
83+
/// <param name="µsecMax">Maximum delay in µs</param>
8284
type DummyTaskFactory(µsecMin: int64<µs>, µsecMax: int64<µs>) =
8385
let mutable x = 0
8486

@@ -98,20 +100,22 @@ type DummyTaskFactory(µsecMin: int64<µs>, µsecMax: int64<µs>) =
98100
/// Uses the defaults for <paramref name="µsecMin" /> and <paramref name="µsecMax" />
99101
/// with 10,000µs and 30,000µs respectively (or 10ms and 30ms).
100102
/// </summary>
101-
new() = new DummyTaskFactory(10_000L<µs>, 30_000L<µs>)
103+
new() = DummyTaskFactory(10_000L<µs>, 30_000L<µs>)
102104

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

111115

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

@@ -123,7 +127,7 @@ type DummyTaskFactory(µsecMin: int64<µs>, µsecMax: int64<µs>) =
123127

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

@@ -468,7 +472,7 @@ module TestUtils =
468472

469473
| SeqWithSideEffect.Sequential_For -> taskSeq {
470474
// F# BUG? coloring disappears?
471-
for x = 0 to 9 do
475+
for _ = 0 to 9 do
472476
i <- i + 1
473477
yield i
474478
}
@@ -528,7 +532,7 @@ module TestUtils =
528532
/// Will add 1 to the passed integer upon disposing.
529533
let getEmptyDisposableTaskSeq (disposed: int ref) =
530534
{ new IAsyncEnumerable<'T> with
531-
member _.GetAsyncEnumerator(_) =
535+
member _.GetAsyncEnumerator _ =
532536
{ new IAsyncEnumerator<'T> with
533537
member _.MoveNextAsync() = ValueTask.False
534538
member _.Current = Unchecked.defaultof<'T>
@@ -540,7 +544,7 @@ module TestUtils =
540544
/// The singleton value is '42'. Will add 1 to the passed integer upon disposing.
541545
let getSingletonDisposableTaskSeq (disposed: int ref) =
542546
{ new IAsyncEnumerable<int> with
543-
member _.GetAsyncEnumerator(_) =
547+
member _.GetAsyncEnumerator _ =
544548
let mutable status = BeforeAll
545549

546550
{ new IAsyncEnumerator<int> with

0 commit comments

Comments
 (0)