diff --git a/pyproject.toml b/pyproject.toml index b498de9..d241ae3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ version = "0.1.0" description = "Port of the Ziffers numerical notation for Python" authors = [ {name = "Raphaël Forment", email="raphael.forment@gmail.com"}, - {name = "Miika Alonen" email = "amiika@gmail.com"} + {name = "Miika Alonen", email = "amiika@gmail.com"} ] license = {file = "LICENSE.txt"} readme = "README.md" @@ -18,8 +18,8 @@ classifiers = [ dependencies = [ "lark>=1.1.5", - "rich>=12.6.0" - "pytest=>7.2.1" + "rich>=12.6.0", + "pytest=>7.2.1", ] [project.urls] @@ -31,4 +31,3 @@ repository = "https://github.com/Bubobubobubobubo/ziffers-python" line-length = 88 target_version = ['py310'] include = '\.pyi?$' -exclude = ''' diff --git a/tests/__init__.py b/tests/__init__.py index a4e4a35..8b13789 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +1 @@ -import ziffers \ No newline at end of file + diff --git a/tests/__pycache__/__init__.cpython-311.pyc b/tests/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..ce98779 Binary files /dev/null and b/tests/__pycache__/__init__.cpython-311.pyc differ diff --git a/tests/__pycache__/test_parser.cpython-311-pytest-7.2.1.pyc b/tests/__pycache__/test_parser.cpython-311-pytest-7.2.1.pyc new file mode 100644 index 0000000..c36b66e Binary files /dev/null and b/tests/__pycache__/test_parser.cpython-311-pytest-7.2.1.pyc differ diff --git a/tests/run_tests.py b/tests/run_tests.py deleted file mode 100644 index b69c9aa..0000000 --- a/tests/run_tests.py +++ /dev/null @@ -1,13 +0,0 @@ -import pytest -from ziffers import * - -@pytest.mark.parametrize( - "pattern", - [ - "1 2 3", - "(1 (2 3))" - "q 2 q2 eq.4" - ], -) -def test_list_arithmetic(pattern: str): - assert parse_expression(pattern).text == pattern \ No newline at end of file diff --git a/tests/test_parser.py b/tests/test_parser.py new file mode 100644 index 0000000..8f454a1 --- /dev/null +++ b/tests/test_parser.py @@ -0,0 +1,33 @@ +from ziffers import * + +def test_can_parse(): + expressions = [ + "[1 [2 3]]", + "(1 (1,3) 1..3)", + "_^ q _qe^3 qww_4 _123 <1 2>", + "q _2 _ 3 ^ 343", + "2 qe2 e4", + "q 2 <3 343>", + "q (2 <3 343 (3 4)>)", + ] + results = [] + for expression in expressions: + try: + print(f"Parsing expression: {expression}") + result = parse_expression(expression) + results.append(True) + except Exception as e: + print(e) + results.append(False) + + # Return true if all the results are true (succesfully parsed) + print(results) + assert all(results) + +#print(ziffers_parser.parse("[1 [2 3]]")) +#print(ziffers_parser.parse("(1 (1,3) 1..3)")) +#print(ziffers_parser.parse("_^ q _qe^3 qww_4 _123 <1 2>")) +#print(ziffers_parser.parse("q _2 _ 3 ^ 343")) +#print(ziffers_parser.parse("2 qe2 e4").values) +#print(ziffers_parser.parse("q 2 <3 343>")) +#print(ziffers_parser.parse("q (2 <3 343 (3 4)>)"))