Make study a negatable option instead

This commit is contained in:
Flaviu Tamas 2015-01-18 12:49:22 -05:00
commit ca299504d1
3 changed files with 7 additions and 8 deletions

View file

@ -4,12 +4,12 @@ include nre
suite "find":
test "find text":
check("3213a".find(initRegex(r"[a-z]")).match == "a")
check("1 2 3 4 5 6 7 8 ".findAll(initRegex(r" ", "S")).map(
check("1 2 3 4 5 6 7 8 ".findAll(re" ").map(
proc (a: RegexMatch): string = a.match
) == @[" ", " ", " ", " ", " ", " ", " ", " "])
test "find bounds":
check("1 2 3 4 5 ".findAll(initRegex(r" ", "S")).map(
check("1 2 3 4 5 ".findAll(re" ")).map(
proc (a: RegexMatch): Slice[int] = a.matchBounds
) == @[1..2, 3..4, 5..6, 7..8, 9..10])

View file

@ -4,9 +4,9 @@ include nre
suite "string splitting":
test "splitting strings":
check("12345".split(initRegex("")) == @["1", "2", "3", "4", "5"])
check("1 2 3 4 5 6 ".split(initRegex(" ", "S")) == @["1", "2", "3", "4", "5", "6", ""])
check("1 2 ".split(initRegex(" ", "S")) == @["1", "", "2", "", ""])
check("1 2".split(initRegex(" ", "S")) == @["1", "2"])
check("1 2 3 4 5 6 ".split(re" ") == @["1", "2", "3", "4", "5", "6", ""])
check("1 2 ".split(initRegex(" ")) == @["1", "", "2", "", ""])
check("1 2".split(initRegex(" ")) == @["1", "2"])
check("foo".split(initRegex("foo")) == @["", ""])
test "captured patterns":