Add test for chars
This commit is contained in:
@@ -248,6 +248,17 @@ when isMainModule:
|
||||
|
||||
block testBlockChar:
|
||||
let ch1 = ch('1')
|
||||
let ch2 = ch('2')
|
||||
let ch3 = ch('3')
|
||||
let chDigits = ch(Digits)
|
||||
|
||||
assert testParser123.flatMap(ch1).tokensToString() == "1"
|
||||
assert testParser123.flatMap(chDigits).tokensToString() == "1"
|
||||
|
||||
# Mismatch
|
||||
assert testParser123.flatMap(ch('2')).error().kind == charMismatchErr
|
||||
assert testParser123.flatMap(ch(Letters)).error().kind == charMismatchErr
|
||||
|
||||
# Out of bounds
|
||||
assert initParserResult("").flatMap(ch1).error().kind == endOfStringErr
|
||||
assert initParserResult("1").flatMap(ch1).flatMap(ch1).error().kind == endOfStringErr
|
||||
|
||||
Reference in New Issue
Block a user