842f125c removed the trait conditions around the Iterable APIs, but
UniqueDeque only got its conformance through Container in ContainersPreview.
RigidDeque had no underestimatedCount, so it was 0 through Iterable.
remove(at:) recursed into the child holding the offset and returned
without balancing it, so repeated removals could empty a leaf. Iterating
then read a stale slot, which returned already-removed elements and read
released references in release builds, and trapped in debug builds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
converting a negative bit array to `Int128` lost the sign above the first
64 bits , so `Int128(truncatingIfNeeded: "1" as BitArray)` gave
18446744073709551615 , not -1 , `Int128(exactly:)` gave nil , and
`Int128(_:)` trapped . a negative value now starts out as all ones , so the
words shifted in keep the sign .
the trap message also named `BitArray` as the type it could not convert
to , it names the integer type now .
Run the mutable container checker, which also runs the bidirectional
one, against UniqueDeque over every storage layout.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run the mutable container checker, which also runs the bidirectional
one, against RigidDeque over every storage layout. With #793's
spanBoundary fix reverted, it fails with a negated distance.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run the mutable container checker, which also runs the bidirectional
one, against RigidArray. With #793's nextMutableSpan fix reverted, it
fails with the index not advancing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run the bidirectional container checker against BidirectionalContainer's
default implementations. With #793's formIndex(_:offsetBy:limitedBy:)
fix reverted, it fails.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Check that nextMutableSpan and previousMutableSpan, with and without
maxCount and a limit, return the expected span from every index, move
the index past it, and write through to exactly those elements.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Check a BidirectionalContainer's backward navigation against its forward
navigation: index(before:), spanBoundary(before:) and previousSpan(before:)
with and without maxDistance or maxCount and a limit, negative offsets and
distances, and formIndex(_:offsetBy:limitedBy:) in both directions.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Check OrderedSet.UnorderedView with checkHashable
The equivalence classes hold permutations of the same members, sets
that differ by one member or by count, and sets on both sides of the
hash table threshold, including small sets that carry a hash table or
reserved capacity.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Check OrderedSet.SubSequence with checkHashable
The equivalence classes hold equal slices taken from different base
sets, at different offsets, and from bases with and without a hash
table, alongside slices that differ in order, members or count.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Check OrderedDictionary.Values with checkHashable
The equivalence classes hold dictionaries with different keys but the
same value sequence, alongside values that differ in order, contents
or count, including repeated values.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
_resizingShiftRight(by:) copied the surviving suffix down to index 0 and
then removed `count &- amount` trailing bits instead of `amount`, so it
truncated the result to `amount` stale bits rather than keeping
`count - amount` valid ones. resizingShiftLeft(by: -n) was affected via
the same path, and the API had no test coverage at all.
Also fix the doc examples, which demonstrated the resizing shifts with
the masking shift function names (and, in one case, a result whose bit
count contradicted the documented growth by `amount`).
Add regression tests asserting parity with the documented semantics
(dropFirst / prepending false values) across word-boundary counts,
negative amounts, boundary `amount` values, and the doc examples
verbatim.
insert(addingCount:initializingWith:) batches elements through a
temporary OutputSpan and loops while `remainder > 0`. When the
`UnstableContainersPreview` trait is disabled, the span's `defer`
handler moved elements out of the temporary buffer but never decremented
`remainder`, so the loop spun forever whenever the initializer didn't
fill every batch. Update `remainder` the same way the preview branch
already does, and add a regression test (issue #774).
The closure-based replaceSubrange overloads on RigidArray (and, through
them, UniqueArray and the generic RangeReplaceableContainer overloads)
returned subrange.lowerBound ..< subrange.lowerBound + newItemCount even
when the initializer performed a short fill, so the returned range could
cover old elements that were never replaced and extend past endIndex.
Return the number of items actually initialized (span.count), matching
insert(addingCount:at:initializingWith:).
Fixes#772
prepend(from:) looped calling uncheckedPrepend, which each time placed the
new batch at index 0 of the deque. Later batches ended up in front of earlier
ones, producing items in the wrong order.
Fix: use uncheckedInsert(addingCount:at:added) so each new batch is inserted
immediately after the items already prepended in earlier passes. Promote the
overload from internal to package so ContainersPreview can reach it.
Adds a regression test covering single- and multi-batch producers prepending
into empty and non-empty deques. Fixes#763.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Run the member identity checker against SortedSet, including a
multi-level tree. With #761's fix reverted, it fails with the wrong
member stored by insert(_:) and update(with:), as reported in #760.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run the member identity checker against OrderedSet's unordered view,
covering both the unhashed and hashed storage paths.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Check which of two equal but distinguishable members insert(_:),
update(with:) and remove(_:) keep and return, using Set as the
reference.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_rawHashValue(seed:) looped on nextSpan() without checking for the
empty span the iterator returns once it is exhausted, so hashing any
RigidSet or UniqueSet spun forever. Break on an empty span, as == does.
Add test_hashable for both types, modeled on RigidArrayTests: equal
sets built with different capacities and insertion orders must hash
equally. Both tests hang without the fix.
Fixes#765.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BitSet.Counted keeps its own count and forwards its index operations to
BitSet, but no test ran it through a collection checker. Run
checkBidirectionalCollection on it with the same inputs as BitSet's
test_collection_strides.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Doubling the other model's elements only exposes an implementation that
counts occurrences instead of distinct members when the two sets share
at least half of the receiver's elements, which depended on the models
a test happened to pick. A BitSet.isStrictSubset that counted
duplicates passed every model pair. Repeat the other model
`xm.count + 2` times instead, so a shared element always appears more
often than the receiver has members.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every sequence the checker passed reported its exact count, so an
implementation that trusts underestimatedCount went unnoticed: an empty
TreeSet whose isEqualSet returned `other.underestimatedCount == 0`
passed every test. Also check the predicates and isEqualSet against a
single-pass MinimalSequence, whose underestimatedCount is 0.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>