Skip to content

Commit 3225f5e

Browse files
xperiandriclaude
andcommitted
fixup! test: shared contracts of the sequence-like modules, run for FlatList
The tests follow the new parameter names: `array` for `sub` and the range sorts, `source` for the removals by value. `sub` is compared with `Array.sub` without a mapping of the parameter name now, so the `subParamName` helper goes away. The rows of `removeMany` and `removeManyWith` for a default flat list together with default items say "default source", as the rows of `insertManyAt` do. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 353a938 commit 3225f5e

1 file changed

Lines changed: 13 additions & 19 deletions

File tree

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

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ type FlatListTests () =
3535
| "source" -> "values"
3636
| other -> other
3737

38-
/// Maps the parameter names of Array.sub to the ones of FlatList.sub, which names the flat list list.
39-
static let subParamName (name : string) =
40-
match name with
41-
| "array" -> "list"
42-
| other -> other
43-
4438
/// The elements without the first one that the equality finds equal to the item: the oracle of the removal by value.
4539
static let removeFirst (equal : 'T -> 'T -> bool) (item : 'T) (elements : 'T array) =
4640
match Array.tryFindIndex (equal item) elements with
@@ -230,25 +224,25 @@ type FlatListTests () =
230224
|> ignore
231225
))
232226
struct (nameof FlatList.length, "array", (fun () -> FlatList.length defaultArray |> ignore))
233-
struct (nameof FlatList.remove, "list", (fun () -> FlatList.remove 1 defaultArray |> ignore))
234-
struct (nameof FlatList.removeMany, "list", (fun () -> FlatList.removeMany [| 1 |] defaultArray |> ignore))
227+
struct (nameof FlatList.remove, "source", (fun () -> FlatList.remove 1 defaultArray |> ignore))
228+
struct (nameof FlatList.removeMany, "source", (fun () -> FlatList.removeMany [| 1 |] defaultArray |> ignore))
235229
struct (nameof FlatList.removeManyWith,
236-
"list",
230+
"source",
237231
(fun () ->
238232
FlatList.removeManyWith EqualityComparer<int>.Default [| 1 |] defaultArray
239233
|> ignore
240234
))
241235
struct (nameof FlatList.removeWith,
242-
"list",
236+
"source",
243237
(fun () ->
244238
FlatList.removeWith EqualityComparer<int>.Default 1 defaultArray
245239
|> ignore
246240
))
247241
struct (nameof FlatList.skipLast, "array", (fun () -> FlatList.skipLast 0 defaultArray |> ignore))
248-
struct (nameof FlatList.sortRange, "list", (fun () -> FlatList.sortRange 0 0 defaultArray |> ignore))
249-
struct (nameof FlatList.sortRangeWith, "list", (fun () -> FlatList.sortRangeWith compare 0 0 defaultArray |> ignore))
242+
struct (nameof FlatList.sortRange, "array", (fun () -> FlatList.sortRange 0 0 defaultArray |> ignore))
243+
struct (nameof FlatList.sortRangeWith, "array", (fun () -> FlatList.sortRangeWith compare 0 0 defaultArray |> ignore))
250244
struct (nameof FlatList.sortRangeWithComparer,
251-
"list",
245+
"array",
252246
(fun () ->
253247
FlatList.sortRangeWithComparer Comparer<int>.Default 0 0 defaultArray
254248
|> ignore
@@ -322,8 +316,8 @@ type FlatListTests () =
322316
|> ignore
323317
))
324318
// ImmutableArray.RemoveRange checks the flat list before the items
325-
struct ($"%s{nameof FlatList.removeMany} (default list and items)",
326-
"list",
319+
struct ($"%s{nameof FlatList.removeMany} (default source and items)",
320+
"source",
327321
(fun () ->
328322
FlatList.removeMany (defaultArray :> seq<_>) defaultArray
329323
|> ignore
@@ -343,8 +337,8 @@ type FlatListTests () =
343337
(FlatList.ofArray Inputs.Several)
344338
|> ignore
345339
))
346-
struct ($"%s{nameof FlatList.removeManyWith} (default list and items)",
347-
"list",
340+
struct ($"%s{nameof FlatList.removeManyWith} (default source and items)",
341+
"source",
348342
(fun () ->
349343
FlatList.removeManyWith EqualityComparer<int>.Default (defaultArray :> seq<_>) defaultArray
350344
|> ignore
@@ -784,7 +778,7 @@ type FlatListTests () =
784778
[<TestMethod; DynamicData(nameof FlatListTests.SubRangesOutOfRange)>]
785779
member _.``sub throws for a range out of range as Array.sub does`` (input : int array, startIndex : int, count : int) =
786780
ExceptionAssert.Same (
787-
subParamName,
781+
id,
788782
(fun () -> Array.sub input startIndex count |> ignore),
789783
(fun () ->
790784
FlatList.sub (FlatList.ofArray input) startIndex count
@@ -798,7 +792,7 @@ type FlatListTests () =
798792
(startIndex : int, count : int)
799793
=
800794
ExceptionAssert.Same (
801-
subParamName,
795+
id,
802796
(fun () -> Array.sub nullArray startIndex count |> ignore),
803797
(fun () -> FlatList.sub defaultArray startIndex count |> ignore),
804798
"FlatList.sub must reject a default flat list as Array.sub rejects a null array"

0 commit comments

Comments
 (0)