mirror of
https://github.com/apple/swift-collections
synced 2026-11-22 04:20:40 +00:00
[Heap] Make _checkInvariants() public in internal checks builds
`Heap._checkInvariants()` was `internal` when COLLECTIONS_INTERNAL_CHECKS is defined but `public` otherwise, so code outside `HeapModule` compiled normally and then failed in an internal checks build. Make both declarations `public`, matching `OrderedSet`, `OrderedDictionary`, `BitSet` and `BitArray`, and add a test that calls it through a plain `import HeapModule`. Fixes #813
This commit is contained in:
1 parent
1233c97689
commit
c9286ec384
2 files changed
+8
-1
No files matched your search
@@ -31,7 +31,7 @@ extension Heap {
|
||||
/// contents satisfy the min-max heap property.
|
||||
@inlinable
|
||||
@inline(never)
|
||||
internal func _checkInvariants() {
|
||||
public func _checkInvariants() {
|
||||
guard count > 1 else { return }
|
||||
_checkInvariants(node: .root, min: nil, max: nil)
|
||||
}
|
||||
|
||||
@@ -43,6 +43,13 @@ extension Heap {
|
||||
}
|
||||
|
||||
final class HeapTests: CollectionTestCase {
|
||||
func test_checkInvariants() {
|
||||
// This test uses a plain `import HeapModule`, so it only compiles with
|
||||
// COLLECTIONS_INTERNAL_CHECKS if `_checkInvariants()` is public there too.
|
||||
let heap = Heap([3, 1, 4, 1, 5, 9, 2, 6])
|
||||
heap._checkInvariants()
|
||||
}
|
||||
|
||||
func test_isEmpty() {
|
||||
var heap = Heap<Int>()
|
||||
expectTrue(heap.isEmpty)
|
||||
|
||||
Reference in new issue
Block a user