fix(v4.0.0): wire review round 1 -- tests for the wake-up order and for waking only on enough room; no overflow moving a message; sleep for impossible room answers at once

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rajames
2026-10-08 14:12:33 -04:00
co-authored by Claude Opus 5.5
parent d5cd64605d
commit 83694b18be
6 changed files with 68 additions and 6 deletions
+20
View File
@@ -235,6 +235,26 @@ int main(void)
for (n = 0; n < 9 && t[n] == wt[n]; n++) { }
CHECK(n == 9, "and every word of its text");
}
/* the fourth word is one fewer for every value, the most negative cell included (no overflow) */
{
const v4_cell least = (v4_cell)((v4_ucell)1 << (V4_CELL_BITS - 1));
const v4_cell most = (v4_cell)(((v4_ucell)1 << (V4_CELL_BITS - 1)) - 1u);
static const int which[3] = { 0, 1, 2 };
unsigned m;
for (m = 0; m < 3; m++) {
v4_wire_reset(&q); v4_wire_reset(&other);
make(h, t, 8, 5);
h[3] = which[m] == 0 ? least : which[m] == 1 ? 0 : most;
CHECK(v4_wire_put(&q, h, t) == V4_WIRE_DONE, "(a message whose fourth word is an extreme)");
v4_wire_first(&q);
CHECK(v4_wire_move(&q, &other) == V4_WIRE_DONE, "moved");
v4_wire_first(&other);
CHECK(v4_wire_take(&other, h2, t2, V4_WIRE_CELLS) == V4_WIRE_DONE, "and taken");
CHECK(h2[3] == (which[m] == 0 ? most : which[m] == 1 ? (v4_cell)-1 : (v4_cell)(most - 1)),
"its fourth word is one fewer, wrapping at the least cell: %ld", (long)h2[3]);
}
}
/* no room in the other: 1, and neither changes */
v4_wire_reset(&q); v4_wire_reset(&other);
ok = 1;