test suite test predicate pattern
private boolean test predicate(character c) pure
return c == 'a' || c == 'b' || c == 'c'
test case test match()
assert the pattern("a")
assert !the pattern("y")
assert !the pattern("xx")
test case test viable prefix()
assert the pattern • is viable prefix("")
assert the pattern • is viable prefix("a")
assert !the pattern • is viable prefix("y")
assert !the pattern • is viable prefix("aa")
test case test match prefix()
assert the pattern • match prefix("") is null
assert the pattern • match prefix("a") == 1
assert the pattern • match prefix("x") is null
assert the pattern • match prefix("abcdef") == 1
test case 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("bfoo", 1) is null
match : the pattern • find first("a", 0)
assert match is_not null
assert match • begin == 0
assert match • end == 1
match2 : the pattern • find first("ayzzyby", 2)
assert match2 is_not null
assert match2 • begin == 5
assert match2 • end == 6
test case test find last()
assert the pattern • find last("", missing • instance) is null
assert the pattern • find last("foo", missing • instance) is null
assert the pattern • find last("foo", 3) is null
assert the pattern • find last("fooc", 3) is null
match : the pattern • find last("c", 1)
assert match is_not null
assert match • begin == 0
assert match • end == 1
match2 : the pattern • find last("ayzzyby", 6)
assert match2 is_not null
assert match2 • begin == 5
assert match2 • end == 6
match3 : the pattern • find last("ayzzyby", 4)
assert match3 is_not null
assert match3 • begin == 0
assert match3 • end == 1
match4 : the pattern • find last("ayzzyby", missing • instance)
assert match4 is_not null
assert match4 • begin == 5
assert match4 • end == 6
test case test split()
split0 : the pattern • split("foo")
assert split0 • size == 1
assert equals(split0[0], "foo")
split1 : the pattern • split("fooaxyzc")
assert split1 • size == 3
assert equals(split1[0], "foo")
assert equals(split1[1], "xyz")
assert equals(split1[2], "")
split2 : the pattern • split("a1b2c3")
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