Every section banner dies (103 -> 0) across test/lang, the observer suites, the C carriers, and the five comment-heavy corpus fixtures; banner provenance (#N cites, carrier numbers, repair-cluster labels) folded into headers or adjacent WHY comments. Narration deleted; row provenance, ref cites, divergence pins, and layout contracts kept (fwd-ref decl-order guards and bootstrap-gate corpus rationale restored where the sweep over-cut). Comment-only proven: all 3742 wwbuild workdir .s byte-identical before/after; test-commit and test-byteid (161 lang + 1399 data, 0 pinned-divergent) green.
61 lines
2.0 KiB
Plaintext
61 lines
2.0 KiB
Plaintext
// Wide tuple-return / sret RECEIVE side (#10 Fold B),
|
|
// migrated from test/wcc/799_tuple_sret_receive_run.c. A fn returning a tuple
|
|
// over the 4-GP cap (`([]u8, []u8)` = 6 GP eightbytes) sret's into the caller's
|
|
// dest; each receive form must lay the elements out at the SAME packed offset
|
|
// the SEND wrote. byte-id alone is blind to a receive that mis-offsets (both
|
|
// stages would be wrong the same way), so each @test RUNS the round-trip and
|
|
// asserts the bytes arrive intact; T2 (test-lang-byteid) keeps the cs==ww net.
|
|
//
|
|
// Data is read back by INDEXING the slice elements (t.0[i] / a[i]); len() is
|
|
// taken only on DESTRUCTURED bindings (plain slice locals), never `len(t.N)` —
|
|
// that is a SEPARATE N_DOT-tuple+len composition bug, deliberately not exercised.
|
|
|
|
package tuple_sret_receive_test;
|
|
|
|
fn mk(a: []u8, b: []u8) ([]u8, []u8) = { return (a, b); };
|
|
fn fwd(a: []u8, b: []u8) ([]u8, []u8) = { return mk(a, b); };
|
|
|
|
@test fn destructure() void = {
|
|
let buf: [8]u8 = [10u8, 11u8, 12u8, 13u8, 20u8, 21u8, 22u8, 23u8];
|
|
let x: []u8 = buf[0:4];
|
|
let y: []u8 = buf[4:8];
|
|
let (a, b) = mk(x, y);
|
|
assert(len(a) == 4);
|
|
assert(len(b) == 4);
|
|
assert(a[0] == 10u8);
|
|
assert(a[3] == 13u8);
|
|
assert(b[0] == 20u8);
|
|
assert(b[3] == 23u8);
|
|
};
|
|
|
|
@test fn single_var_let() void = {
|
|
let buf: [8]u8 = [10u8, 11u8, 12u8, 13u8, 20u8, 21u8, 22u8, 23u8];
|
|
let x: []u8 = buf[0:4];
|
|
let y: []u8 = buf[4:8];
|
|
let t = mk(x, y);
|
|
assert(t.0[0] == 10u8);
|
|
assert(t.0[3] == 13u8);
|
|
assert(t.1[0] == 20u8);
|
|
assert(t.1[3] == 23u8);
|
|
};
|
|
|
|
@test fn return_forward() void = {
|
|
let buf: [8]u8 = [10u8, 11u8, 12u8, 13u8, 20u8, 21u8, 22u8, 23u8];
|
|
let x: []u8 = buf[0:4];
|
|
let y: []u8 = buf[4:8];
|
|
let (a, b) = fwd(x, y);
|
|
assert(len(a) == 4);
|
|
assert(a[0] == 10u8);
|
|
assert(b[3] == 23u8);
|
|
};
|
|
|
|
@test fn reassign() void = {
|
|
let buf: [8]u8 = [10u8, 11u8, 12u8, 13u8, 20u8, 21u8, 22u8, 23u8];
|
|
let x: []u8 = buf[0:4];
|
|
let y: []u8 = buf[4:8];
|
|
let t = mk(x, y);
|
|
t = mk(y, x);
|
|
assert(t.0[0] == 20u8);
|
|
assert(t.1[0] == 10u8);
|
|
};
|