Skip to content

Commit 69c276a

Browse files
xperiandriclaude
andcommitted
fixup! test: FlatList.Parallel against the sequential functions and Array.Parallel
The assertion helpers of `main` are static classes with tupled arguments, so the calls of the `FlatList.Parallel` tests use them: `ExceptionAssert.Same` and `OverrideAssert.OptionMatches`. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 588a51b commit 69c276a

3 files changed

Lines changed: 65 additions & 52 deletions

File tree

‎tests/FSharp.Collections.Immutable.Tests/FlatList/FlatListParallelOptionTests.fs‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,22 @@ type FlatListParallelOptionTests () =
7272
let source = flatListOf input
7373
let found : int option = FlatList.Parallel.tryFind (isAbove 6) source
7474

75-
OverrideAssert.optionMatches
76-
(FSharp.Collections.Immutable.FlatList.Parallel.tryFind (isAbove 6) source)
77-
found
75+
OverrideAssert.OptionMatches (
76+
FSharp.Collections.Immutable.FlatList.Parallel.tryFind (isAbove 6) source,
77+
found,
7878
"Option.FlatList.Parallel.tryFind must match the default"
79+
)
7980

8081
[<TestMethod; DynamicData(nameof FlatListParallelOptionTests.Sources)>]
8182
member _.``tryFindIndex returns an option`` (input : ParallelInput) =
8283
let source = flatListOf input
8384
let found : int option = FlatList.Parallel.tryFindIndex (isAbove 6) source
8485

85-
OverrideAssert.optionMatches
86-
(FSharp.Collections.Immutable.FlatList.Parallel.tryFindIndex (isAbove 6) source)
87-
found
86+
OverrideAssert.OptionMatches (
87+
FSharp.Collections.Immutable.FlatList.Parallel.tryFindIndex (isAbove 6) source,
88+
found,
8889
"Option.FlatList.Parallel.tryFindIndex must match the default"
90+
)
8991

9092
[<TestMethod; DynamicData(nameof FlatListParallelOptionTests.Sources)>]
9193
member _.``tryPick takes a chooser of options and returns an option`` (input : ParallelInput) =
@@ -112,7 +114,7 @@ type FlatListParallelOptionTests () =
112114
[<TestMethod; DynamicData(nameof FlatListParallelOptionTests.ArrayRejections)>]
113115
member _.``the functions reject a default flat list as Array.Parallel rejects a null array`` (name : string) =
114116
let struct (oracle, actual) = arrayRejections[name]
115-
ExceptionAssert.same id oracle actual $"Option.FlatList.Parallel.%s{name} must reject a default flat list"
117+
ExceptionAssert.Same (id, oracle, actual, $"Option.FlatList.Parallel.%s{name} must reject a default flat list")
116118

117119
[<TestMethod>]
118120
member _.``the functions without an option keep resolving to the default module`` () =

‎tests/FSharp.Collections.Immutable.Tests/FlatList/FlatListParallelTests.fs‎

Lines changed: 51 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,12 @@ type FlatListParallelTests () =
306306

307307
[<TestMethod>]
308308
member _.``init throws for a negative count as Array.Parallel does`` () =
309-
ExceptionAssert.same
310-
id
311-
(fun () -> Array.Parallel.init -1 id |> ignore)
312-
(fun () -> FlatList.Parallel.init -1 id |> ignore)
309+
ExceptionAssert.Same (
310+
id,
311+
(fun () -> Array.Parallel.init -1 id |> ignore),
312+
(fun () -> FlatList.Parallel.init -1 id |> ignore),
313313
"FlatList.Parallel.init -1 must throw as Array.Parallel.init does"
314+
)
314315

315316
// ---- Search ----
316317

@@ -467,14 +468,15 @@ type FlatListParallelTests () =
467468

468469
[<TestMethod; DynamicData(nameof FlatListParallelTests.DifferentLengths)>]
469470
member _.``zip throws for different lengths as Array.Parallel does`` (first : int array, second : int array) =
470-
ExceptionAssert.same
471-
id
472-
(fun () -> Array.Parallel.zip first second |> ignore)
471+
ExceptionAssert.Same (
472+
id,
473+
(fun () -> Array.Parallel.zip first second |> ignore),
473474
(fun () ->
474475
FlatList.Parallel.zip (FlatList.ofArray first) (FlatList.ofArray second)
475476
|> ignore
476-
)
477+
),
477478
"FlatList.Parallel.zip of flat lists of different lengths must throw as Array.Parallel.zip does"
479+
)
478480

479481
[<TestMethod; DynamicData(nameof FlatListParallelTests.ZipChunks)>]
480482
member _.``zip divides every array length into chunks without overflow``
@@ -525,11 +527,12 @@ type FlatListParallelTests () =
525527

