class test option pattern
private boolean match a(character c) pure
return c == 'a' || c == 'A'
private boolean match b(character c) pure
return c == 'b' || c == 'B'
private boolean match c(character c) pure
return c == 'c' || c == 'C'
testcase test match()
assert the pattern("ab")
assert the pattern("AAAA")
assert the pattern("AAAABB")
assert the pattern("bbc")
assert the pattern("BBCcc")
assert the pattern("Ccc")
assert !the pattern("abc")
assert !the pattern("baaaa")
assert !the pattern("accc")
testcase test viable prefix()
assert the pattern • is viable prefix("")
assert the pattern • is viable prefix("a")
assert the pattern • is viable prefix("aAa")
assert the pattern • is viable prefix("aabb")
assert the pattern • is viable prefix("bb")
assert the pattern • is viable prefix("bbccc")
assert the pattern • is viable prefix("cc")
assert !the pattern • is viable prefix("x")
assert !the pattern • is viable prefix("xyz")
assert !the pattern • is viable prefix("ba")
assert !the pattern • is viable prefix("cca")
assert !the pattern • is viable prefix("Cccb")
testcase test match prefix()
assert the pattern • match prefix("") is null
assert the pattern • match prefix("x") is null
assert the pattern • match prefix("xac") is null
assert the pattern • match prefix("xab") is null
assert the pattern • match prefix("abbc") == 3
assert the pattern • match prefix("bcdef") == 2
assert the pattern • match prefix("aAbBcCdef") == 4
assert the pattern • match prefix("bCabc") == 2
assert the pattern • match prefix("aaabbbcccddd") == 6
testcase test find first()
assert the pattern • find first("", 0) is null
assert the pattern • find first("foo", 0) is null
assert the pattern • find first("abcfoo", 3) is null
match : the pattern • find first("xxaabbcczz", 0)
assert match is_not null
assert match • begin == 2
assert match • end == 6
match2 : the pattern • find first("aaabbbAAACCCBBB", 1)
assert match2 is_not null
assert match2 • begin == 1
assert match2 • end == 6
match3 : the pattern • find first("aaabbbAAACCCBBB", 6)
assert match3 is_not null
assert match3 • begin == 6
assert match3 • end == 9
match4 : the pattern • find first("fooACxyzABC", 0)
assert match4 is_not null
assert match4 • begin == 3
assert match4 • end == 4
match5 : the pattern • find first("aaabbbAAACCCBBB", 9)
assert match5 is_not null
assert match5 • begin == 9
assert match5 • end == 12
testcase test split()
split0 : the pattern • split("foo")
assert split0 • size == 1
assert equals(split0[0], "foo")
split1 : the pattern • split("fooBCxyzAB")
assert split1 • size == 3
assert equals(split1[0], "foo")
assert equals(split1[1], "xyz")
assert equals(split1[2], "")
split2 : the pattern • split("aaa1ab2BC3")
assert split2 • size == 4
assert equals(split2[0], "")
assert equals(split2[1], "1")
assert equals(split2[2], "2")
assert equals(split2[3], "3")
boolean equals(immutable list[character] s0, string s1)
return (s0 !> string) == s1