You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6aa1c13
Browse filesBrowse the repository at this point in the historyBrowse files
fixup! test: shared contracts of the set modules, run for HashSet and ISet
Pin the recipe that the changelog gives for passing a sequence to a relation or to an
operation of the set algebra, which take sets, not sequences, in `HashSet` and `ISet`. The
strings, the comparers and the sets and sequences of each case are in `SetRelationInputs`,
which the two test classes share:
- 24 rows each: the six relations and `intersect` and `symmetricDifference`, with the
default comparer, a comparer that ignores case and a reference comparer
(`HashIdentity.Reference`) as the comparer of the first set. The strings are two instances
of "a", "A" and "b". The conversion with the comparer of the first set,
`(HashSet.forComparer (HashSet.comparer set)).ofSeq` for `HashSet` and
`ISet.addRange elements (ISet.clear set)` for `ISet`, answers as the member of the BCL type
(of the interface for `ISet`) in every row. The conversion with the default comparer,
`HashSet.ofSeq`, answers as the member for the first two comparers, which find equal what
the default comparer finds equal, and differently for the reference comparer, which tells
the two instances of "a" apart where the default comparer keeps one of them.
- 6 rows each: `overlaps` and `isSuperset` as `Seq.exists` and `Seq.forall` with `contains`
answer as the members with all three comparers.
Each pinned behavior was broken once in the code, 11 mutations (`ofSeq` of the struct
converting with the default comparer, `isSubset` of each module comparing in the comparer of
the second set, `contains` of each module comparing in the default comparer, `intersect` and
`symmetricDifference` of each module converting the second set with the default comparer,
`ISet.clear` without the comparer, and the reference comparer of the test data comparing by
the default comparer), and a new test failed each time.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
moduleFunction set ((HashSet.forComparer (HashSet.comparer set)).ofSeq elements),
623
+
$"HashSet.%s{relation} must answer as the member of the BCL type for the sequence that the comparer of the first set converts"
624
+
)
625
+
626
+
letwithDefaultComparer= moduleFunction set (HashSet.ofSeq elements)
627
+
628
+
if defaultFindsEqualWhatItFindsEqual then
629
+
Assert.AreEqual<bool>(
630
+
expected,
631
+
withDefaultComparer,
632
+
$"HashSet.%s{relation} must answer as the member of the BCL type for the sequence that the default comparer converts, because the comparer of the first set finds equal what the default comparer finds equal"
633
+
)
634
+
else
635
+
Assert.AreNotEqual<bool>(
636
+
expected,
637
+
withDefaultComparer,
638
+
$"HashSet.%s{relation} must answer differently for the sequence that the default comparer converts, because the comparer of the first set tells apart strings that the default comparer finds equal"
639
+
)
640
+
641
+
// The same recipe for the operations of the set algebra that take a sequence in the BCL type
letexpected= HashSet.toArray (bclMember set elements)
652
+
653
+
CollectionAssert.AreEquivalent (
654
+
expected,
655
+
HashSet.toArray (moduleFunction set ((HashSet.forComparer (HashSet.comparer set)).ofSeq elements)),
656
+
$"HashSet.%s{operation} must return the result of the member of the BCL type for the sequence that the comparer of the first set converts"
657
+
)
658
+
659
+
letwithDefaultComparer= HashSet.toArray (moduleFunction set (HashSet.ofSeq elements))
660
+
661
+
if defaultFindsEqualWhatItFindsEqual then
662
+
CollectionAssert.AreEquivalent (
663
+
expected,
664
+
withDefaultComparer,
665
+
$"HashSet.%s{operation} must return the result of the member of the BCL type for the sequence that the default comparer converts, because the comparer of the first set finds equal what the default comparer finds equal"
666
+
)
667
+
else
668
+
CollectionAssert.AreNotEquivalent (
669
+
expected,
670
+
withDefaultComparer,
671
+
$"HashSet.%s{operation} must return another result for the sequence that the default comparer converts, because the comparer of the first set tells apart strings that the default comparer finds equal"
0 commit comments