Files
ww/lib/hash/adler32/adler32_test.ww
Hojun-Cho 2338ea5d59 ww: lib tests run via -T test mode; bare mains retired (closes @test conversion)
'ww test' gains the istest build path (-T injection in build_one/
buildone) and do_test/dotest accept -I, mirroring do_run - both twins.
The 35 converted lib tests drop their interim bare mains (-T
synthesizes the entry from @test fns and rejects a user main); their
35 C run-drivers flip 'ww run' -> 'ww test'; 989_lib_byteid compiles
lib tests under -T (8 user-main probe fixtures stay non-T, gated on
the fixture field). Abort-on-first-failure stands until the deferred
record-and-continue harness lands with the multi-package arc.
2026-06-10 20:45:46 +09:00

46 lines
923 B
Plaintext

package adler32_test;
import adler32;
fn putstr(s: str, into: []u8, off: i32) i32 = {
let i: i32 = 0;
for (i < s.len) {
into[off + i] = s[i];
i += 1;
};
return off + s.len;
};
fn check(s: str, want: u32) void = {
let arr: [256]u8;
let n: i32 = putstr(s, arr[0:256], 0);
let buf: []u8 = arr[0:n];
let got: u32 = adler32.sum32(buf);
assert(!(got != want));
};
@test fn vec_empty() void = {
let arr: [1]u8;
let buf: []u8 = arr[0:0];
let h: u32 = adler32.sum32(buf);
assert(!(h != 1u32));
};
@test fn vec_helloworld() void = {
check("hello world", 436929629u32);
};
@test fn vec_hareiscool() void = {
check("Hare is a cool language", 1578567727u32);
};
@test fn vec_bdale() void = {
check("'Life is too short to run proprietary software' - Bdale Garbee",
3135706652u32);
};
@test fn vec_geer() void = {
check("'The central enemy of reliability is complexity.' - Geer et al",
3170309588u32);
};