diff --git a/tests/test_parser_combinator.py b/tests/test_parser_combinator.py index ea45940b89503f436a465d72ddcda33c4873fdac..3767dcbf83499b800ad41281b72aeaec415ed9c8 100644 --- a/tests/test_parser_combinator.py +++ b/tests/test_parser_combinator.py @@ -1,3 +1,4 @@ +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"))