signalled/fail() counters and run-loop plumbing removed; failure sites become assert(!(cond)); table rows and @test fns 1:1. Bare mains stay until the -T flip commit. Spec: .ai/drew-t2-conversion-spec.md.
55 lines
1.0 KiB
Plaintext
55 lines
1.0 KiB
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);
|
|
};
|
|
|
|
export fn main() i32 = {
|
|
vec_empty();
|
|
vec_helloworld();
|
|
vec_hareiscool();
|
|
vec_bdale();
|
|
vec_geer();
|
|
return 0;
|
|
};
|