From 67ee4beb7505d8c2597408b31c100ed1eaccc1c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= <hugo@lysator.liu.se>
Date: Wed, 20 Sep 2023 23:02:07 +0200
Subject: [PATCH] Add tests parser combinator `not_` and `all_`.

---
 tests/test_parser_combinator.py | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tests/test_parser_combinator.py b/tests/test_parser_combinator.py
index ea45940..3767dcb 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"))
-- 
GitLab