test: migrate struct/sret round-trip family-7 to test/lang @test, retire C twins (fold-2)

Continue fold-2: migrate the struct-by-value / sret round-trip family from
bespoke build+run C twins to test/lang @test, retiring each twin in the same
commit. Runtime coverage MOVES from $(TESTS) to test-lang (T1 runs+asserts via
`ww test`) + test-lang-byteid (T2 keeps cs==ww .s byte-id); the $(TESTS)
headline drops 6. Every assert is a primitive int/u8/bool comparison (no
fmt/strconv in the assert path); each returned struct/tuple FIELD is asserted
individually so a dropped/mis-offset/over-wide word FAILS. 46 @test cases, a
strict superset of the 46 C rows (799=4, 925=10, 930=6, 949odd=7, 949chained=9,
949aggret=10).

  799_tuple_sret_receive_run.c   -> tuple_sret_receive_test.ww    (#10 Fold B: over-4-GP tuple `([]u8,[]u8)` sret RECEIVE — destructure/single-var/return-forward/reassign; len() only on destructured bindings, never len(t.N))
  925_sret_struct_return_run.c   -> sret_struct_return_test.ww     (#23: >24B sret round-trip; 32B/40B/nested/slice-payload, reassign-receive, struct16-by-value-arg #11 collision, N_IDENT return rhs, forward #9 simple/multi-arg/slice)
  930_sret_narrow_field_run.c    -> sret_narrow_field_test.ww      (#33: sret narrow trailing-field copy — bool/u8/i16/i32 + mixed bool+i32+i64 after the 24B slice)
  949_oddstruct_byval_ret_run.c  -> oddstruct_byval_ret_test.ww    (#107: by-value return of odd sub-8 size {3,5,6,7} single-eightbyte + 8/12/24 boundaries)
  949_chained_dot_struct_copy_run.c -> chained_dot_struct_copy_test.ww (#107 sibling: chained-DOT `t.m.l = s` natural-size tail copy {0..7} + via-CX global dest; neighbour z is the oracle)
  949_aggret_source_run.c        -> aggret_source_test.ww          (#272: aggregate return from every addressable source — arrlit/N_DOT/N_INDEX/deref/ident + >24B sret arm + global-receive caller-half)

This family is sret / struct-by-value-return (the #107/#38/#271/#272 ABI area):
all 6 new files are byte-id cs==ww (no fold-5 divergence surfaced). Bump
LANGBYTEID_EXPECTED_MIN 43->49 to ratchet the new corpus floor.
This commit is contained in:
2026-06-22 13:52:41 +09:00
parent c9c5f6406f
commit d8e7470555
13 changed files with 611 additions and 1685 deletions

View File

@@ -0,0 +1,60 @@
// tuple_sret_receive_test — 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);
};