Skip to content
Snippets Groups Projects
Commit 67ee4beb authored by Hugo Hörnquist's avatar Hugo Hörnquist
Browse files

Add tests parser combinator `not_` and `all_`.

parent 3273e8c6
No related branches found
No related tags found
No related merge requests found
import pytest
from muppet.parser_combinator import (
MatchObject,
ParseDirective,
......@@ -179,6 +180,26 @@ def test_complement():
assert ["He"] == p2.get(many(complement("l")))
def test_not_fail():
p1 = ParserCombinator(" Hello")
with pytest.raises(ParseError):
p1.get(~ space)
assert False, "Should never be rearched"
def test_not_succeed():
p2 = ParserCombinator("AAAAA")
assert [] == p2.get(~ space)
def test_all_():
p1 = ParserCombinator("Hello ")
assert ["H"] == p1.get(all_(~ space, char))
p2 = ParserCombinator("Hello ")
assert ["Hello"] == p2.get(many(all_(~ space, char)))
def test_stringifiers():
assert "'a'" == str(s("a"))
assert "~ 'a'" == repr(~ s("a"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment