Hardened DefaultParser

This commit is contained in:
2020-09-22 17:39:42 +02:00
parent 310c9ae839
commit 9b965105e9
5 changed files with 220 additions and 40 deletions
+16
View File
@@ -77,3 +77,19 @@ def test_i_can_parse_twice():
while p2.next_token():
p1.next_token()
assert p1.token == p2.token
@pytest.mark.parametrize("text, skip_whitespace, expected", [
("first second", True, "second"),
("first second", False, "<ws>"),
("first", True, "<EOF>"),
("first", False, "<EOF>"),
("first ", True, "<EOF>"),
("first ", False, "<ws>"),
("first:", True, ":"),
("first:", False, ":"),
])
def test_i_can_get_the_token_after(text, skip_whitespace, expected):
parser_input = ParserInput(text).reset()
parser_input.next_token()
assert parser_input.the_token_after(skip_whitespace).repr_value == expected