Files
ww/test/lang/arrlit_infer_elem_test.ww
Hojun-Cho 132ea4ee60 test: migrate Fam13 misc checker/coercion value tests to @test (#5-C6)
Final fold-2 chunk. The 12 Fam13 single-file value drivers move from
test/wcc/*_run.c into in-language @test row-tables under test/lang/:

- value rows -> test/lang/*_test.ww (12 files)
- reject rows -> runww //ww:error carriers (13, dual-stage non-vacuous)
- nullable abort rows -> runww //ww:run-exit 1 carriers (3)
- 953_globalslice_arg -> _runonly (cs!=ww checker divergence, #28)
- 788 value_not_type_neg + 953_arrlit_slice reject_assign kept as slim
  rc-only .c pins (divergent-diag dual-reject, mutation-gated); 788 #29

Coverage parity verified row-by-row vs each retired driver; advisor-
ratified carve taxonomy; two-round reviewed. Floor ratchet follows.
2026-06-24 22:59:32 +09:00

86 lines
1.9 KiB
Plaintext

// arrlit_infer_elem_test — #103/#108/#104: an INFERRED let defaults its
// untyped-int element to `int` (8B machine word), not i32. Migrated from
// test/wcc/813_arrlit_infer_elem_run.c (value rows; cs==ww byte-id rides T2).
//
// Pre-fix cstage truncated the untyped-int default to i32 (4B): a value > 2^31
// (5000000000 → 705032704) and arrays strided at 4; wwstage SEGV'd on the
// inferred array (under-sized frame). The wide rows use 5000000000 ( > 2^31) as
// the truncation teeth — a small value would pass both stages by luck. The
// ctrl_* rows use ANNOTATED element types ([4]i32 / [4]int): the fix must leave
// those untouched, so they pin the inferred-default branch is isolated.
package arrlit_infer_elem_test;
type myb = bool;
type arr = [4]int;
type arr2 = arr;
type sl = []int;
type sl2 = sl;
@test fn arr_wide() void = {
let a = [5000000000, 2, 3, 4];
assert(a[0] == 5000000000);
assert(a[3] == 4);
};
@test fn scalar_wide() void = {
let x = 5000000000;
assert(x == 5000000000);
};
@test fn arr_small() void = {
let a = [10, 20, 30, 40];
assert(a[2] == 30);
};
@test fn m2_while() void = {
let b: myb = true;
let i = 0;
for (b) {
i = i + 1;
if (i >= 3) { b = false; };
};
assert(i == 3);
};
@test fn m8_range1() void = {
let a: arr = [1, 2, 3, 4];
let sum = 0;
for (let x .. a) { sum = sum + x; };
assert(sum == 10);
};
@test fn m8_range2() void = {
let a: arr2 = [1, 2, 3, 4];
let sum = 0;
for (let x .. a) { sum = sum + x; };
assert(sum == 10);
};
@test fn m8_slice1() void = {
let a = [10, 20, 30, 40];
let s: sl = a[1:3];
assert(s.len == 2);
assert(s[0] == 20);
assert(s[1] == 30);
};
@test fn m8_slice2() void = {
let a = [10, 20, 30, 40];
let s: sl2 = a[1:3];
assert(s.len == 2);
assert(s[0] == 20);
let t = s[0:1];
assert(t[0] == 20);
};
@test fn ctrl_i32() void = {
let a: [4]i32 = [1, 2, 3, 4];
assert(a[3] == 4);
};
@test fn ctrl_int() void = {
let a: [4]int = [1, 2, 3, 4];
assert(a[3] == 4);
};