From fb2dff51dfdd8a1cb8c4353cae72dd21435b313f Mon Sep 17 00:00:00 2001 From: John Doty Date: Sat, 15 Jun 2024 06:14:37 -0700 Subject: [PATCH] Tests. Well, test. --- tests/__init__.py | 0 tests/test_grammar.py | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/test_grammar.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_grammar.py b/tests/test_grammar.py new file mode 100644 index 0000000..3845990 --- /dev/null +++ b/tests/test_grammar.py @@ -0,0 +1,18 @@ +import parser +import pytest + + +def test_conflicting_names(): + """Terminals and nonterminals can have the same name.""" + + IDENTIFIER = parser.Terminal("Identifier") + + class TestGrammar(parser.Grammar): + start = "Identifier" + + @parser.rule("Identifier") + def identifier(self): + return IDENTIFIER + + with pytest.raises(ValueError): + TestGrammar().build_table()