526528
[<TestMethod>]
527529
member _.``average throws for an empty flat list as Array.Parallel does`` () =
528-
ExceptionAssert.same
529-
id
530-
(fun () -> Array.Parallel.average Array.empty<float> |> ignore)
531-
(fun () -> FlatList.Parallel.average FlatList.empty<float> |> ignore)
530+
ExceptionAssert.Same (
531+
id,
532+
(fun () -> Array.Parallel.average Array.empty<float> |> ignore),
533+
(fun () -> FlatList.Parallel.average FlatList.empty<float> |> ignore),
532534
"FlatList.Parallel.average of an empty flat list must throw as Array.Parallel.average does"
535+
)
533536

534537
[<TestMethod; DynamicData(nameof FlatListParallelTests.NonEmptyInputs)>]
535538
member _.``averageBy returns the average of the projections`` (input : ParallelInput) =
@@ -543,14 +546,15 @@ type FlatListParallelTests () =
543546

544547
[<TestMethod>]
545548
member _.``averageBy throws for an empty flat list as Array.Parallel does`` () =
546-
ExceptionAssert.same
547-
id
548-
(fun () -> Array.Parallel.averageBy float Array.empty<int> |> ignore)
549+
ExceptionAssert.Same (
550+
id,
551+
(fun () -> Array.Parallel.averageBy float Array.empty<int> |> ignore),
549552
(fun () ->
550553
FlatList.Parallel.averageBy float FlatList.empty<int>
551554
|> ignore
552-
)
555+
),
553556
"FlatList.Parallel.averageBy of an empty flat list must throw as Array.Parallel.averageBy does"
557+
)
554558

555559
[<TestMethod; DynamicData(nameof FlatListParallelTests.AllInputs)>]
556560
member _.``iter visits every element once`` (input : ParallelInput) =
@@ -589,11 +593,12 @@ type FlatListParallelTests () =
589593

590594
[<TestMethod>]
591595
member _.``max throws for an empty flat list as Array.Parallel does`` () =
592-
ExceptionAssert.same
593-
id
594-
(fun () -> Array.Parallel.max Array.empty<int> |> ignore)
595-
(fun () -> FlatList.Parallel.max FlatList.empty<int> |> ignore)
596+
ExceptionAssert.Same (
597+
id,
598+
(fun () -> Array.Parallel.max Array.empty<int> |> ignore),
599+
(fun () -> FlatList.Parallel.max FlatList.empty<int> |> ignore),
596600
"FlatList.Parallel.max of an empty flat list must throw as Array.Parallel.max does"
601+
)
597602

598603
[<TestMethod; DynamicData(nameof FlatListParallelTests.NonEmptyInputs)>]
599604
member _.``maxBy returns the element with the greatest projection`` (input : ParallelInput) =
@@ -618,11 +623,12 @@ type FlatListParallelTests () =
618623

619624
[<TestMethod>]
620625
member _.``maxBy throws for an empty flat list as Array.Parallel does`` () =
621-
ExceptionAssert.same
622-
id
623-
(fun () -> Array.Parallel.maxBy abs Array.empty<int> |> ignore)
624-
(fun () -> FlatList.Parallel.maxBy abs FlatList.empty<int> |> ignore)
626+
ExceptionAssert.Same (
627+
id,
628+
(fun () -> Array.Parallel.maxBy abs Array.empty<int> |> ignore),
629+
(fun () -> FlatList.Parallel.maxBy abs FlatList.empty<int> |> ignore),
625630
"FlatList.Parallel.maxBy of an empty flat list must throw as Array.Parallel.maxBy does"
631+
)
626632

627633
[<TestMethod; DynamicData(nameof FlatListParallelTests.NonEmptyInputs)>]
628634
member _.``min returns the smallest element`` (input : ParallelInput) =
@@ -635,11 +641,12 @@ type FlatListParallelTests () =
635641

636642
[<TestMethod>]
637643
member _.``min throws for an empty flat list as Array.Parallel does`` () =
638-
ExceptionAssert.same
639-
id
640-
(fun () -> Array.Parallel.min Array.empty<int> |> ignore)
641-
(fun () -> FlatList.Parallel.min FlatList.empty<int> |> ignore)
644+
ExceptionAssert.Same (
645+
id,
646+
(fun () -> Array.Parallel.min Array.empty<int> |> ignore),
647+
(fun () -> FlatList.Parallel.min FlatList.empty<int> |> ignore),
642648
"FlatList.Parallel.min of an empty flat list must throw as Array.Parallel.min does"
649+
)
643650

644651
[<TestMethod; DynamicData(nameof FlatListParallelTests.NonEmptyInputs)>]
645652
member _.``minBy returns the element with the smallest projection`` (input : ParallelInput) =
@@ -664,11 +671,12 @@ type FlatListParallelTests () =
664671

