Add str test
This commit is contained in:
@@ -241,7 +241,7 @@ let parseBetweenPair* = proc(delimiterParser: parserFnT): parserFnT {.closure.}
|
||||
when isMainModule:
|
||||
let testParser123 = initParserResult("123")
|
||||
|
||||
block testBlockChar:
|
||||
block testParsingFunctions:
|
||||
let ch1 = ch('1')
|
||||
let chDigits = ch(Digits)
|
||||
|
||||
@@ -249,13 +249,14 @@ when isMainModule:
|
||||
assert testParser123.flatMap(ch1).tokensToString() == "1"
|
||||
assert testParser123.flatMap(anyCh).tokensToString() == "1"
|
||||
assert testParser123.flatMap(chDigits).tokensToString() == "1"
|
||||
assert testParser123.flatMap(str("123")).tokensToString() == "123"
|
||||
|
||||
# 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("").flatMap(ch1).error().kind == endOfStringErr
|
||||
assert initParserResult("1").flatMap(ch1).flatMap(ch1).error().kind == endOfStringErr
|
||||
|
||||
# Stream end reached
|
||||
|
||||
Reference in New Issue
Block a user