Files
ww/test/lang/gunsigned_test.ww
Hojun-Cho ca9376acde test: migrate gunsigned/chainidx/idxarg behavior to test/lang @test
Batch 2 of the test-arch reframe. These three are codegen-SHAPE tests,
not data-row tests: each subject is a distinct node shape (N_IDENT
module-global read; chained N_INDEX m[i][k]; index-base node-kind). A
[N]struct row-table would interpose its own N_INDEX/N_DOT lowering and
mask the shape under test, so each uses per-shape @test fns with direct
asserts (rob-ratified rule: table where the row is data, per-fn where
the row is a codegen shape). Lossless from the matching
989_{gunsigned,chainidx,idxarg}_run.c; additive (C kept); both stages green.
2026-06-22 02:04:56 +09:00

41 lines
1.5 KiB
Plaintext

// gunsigned_test — a module-GLOBAL unsigned ident on the divide / shift /
// relational path must select the UNSIGNED opcode (DIVQ / SHRQ / JA), migrated
// from test/wcc/989_gunsigned_run.c (#25). nodeisunsigned read the LOCAL's
// declared tnode and fell to signed (false) for a module-global ident, so a
// u64 global fed to `/ % >> >= >` got the signed opcode and diverged from
// cstage on a high-bit-set value — the cat-A signature.
//
// The subject IS the module-global IDENT, so the rows MUST stay package-scope
// globals exercised directly: a struct-array row-table would route the values
// through N_INDEX/N_DOT and never hit the N_IDENT-global codegen path the bug
// lives on (so this file does not use the uniesc row-loop idiom — the shapes,
// not the data, are what vary).
package gunsigned_test;
let g: u64 = 0;
let s: i64 = 0;
@test fn global_unsigned_path() void = {
// global_ushr: (1<<63) >> 1 unsigned == 1<<62 (bug: signed SARQ).
g = 9223372036854775808u64;
let r0: u64 = g >> 1;
assert(r0 == 4611686018427387904u64);
// global_udiv: (1<<63) / (1<<62) unsigned == 2 (bug: signed IDIVQ).
g = 9223372036854775808u64;
let r1: u64 = g / 4611686018427387904u64;
assert(r1 == 2u64);
// global_ucmp: (1<<63) > 1 is true unsigned, false signed (bug: JG).
g = 9223372036854775808u64;
assert(g > 1u64);
// signed_global_ctl: a SIGNED i64 global must KEEP the signed shift —
// -8 >> 1 == -4 (control: c5 reads the stamp, no blanket
// global -> unsigned over-conversion).
s = -8;
let r3: i64 = s >> 1;
assert(r3 == -4);
};