Change endpos to inclusive

This commit is contained in:
Oleh Prypin 2015-04-09 23:49:26 +03:00
commit 2f0375c4c8
3 changed files with 11 additions and 10 deletions

View file

@ -1,9 +1,10 @@
include nre, unittest, optional_t.nonstrict
suite "match":
test "upper bound must be exclusive":
check("abc".match(re"abc", endpos = 0) == None[RegexMatch]())
check("abc".match(re"abc", endpos = 3) != None[RegexMatch]())
test "upper bound must be inclusive":
check("abc".match(re"abc", endpos = -1) == None[RegexMatch]())
check("abc".match(re"abc", endpos = 1) == None[RegexMatch]())
check("abc".match(re"abc", endpos = 2) != None[RegexMatch]())
test "match examples":
check("abc".match(re"(\w)").captures[0] == "a")