test: migrate defdim len/cap family to test/lang @test, retire C twins (fold-2)
Continue fold-2: migrate drew's Family 2 (def-dimensioned array len/cap/slice resolution) 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); coverage is preserved, the $(TESTS) headline drops 3 (425->422). All asserts are primitive int comparisons (no fmt/strconv in the assert path); the defcap rows poison cap != len and assert both words so a dropped cap word FAILS. 989_defdim_field_run.c -> defdim_field_test.ww (`.len` field-read on a def-dim [MAX]T resolves from the type table: local/let-global/def cgdot arms + sum) 989_defdim_slice_run.c -> defdim_slice_test.ww (slicing a def-dim [MAX]T resolves len AND cap from the type table: default-hi + cgbasecap, local+global) 989_defdim_argslice_run.c -> defdim_argslice_test.ww (def-dim slice passed as a call arg resolves default-hi len in the N_SLICE arg-push arms; litctrl pins the N_INTLIT path) Bump LANGBYTEID_EXPECTED_MIN 31->34 to ratchet the new corpus floor.
This commit is contained in:
37
test/lang/defdim_field_test.ww
Normal file
37
test/lang/defdim_field_test.ww
Normal file
@@ -0,0 +1,37 @@
|
||||
// defdim_field_test — `.len` field-read on an array whose dimension is a
|
||||
// `def` constant (`[MAX]T`) must resolve the length from the type table, the
|
||||
// cgdot sibling of the #21 cgslice fix, migrated from
|
||||
// test/wcc/989_defdim_field_run.c (#56). A `def MAX` dim arrives as a
|
||||
// non-literal node; wwstage's cgdot `.len` arms (local / let-global / def) +
|
||||
// letemitsize only handled an N_INTLIT dim, so `.len` folded to MOVQ $0 (ww
|
||||
// returned 0 where cstage reads the resolved bu->alen). The fix reads alen from
|
||||
// the stamped array tinfo (rule-13) in each arm. cstage was always correct; T2
|
||||
// (test-lang-byteid) keeps the cs==ww net the .c twin's run-compare provided.
|
||||
|
||||
package defdim_field_test;
|
||||
|
||||
def MAX: i32 = 5;
|
||||
let g: [MAX]u8 = [1, 2, 3, 4, 5];
|
||||
def A: [MAX]u8 = [1, 2, 3, 4, 5];
|
||||
|
||||
@test fn local_len() void = {
|
||||
// local [MAX]u8 — the cgdot local arm; pre-fix ww folded to 0.
|
||||
let buf: [MAX]u8 = [1, 2, 3, 4, 5];
|
||||
assert(buf.len: i32 == 5);
|
||||
};
|
||||
|
||||
@test fn global_len() void = {
|
||||
// let-global [MAX]u8 — the cgdot let-global arm.
|
||||
assert(g.len: i32 == 5);
|
||||
};
|
||||
|
||||
@test fn defarr_len() void = {
|
||||
// def [MAX]u8 constant — the cgdot def arm.
|
||||
assert(A.len: i32 == 5);
|
||||
};
|
||||
|
||||
@test fn sum_len() void = {
|
||||
// all three arms in one fn (the .c `sum` row): 5 + 5 + 5 = 15.
|
||||
let buf: [MAX]u8 = [1, 2, 3, 4, 5];
|
||||
assert((buf.len + g.len + A.len): i32 == 15);
|
||||
};
|
||||
Reference in New Issue
Block a user