Add test for chars

This commit is contained in:
Florian Schroedl
2022-08-26 16:08:26 +02:00
parent e5bf85a551
commit 1f4bd5d60e
2 changed files with 18 additions and 0 deletions

View File

@@ -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