Add tests for claims in documentation

This commit is contained in:
Flaviu Tamas
2015-01-16 20:04:38 -05:00
parent abccac2f06
commit a7ce05b42f
2 changed files with 7 additions and 0 deletions

View File

@@ -12,3 +12,7 @@ suite "find":
check("1 2 3 4 5 ".findAll(initRegex(r" ", "S")).map(
proc (a: RegexMatch): Slice[int] = a.matchBounds
) == @[1..2, 3..4, 5..6, 7..8, 9..10])
test "overlapping find":
check("222".findAllStr(re"22") == @["22"])
check("2222".findAllStr(re"22") == @["22", "22"])

View File

@@ -8,3 +8,6 @@ suite "string splitting":
check("1 2 ".split(initRegex(" ", "S")) == @["1", "", "2", "", ""])
check("1 2".split(initRegex(" ", "S")) == @["1", "2"])
check("foo".split(initRegex("foo")) == @["", ""])
test "captured patterns":
check("12".split(re"(\d)") == @["", "1", "", "2", ""])