mirror of
https://github.com/apple/swift-collections
synced 2026-11-26 04:47:48 +00:00
formUnion against union, formIntersection against intersection, subtract against subtracting, and formSymmetricDifference against symmetricDifference, in both the Self-taking and Sequence-taking overloads. Each runs under withHiddenCopies at both sharing states, because a mutating operation on a shared value is where copy-on-write bugs live, and the original is checked afterwards to confirm it was not mutated through the copy. This is the highest-value law in the checker. The two implementations should agree by construction, so a divergence is a real bug rather than a debatable one — and nothing else here would catch a form* method that is simply wrong: a formUnion that intersects passes every law in the preceding commit. Verified by injecting three defects into a stand-in conformance: a formUnion that intersects, an isStrictSubset that drops strictness, and a subtracting that returns a stale count. All three are caught, and an unmodified control passes. The stale-count case is caught only because contents and count are asserted separately. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Unit tests
Beware! The contents of this directory are not source stable. They are provided as is, with no compatibility promises across package releases. Future versions of this package can arbitrarily change these files or remove them, without any advance notice. (This can include patch releases.)