class test option pattern
option pattern[character] make pattern()
pattern[character] alpha : sequence pattern[character] • new([match one or more a, match zero or more b])
pattern[character] beta : sequence pattern[character] • new([match zero or more b, match one or more 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("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 match is_not null
assert match • begin == 2
assert match • end == 6
assert match2 is_not null
assert match2 • begin == 1
assert match2 • end == 6
assert match3 is_not null
assert match3 • begin == 6
assert match3 • end == 9
assert match4 is_not null
assert match4 • begin == 3
assert match4 • end == 4
assert match5 is_not null
assert match5 • begin == 9
assert match5 • end == 12
testcase test split()
assert split0 • size == 1
assert equals(split0[0], "foo")
assert split1 • size == 3
assert equals(split1[0], "foo")
assert equals(split1[1], "xyz")
assert equals(split1[2], "")
assert split2 • size == 4
assert equals(split2[0], "")
assert equals(split2[1], "1")
assert equals(split2[2], "2")
assert equals(split2[3], "3")