wcc/ww: drop underscores from next/peek/remaining-tokens (F-Z)

This commit is contained in:
2026-06-15 04:31:16 +09:00
parent 5ae3787cb9
commit 04d35c25c3
10 changed files with 278 additions and 278 deletions

View File

@@ -1096,28 +1096,28 @@ fn streq(a: str, b: str) bool = {
assert(!(!streq(strings.iterstr(&rit), "he")));
};
// ---- tokenize / rtokenize / peek_token / remaining_tokens -----------
// ---- tokenize / rtokenize / peektoken / remainingtokens -----------
// ref/hare/strings/tokenize.ha:110 @test fn tokenize. Row drivers
// mirror lib/bytes/bytestest expect_token / expect_done but compare
// str via streq.
fn expect_str_token(t: *strings.tokenizer, want: str) void = {
match (strings.peek_token(t)) {
match (strings.peektoken(t)) {
case let p: str => { assert(!(!streq(p, want))); };
case bytes.done => { abort(); };
};
match (strings.next_token(t)) {
match (strings.nexttoken(t)) {
case let n: str => { assert(!(!streq(n, want))); };
case bytes.done => { abort(); };
};
};
fn expect_str_done(t: *strings.tokenizer) void = {
match (strings.peek_token(t)) {
match (strings.peektoken(t)) {
case let p: str => { abort(); };
case bytes.done => void;
};
match (strings.next_token(t)) {
match (strings.nexttoken(t)) {
case let n: str => { abort(); };
case bytes.done => void;
};
@@ -1177,7 +1177,7 @@ fn expect_str_done(t: *strings.tokenizer) void = {
};
@test fn rtokenize_cases() void = {
// Reverse direction — first next_token is the last token.
// Reverse direction — first nexttoken is the last token.
let t: strings.tokenizer = strings.rtokenize(
"Hello world! My name is Harriet.", " ");
expect_str_token(&t, "Harriet.");
@@ -1200,55 +1200,55 @@ fn expect_str_done(t: *strings.tokenizer) void = {
expect_str_done(&t3);
};
@test fn peek_token_cases() void = {
@test fn peektoken_cases() void = {
// Two peeks without advancing return the same token.
let t: strings.tokenizer = strings.tokenize("a b c", " ");
match (strings.peek_token(&t)) {
match (strings.peektoken(&t)) {
case let p: str => { assert(!(!streq(p, "a"))); };
case bytes.done => { abort(); };
};
match (strings.peek_token(&t)) {
match (strings.peektoken(&t)) {
case let p: str => { assert(!(!streq(p, "a"))); };
case bytes.done => { abort(); };
};
// Advance once — peek then returns "b".
match (strings.next_token(&t)) {
match (strings.nexttoken(&t)) {
case let n: str => { assert(!(!streq(n, "a"))); };
case bytes.done => { abort(); };
};
match (strings.peek_token(&t)) {
match (strings.peektoken(&t)) {
case let p: str => { assert(!(!streq(p, "b"))); };
case bytes.done => { abort(); };
};
// Empty input — peek is done.
let t2: strings.tokenizer = strings.tokenize("", " ");
match (strings.peek_token(&t2)) {
match (strings.peektoken(&t2)) {
case let p: str => { abort(); };
case bytes.done => void;
};
};
@test fn remaining_tokens_cases() void = {
// ref/hare/strings/tokenize.ha:157. After 2 next_tokens, remaining
@test fn remainingtokens_cases() void = {
// ref/hare/strings/tokenize.ha:157. After 2 nexttokens, remaining
// is "My name is Harriet.".
let t: strings.tokenizer = strings.tokenize(
"Hello world! My name is Harriet.", " ");
match (strings.next_token(&t)) {
match (strings.nexttoken(&t)) {
case let n: str => { assert(!(!streq(n, "Hello"))); };
case bytes.done => { abort(); };
};
match (strings.next_token(&t)) {
match (strings.nexttoken(&t)) {
case let n: str => { assert(!(!streq(n, "world!"))); };
case bytes.done => { abort(); };
};
if (!streq(strings.remaining_tokens(&t), "My name is Harriet.")) {
if (!streq(strings.remainingtokens(&t), "My name is Harriet.")) {
abort();
};
// Fresh tokenizer — remaining_tokens is the whole input.
// Fresh tokenizer — remainingtokens is the whole input.
let t2: strings.tokenizer = strings.tokenize("a b c", " ");
assert(!(!streq(strings.remaining_tokens(&t2), "a b c")));
assert(!(!streq(strings.remainingtokens(&t2), "a b c")));
};
// ---- splitn / rsplitn / split ----------------------------------------
@@ -1338,7 +1338,7 @@ fn expect_str(toks: []str, i: i32, want: str) void = {
expect_str(t3, 0, "a b c");
os.free(t3.ptr: *void, (t3.cap: u64) * size(str): u64);
// delim absent — first next_token yields the entire input as the
// delim absent — first nexttoken yields the entire input as the
// sole token; second iter sees done and short-circuits with the
// 1-elem toks un-reversed (single element, reverse is a no-op).
let t4: []str = strings.rsplitn("abc", "=", 5);