Pure move: the hasprefix/hassuffix, contains, byteindex/rbyteindex/
index/rindex, and compare sections of strings_test.ww become sibling
suffix_test.ww, contains_test.ww, index_test.ww, compare_test.ww,
mirroring ref/hare/strings/{suffix,contains,index,compare}.ha
ownership. Blocks are byte-identical; only the section banner lines
are deleted (the file names now carry them).
The remaining families (dup, concat, trim, sub, utf8, iter, tokenize,
pad, replace, cut) stay in strings_test.ww: they all consume the
file-local streq helper, and a helper cannot be shared across split
test files — a single-file test root does not pull same-package
siblings (undefined: helper), while dir-mode composes all package
test files into one unit (duplicate fn helper). Splitting them would
force either helper duplication or renames, both out of scope for a
pure move.
Consumers: Makefile LIBRARY_TESTS gains the four new entries beside
the strings_test.ww row; test/byteid/libbyteid_test.ww roster gains
four fx rows, NENTEXPECT 44->48 (+4).
29 lines
1.1 KiB
Plaintext
29 lines
1.1 KiB
Plaintext
// containstest — exercises strings.contains. A failing row aborts
|
|
// via the assert/abort builtin (task #5 @test conversion).
|
|
// Vectors mirror ref/hare/strings/contains.ha.
|
|
|
|
package strings_test;
|
|
|
|
import strings;
|
|
|
|
// ref/hare/strings/contains.ha:27.
|
|
|
|
@test fn contains_cases() void = {
|
|
assert(!(!strings.contains("hello world", "hello")));
|
|
assert(!(!strings.contains("hello world", 'h')));
|
|
assert(!( strings.contains("hello world", 'x')));
|
|
assert(!(!strings.contains("hello world", "world")));
|
|
assert(!(!strings.contains("hello world", ""))); // empty hits at 0
|
|
assert(!( strings.contains("hello world", "foobar")));
|
|
assert(!(!strings.contains("こんにちは", 0x306Bu32: rune))); // 'に'
|
|
assert(!(!strings.contains("こんにちは", "ちは")));
|
|
|
|
// Variadic rows. ref/hare/strings/contains.ha:27.
|
|
assert(!( strings.contains("hello")));
|
|
assert(!(!strings.contains("hello world", "world")));
|
|
assert(!(!strings.contains("hello", 'l')));
|
|
assert(!(!strings.contains("hello world", "foo", "world", 'x')));
|
|
assert(!( strings.contains("hello", "foo", 'z', "bar")));
|
|
assert(!(!strings.contains("héllo", "x", 0xE9u32: rune)));
|
|
};
|