Skip to content

Commit 4e35919

Browse files
xperiandriclaude
andcommitted
fixup! test: SortedMap against the map contracts and the order of Map
Calls the assertion helpers of `main`: `ExceptionAssert.Same`, `OverrideAssert.OptionMatches` and `OverrideAssert.PairMatches`, which replace the curried functions of the former modules in the tests of `minKeyValue`, `maxKeyValue` and the `Option` and `Tuple` namespaces. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent e710b38 commit 4e35919

3 files changed

Lines changed: 40 additions & 31 deletions

File tree

‎tests/FSharp.Collections.Immutable.Tests/SortedMap/SortedMapOptionTests.fs‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,21 @@ type SortedMapOptionTests () =
5555
member _.``tryFind returns an option`` (key : int) =
5656
let found : string option = SortedMap.tryFind key table
5757

58-
OverrideAssert.optionMatches
59-
(FSharp.Collections.Immutable.SortedMap.tryFind key table)
60-
found
58+
OverrideAssert.OptionMatches (
59+
FSharp.Collections.Immutable.SortedMap.tryFind key table,
60+
found,
6161
"Option.SortedMap.tryFind must match the default"
62+
)
6263

6364
[<TestMethod; DataRow 5; DataRow 1>]
6465
member _.``tryGetKey returns an option`` (key : int) =
6566
let found : int option = SortedMap.tryGetKey key table
6667

67-
OverrideAssert.optionMatches
68-
(FSharp.Collections.Immutable.SortedMap.tryGetKey key table)
69-
found
68+
OverrideAssert.OptionMatches (
69+
FSharp.Collections.Immutable.SortedMap.tryGetKey key table,
70+
found,
7071
"Option.SortedMap.tryGetKey must match the default"
72+
)
7173

7274
[<TestMethod>]
7375
member _.``pick takes a chooser of options as Map.pick does`` () =
@@ -89,10 +91,11 @@ type SortedMapOptionTests () =
8991
"Option.SortedMap.tryFindKey must find the first key in the order of the keys, as Map.tryFindKey does"
9092
)
9193

92-
OverrideAssert.optionMatches
93-
(FSharp.Collections.Immutable.SortedMap.tryFindKey predicate.Matches table)
94-
found
94+
OverrideAssert.OptionMatches (
95+
FSharp.Collections.Immutable.SortedMap.tryFindKey predicate.Matches table,
96+
found,
9597
"Option.SortedMap.tryFindKey must match the default"
98+
)
9699

97100
[<TestMethod>]
98101
member _.``tryPick takes a chooser of options and returns an option as Map.tryPick does`` () =

‎tests/FSharp.Collections.Immutable.Tests/SortedMap/SortedMapTests.fs‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -730,19 +730,21 @@ type SortedMapTests () =
730730

731731
[<TestMethod>]
732732
member _.``minKeyValue throws for an empty map as Map does`` () =
733-
ExceptionAssert.same
734-
id
735-
(fun () -> Map.minKeyValue Map.empty<int, string> |> ignore)
736-
(fun () -> SortedMap.minKeyValue SortedMap.empty<int, string> |> ignore)
733+
ExceptionAssert.Same (
734+
id,
735+
(fun () -> Map.minKeyValue Map.empty<int, string> |> ignore),
736+
(fun () -> SortedMap.minKeyValue SortedMap.empty<int, string> |> ignore),
737737
"SortedMap.minKeyValue must reject an empty map"
738+
)
738739

739740
[<TestMethod>]
740741
member _.``maxKeyValue throws for an empty map as Map does`` () =
741-
ExceptionAssert.same
742-
id
743-
(fun () -> Map.maxKeyValue Map.empty<int, string> |> ignore)
744-
(fun () -> SortedMap.maxKeyValue SortedMap.empty<int, string> |> ignore)
742+
ExceptionAssert.Same (
743+
id,
744+
(fun () -> Map.maxKeyValue Map.empty<int, string> |> ignore),
745+
(fun () -> SortedMap.maxKeyValue SortedMap.empty<int, string> |> ignore),
745746
"SortedMap.maxKeyValue must reject an empty map"
747+
)
746748

747749
[<TestMethod>]
748750
member _.``singleton binds the key to the value`` () =

‎tests/FSharp.Collections.Immutable.Tests/SortedMap/SortedMapTupleTests.fs‎

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,38 +49,42 @@ type SortedMapTupleTests () =
4949
let largest : int * string = SortedMap.maxKeyValue table
5050
Assert.AreEqual<int * string>(Map.maxKeyValue oracle, largest, "Tuple.SortedMap.maxKeyValue must match Map.maxKeyValue")
5151

52-
OverrideAssert.pairMatches
53-
(FSharp.Collections.Immutable.SortedMap.maxKeyValue table)
54-
largest
52+
OverrideAssert.PairMatches (
53+
FSharp.Collections.Immutable.SortedMap.maxKeyValue table,
54+
largest,
5555
"Tuple.SortedMap.maxKeyValue must match the default"
56+
)
5657

57-
ExceptionAssert.same
58-
id
59-
(fun () -> Map.maxKeyValue Map.empty<int, string> |> ignore)
58+
ExceptionAssert.Same (
59+
id,
60+
(fun () -> Map.maxKeyValue Map.empty<int, string> |> ignore),
6061
(fun () ->
6162
SortedMap.maxKeyValue FSharp.Collections.Immutable.SortedMap.empty<int, string>
6263
|> ignore
63-
)
64+
),
6465
"Tuple.SortedMap.maxKeyValue must reject an empty map as Map.maxKeyValue does"
66+
)
6567

6668
[<TestMethod>]
6769
member _.``minKeyValue returns a reference tuple as Map.minKeyValue does`` () =
6870
let smallest : int * string = SortedMap.minKeyValue table
6971
Assert.AreEqual<int * string>(Map.minKeyValue oracle, smallest, "Tuple.SortedMap.minKeyValue must match Map.minKeyValue")
7072

71-
OverrideAssert.pairMatches
72-
(FSharp.Collections.Immutable.SortedMap.minKeyValue table)
73-
smallest
73+
OverrideAssert.PairMatches (
74+
FSharp.Collections.Immutable.SortedMap.minKeyValue table,
75+
smallest,
7476
"Tuple.SortedMap.minKeyValue must match the default"
77+
)
7578

76-
ExceptionAssert.same
77-
id
78-
(fun () -> Map.minKeyValue Map.empty<int, string> |> ignore)
79+
ExceptionAssert.Same (
80+
id,
81+
(fun () -> Map.minKeyValue Map.empty<int, string> |> ignore),
7982
(fun () ->
8083
SortedMap.minKeyValue FSharp.Collections.Immutable.SortedMap.empty<int, string>
8184
|> ignore
82-
)
85+
),
8386
"Tuple.SortedMap.minKeyValue must reject an empty map as Map.minKeyValue does"
87+
)
8488

8589
[<TestMethod>]
8690
member _.``partition returns a reference tuple`` () =

0 commit comments

Comments
 (0)