Skip to content

Commit e854d3d

Browse files
committed
Update heap integrity tests to reflect the fact the root is the top node now.
1 parent 3b5446b commit e854d3d

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

sdlib/d/gc/heap.d

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -524,27 +524,27 @@ unittest heap {
524524
}
525525

526526
void checkIntegrity() {
527-
void check(Link n, Link prev, Link parent) {
527+
auto root = heap.root;
528+
assert(heap.top is root.node);
529+
530+
static void check(Link root, Link n, Link prev, Link parent) {
528531
if (n.isNull()) {
529532
return;
530533
}
531534

532-
assert(n.node is heap.top || stuffCmp(heap.top, n.node) < 0);
533-
assert(parent.isNull() || stuffCmp(parent.node, n.node) < 0);
535+
auto top = root.node;
536+
assert(n.node is top || stuffCmp(top, n.node) < 0);
537+
assert(n.node is top || stuffCmp(parent.node, n.node) < 0);
534538

535539
// /!\ The root's prev is not maintained.
536540
assert(prev.isNull() || n.prev.node is prev.node);
537-
check(n.next, n, parent);
538-
check(n.child, n, n);
541+
check(root, n.next, n, parent);
542+
check(root, n.child, n, n);
539543
}
540544

541-
auto root = heap.root;
542-
check(root, Link(null), Link(null));
543-
544-
// Check that all elements in the aux list are smaller than the root.
545-
if (!root.isNull()) {
546-
check(root.next, root, root);
547-
}
545+
// /!\ Passing root as parent to check the aux list is
546+
// made of elements smaller than the root.
547+
check(root, root, Link(null), root);
548548
}
549549

550550
void checkHeap() {

0 commit comments

Comments
 (0)