// 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); };