25 renames (git mv, content untouched). _test.ww is what the package coordinator's test detection and the sep loader's canonical exclusion key on; the old *test.ww spellings survived only through the line-leading-@test compatibility scan. Consumers updated in place: LIBRARY_TESTS, the libbyteid roster, the 901/974/975/976 carriers that copy or invoke these files, and the check.c/check.ww + path/ftos comments that cite them. Closes the open-driver-work migration bullet.
68 lines
2.3 KiB
Plaintext
68 lines
2.3 KiB
Plaintext
// asciitest — exercises lib/ascii case folding. Run with
|
|
// `ww run lib/ascii/asciitest.ww`. A failing row aborts via the
|
|
// assert/abort builtin (task #5 @test conversion).
|
|
//
|
|
// Vectors mirror Hare's @test fn strcasecmp in ref/hare/ascii/string.ha.
|
|
|
|
package ascii_test;
|
|
|
|
import ascii;
|
|
|
|
// checkfold — one table row: strlower(in) == lo and strupper(in) == up.
|
|
fn checkfold(in: str, lo: str, up: str) void = {
|
|
match (ascii.strlower(in)) {
|
|
case let got: str => { assert(!(got != lo)); };
|
|
case nomem => { abort(); };
|
|
};
|
|
match (ascii.strupper(in)) {
|
|
case let got: str => { assert(!(got != up)); };
|
|
case nomem => { abort(); };
|
|
};
|
|
};
|
|
|
|
// ref/hare/ascii/string.ha:70 case-fold vectors. The こ row pins that a
|
|
// UTF-8 multibyte sequence (all bytes >=0x80) passes through unchanged.
|
|
@test fn strfold_cases() void = {
|
|
checkfold("ABC", "abc", "ABC");
|
|
checkfold("abc", "abc", "ABC");
|
|
checkfold("[[[", "[[[", "[[[");
|
|
checkfold("こ", "こ", "こ");
|
|
checkfold("", "", "");
|
|
checkfold("aB1z", "ab1z", "AB1Z");
|
|
};
|
|
|
|
// checkbuf — strlower_buf/strupper_buf into an exactly-sized buf.
|
|
fn checkbuf(in: str, lo: str, up: str) void = {
|
|
let lstore: [16]u8; let lbuf: []u8 = lstore[0:16]; lbuf.len = 0;
|
|
match (ascii.strlower_buf(in, lbuf)) {
|
|
case let got: str => { assert(!(got != lo)); };
|
|
case nomem => { abort(); };
|
|
};
|
|
let ustore: [16]u8; let ubuf: []u8 = ustore[0:16]; ubuf.len = 0;
|
|
match (ascii.strupper_buf(in, ubuf)) {
|
|
case let got: str => { assert(!(got != up)); };
|
|
case nomem => { abort(); };
|
|
};
|
|
};
|
|
|
|
@test fn strfold_buf_cases() void = {
|
|
checkbuf("ABC", "abc", "ABC");
|
|
checkbuf("aB1z", "ab1z", "AB1Z");
|
|
checkbuf("", "", "");
|
|
// non-ASCII pins UTF-8 multibyte passthrough through the _buf path
|
|
// directly (all bytes >=0x80, untouched by the byte-wise fold).
|
|
checkbuf("こ", "こ", "こ");
|
|
// cap exactly == s.len must succeed — pins the `<` boundary in the
|
|
// buf.cap check (a `<=` off-by-one would wrongly return nomem here).
|
|
let exact: [3]u8; let ebuf: []u8 = exact[0:3]; ebuf.len = 0;
|
|
match (ascii.strlower_buf("ABC", ebuf)) {
|
|
case let got: str => { assert(!(got != "abc")); };
|
|
case nomem => { abort(); };
|
|
};
|
|
let small: [2]u8; let sbuf: []u8 = small[0:2]; sbuf.len = 0;
|
|
match (ascii.strlower_buf("ABC", sbuf)) {
|
|
case let got: str => { abort(); };
|
|
case nomem => void;
|
|
};
|
|
};
|