Skip to content

Commit 2b76540

Browse files
xperiandriclaude
andcommitted
fixup! test: FrozenSet against the set contracts
The review of #31 asked to unwrap options and value options with `Assert.WantSome` and `Assert.WantValueSome` in all such cases in all tests. The tests of `tryGetValue` and `tryAlternateLookup`, and the `Option` test of `tryAlternateLookup`, matched on `ValueNone` or `None` to fail; they unwrap the value with the assertions now. The test of the alternate lookup that reads a lookup with `TryGetValue` keeps its match: the member returns a `bool` and an out value, not an option. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 47288dc commit 2b76540

2 files changed

Lines changed: 22 additions & 12 deletions

File tree

‎tests/FSharp.Collections.Immutable.Tests/FrozenSet/FrozenSetOptionTests.fs‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,13 @@ type FrozenSetOptionTests () =
6767
let found : FrozenSet<int64>.AlternateLookup<int> option =
6868
FrozenSet.tryAlternateLookup<int, _>(FrozenSetOps.ofInt64WithInt32Comparer [| 1L; 2L; 3L |])
6969

70-
match found with
71-
| Some lookup ->
72-
Assert.IsTrue (lookup.Contains 2, "Option.FrozenSet.tryAlternateLookup must return a lookup that finds 2")
73-
| None -> Assert.Fail "Option.FrozenSet.tryAlternateLookup must return the lookup of a comparer with the alternate type"
70+
let lookup =
71+
Assert.WantSome (
72+
found,
73+
"Option.FrozenSet.tryAlternateLookup must return the lookup of a comparer with the alternate type"
74+
)
75+
76+
Assert.IsTrue (lookup.Contains 2, "Option.FrozenSet.tryAlternateLookup must return a lookup that finds 2")
7477

7578
let missing : FrozenSet<int64>.AlternateLookup<int> option =
7679
FrozenSet.tryAlternateLookup<int, _>(FrozenSet.ofArray [| 1L |])

‎tests/FSharp.Collections.Immutable.Tests/FrozenSet/FrozenSetTests.fs‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -874,9 +874,13 @@ type FrozenSetTests () =
874874
let stored = String ('x', 3)
875875
let set = caseless.ofArray [| stored; "apple" |]
876876

877-
match FrozenSet.tryGetValue "XXX" set with
878-
| ValueSome found -> Assert.AreSame (stored, found, "FrozenSet.tryGetValue must return the instance of the frozen set")
879-
| ValueNone -> Assert.Fail "FrozenSet.tryGetValue must find the element that equals the value in the comparer"
877+
let found =
878+
Assert.WantValueSome (
879+
FrozenSet.tryGetValue "XXX" set,
880+
"FrozenSet.tryGetValue must find the element that equals the value in the comparer"
881+
)
882+
883+
Assert.AreSame (stored, found, "FrozenSet.tryGetValue must return the instance of the frozen set")
880884

881885
Assert.AreEqual<string voption>(
882886
ValueSome "apple",
@@ -1046,11 +1050,14 @@ type FrozenSetAlternateLookupTests () =
10461050
member _.``tryAlternateLookup returns the lookup of a comparer with the alternate type`` (count : int) =
10471051
let set = numbers count
10481052

1049-
match FrozenSet.tryAlternateLookup<int, _> set with
1050-
| ValueSome lookup ->
1051-
Assert.AreSame (set, lookup.Set, "FrozenSet.tryAlternateLookup must look up in the frozen set")
1052-
Assert.IsTrue (lookup.Contains 2, "FrozenSet.tryAlternateLookup must return a lookup that finds 2")
1053-
| ValueNone -> Assert.Fail "FrozenSet.tryAlternateLookup must return the lookup of a comparer with the alternate type"
1053+
let lookup =
1054+
Assert.WantValueSome (
1055+
FrozenSet.tryAlternateLookup<int, _> set,
1056+
"FrozenSet.tryAlternateLookup must return the lookup of a comparer with the alternate type"
1057+
)
1058+
1059+
Assert.AreSame (set, lookup.Set, "FrozenSet.tryAlternateLookup must look up in the frozen set")
1060+
Assert.IsTrue (lookup.Contains 2, "FrozenSet.tryAlternateLookup must return a lookup that finds 2")
10541061

10551062
[<TestMethod; DynamicData(nameof FrozenSetAlternateLookupTests.WithoutAlternate)>]
10561063
member _.``tryAlternateLookup returns nothing for a comparer without the alternate type`` (comparer : string) =

0 commit comments

Comments
 (0)