test suite test repeat element
private boolean test predicate(character c) pure
return c == 'a' || c == 'b' || c == 'c'
test case test match()
assert zero or more("")
assert zero or more("a")
assert zero or more("abca")
assert !zero or more("abcda")
assert !zero or more("y")
assert !zero or more("xab")
assert !one or more("")
assert one or more("a")
assert one or more("abca")
assert !one or more("abcda")
assert !one or more("y")
assert !one or more("xab")
test case test viable prefix()
assert zero or more • is viable prefix("")
assert zero or more • is viable prefix("a")
assert zero or more • is viable prefix("ab")
assert !zero or more • is viable prefix("y")
assert !zero or more • is viable prefix("ay")
assert one or more • is viable prefix("")
assert one or more • is viable prefix("a")
assert one or more • is viable prefix("ab")
assert !one or more • is viable prefix("y")
assert !one or more • is viable prefix("ay")
test case test match prefix()
assert zero or more • match prefix("") == 0
assert zero or more • match prefix("a") == 1
assert zero or more • match prefix("abc") == 3
assert zero or more • match prefix("abcdef") == 3
assert zero or more • match prefix("x") == 0
assert zero or more • match prefix("xabc") == 0
assert zero or more • match prefix("abcabc") == 6
assert one or more • match prefix("") is null
assert one or more • match prefix("a") == 1
assert one or more • match prefix("abc") == 3
assert one or more • match prefix("abcdef") == 3
assert one or more • match prefix("x") is null
assert one or more • match prefix("xabc") is null
assert one or more • match prefix("abcabc") == 6
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("-abc-", 0)
assert match2 is_not null
assert match2 • begin == 1
assert match2 • end == 4
match3 : the pattern • find first("ayzzybacy", 2)
assert match3 is_not null
assert match3 • begin == 5
assert match3 • end == 8
match4 : the pattern2 • find first("", 0)
assert match4 is_not null
assert match4 • begin == 0
assert match4 • end == 0
match5 : the pattern2 • find first("xyz", 2)
assert match5 is_not null
assert match5 • begin == 2
assert match5 • end == 2
match6 : the pattern2 • find first("xabcd", 1)
assert match6 is_not null
assert match6 • begin == 1
assert match6 • end == 4
match7 : the pattern2 • find first("ayzzybacy", 2)
assert match7 is_not null
assert match7 • begin == 2
assert match7 • end == 2
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("ayzzzby", 6)
assert match2 is_not null
assert match2 • begin == 5
assert match2 • end == 6
match3 : the pattern • find last("abczyby", 4)
assert match3 is_not null
assert match3 • begin == 0
assert match3 • end == 3
match4 : the pattern • find last("ayzzyabcy", missing • instance)
assert match4 is_not null
assert match4 • begin == 5
assert match4 • end == 8
match5 : the pattern2 • find last("", missing • instance)
assert match5 is_not null
assert match5 • begin == 0
assert match5 • end == 0
match6 : the pattern2 • find last("foobar", 2)
assert match6 is_not null
assert match6 • begin == 2
assert match6 • end == 2
match7 : the pattern2 • find last("foobar", 5)
assert match7 is_not null
assert match7 • begin == 3
assert match7 • end == 5
match8 : the pattern2 • find last("ayzzyabcy", missing • instance)
assert match8 is_not null
assert match8 • begin == 9
assert match8 • end == 9
test case test split()
split0 : the pattern • split("foo")
assert split0 • size == 1
assert equals(split0[0], "foo")
split1 : the pattern • split("fooabcxyzc")
assert split1 • size == 3
assert equals(split1[0], "foo")
assert equals(split1[1], "xyz")
assert equals(split1[2], "")
split2 : the pattern • split("ab1bc2ca3")
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