665672
[<TestMethod>]
666673
member _.``minBy throws for an empty flat list as Array.Parallel does`` () =
667-
ExceptionAssert.same
668-
id
669-
(fun () -> Array.Parallel.minBy abs Array.empty<int> |> ignore)
670-
(fun () -> FlatList.Parallel.minBy abs FlatList.empty<int> |> ignore)
674+
ExceptionAssert.Same (
675+
id,
676+
(fun () -> Array.Parallel.minBy abs Array.empty<int> |> ignore),
677+
(fun () -> FlatList.Parallel.minBy abs FlatList.empty<int> |> ignore),
671678
"FlatList.Parallel.minBy of an empty flat list must throw as Array.Parallel.minBy does"
679+
)
672680

673681
[<TestMethod; DynamicData(nameof FlatListParallelTests.NonEmptyInputs)>]
674682
member _.``reduce combines the elements as the sequential reduce does for an associative and commutative function``
@@ -684,11 +692,12 @@ type FlatListParallelTests () =
684692

685693
[<TestMethod>]
686694
member _.``reduce throws for an empty flat list as Array.Parallel does`` () =
687-
ExceptionAssert.same
688-
id
689-
(fun () -> Array.Parallel.reduce (+) Array.empty<int> |> ignore)
690-
(fun () -> FlatList.Parallel.reduce (+) FlatList.empty<int> |> ignore)
695+
ExceptionAssert.Same (
696+
id,
697+
(fun () -> Array.Parallel.reduce (+) Array.empty<int> |> ignore),
698+
(fun () -> FlatList.Parallel.reduce (+) FlatList.empty<int> |> ignore),
691699
"FlatList.Parallel.reduce of an empty flat list must throw as Array.Parallel.reduce does"
700+
)
692701

693702
[<TestMethod; DynamicData(nameof FlatListParallelTests.NonEmptyInputs)>]
694703
member _.``reduceBy combines the projections as Array.Parallel does`` (input : ParallelInput) =
@@ -710,14 +719,15 @@ type FlatListParallelTests () =
710719

711720
[<TestMethod>]
712721
member _.``reduceBy throws for an empty flat list as Array.Parallel does`` () =
713-
ExceptionAssert.same
714-
id
715-
(fun () -> Array.Parallel.reduceBy abs (+) Array.empty<int> |> ignore)
722+
ExceptionAssert.Same (
723+
id,
724+
(fun () -> Array.Parallel.reduceBy abs (+) Array.empty<int> |> ignore),
716725
(fun () ->
717726
FlatList.Parallel.reduceBy abs (+) FlatList.empty<int>
718727
|> ignore
719-
)
728+
),
720729
"FlatList.Parallel.reduceBy of an empty flat list must throw as Array.Parallel.reduceBy does"
730+
)
721731

722732
[<TestMethod; DynamicData(nameof FlatListParallelTests.AllInputs)>]
723733
member _.``sum adds the elements`` (input : ParallelInput) =
@@ -900,7 +910,7 @@ type FlatListParallelTests () =
900910
[<TestMethod; DynamicData(nameof FlatListParallelTests.ArrayRejections)>]
901911
member _.``functions reject a default flat list as Array.Parallel rejects a null array`` (name : string) =
902912
let struct (oracle, actual) = arrayRejections[name]
903-
ExceptionAssert.same id oracle actual $"FlatList.Parallel.%s{name} must reject a default flat list"
913+
ExceptionAssert.Same (id, oracle, actual, $"FlatList.Parallel.%s{name} must reject a default flat list")
904914

905915
[<TestMethod; DynamicData(nameof FlatListParallelTests.Dereferences)>]
906916
member _.``sum and sumBy reject a default flat list where Array.Parallel dereferences a null array`` (name : string) =

‎tests/FSharp.Collections.Immutable.Tests/FlatList/FlatListParallelTupleTests.fs‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ type FlatListParallelTupleTests () =
4848

4949
[<TestMethod>]
5050
member _.``zip throws for different lengths as the default does`` () =
51-
ExceptionAssert.same
52-
id
51+
ExceptionAssert.Same (
52+
id,
5353
(fun () ->
5454
FSharp.Collections.Immutable.FlatList.Parallel.zip array (FlatList.singleton 1)
5555
|> ignore
56-
)
57-
(fun () -> FlatList.Parallel.zip array (FlatList.singleton 1) |> ignore)
56+
),
57+
(fun () -> FlatList.Parallel.zip array (FlatList.singleton 1) |> ignore),
5858
"Tuple.FlatList.Parallel.zip must throw as the default zip does"
59+
)
5960

6061
[<TestMethod; DynamicData(nameof FlatListParallelTupleTests.Sources)>]
6162
member _.``groupBy returns reference tuples`` (input : ParallelInput) =

0 commit comments

Comments
 (0)