From f48f0bb0acd2bf271e1ebce16e66b91be4476b70 Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Tue, 31 Jan 2023 23:43:01 +0100 Subject: [PATCH] Add a very very simple test checking that the parser actually works. --- pyproject.toml | 7 ++-- tests/__init__.py | 2 +- tests/__pycache__/__init__.cpython-311.pyc | Bin 0 -> 153 bytes .../test_parser.cpython-311-pytest-7.2.1.pyc | Bin 0 -> 1998 bytes tests/run_tests.py | 13 ------- tests/test_parser.py | 33 ++++++++++++++++++ 6 files changed, 37 insertions(+), 18 deletions(-) create mode 100644 tests/__pycache__/__init__.cpython-311.pyc create mode 100644 tests/__pycache__/test_parser.cpython-311-pytest-7.2.1.pyc delete mode 100644 tests/run_tests.py create mode 100644 tests/test_parser.py 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 0000000000000000000000000000000000000000..ce987795d8a997c6fe47be0454feb8ddc2071a04 GIT binary patch literal 153 zcmZ3^%ge<81V^XdOlAbqk3k$5011G=XEq=)ogsxGm_d`#ZzV$!6G#vw^GioRv^ce> zSU;&WDPO-TGc66s(JiPf$;i*sFG(#fDb|mV&&nx>^3CT%Lbs5rIP_)tPbBvK+FSxA&aQzfg7cau6=+v}MP zP8J&l)I&g#fKx$$RBW8V@4er= zeQWH^ES$Ipnj||~4 zT8tUo$4C+X@tlha$GA63-8lXtgB0L<{0D@8g4Q7DFI)@O7S}}Yqa~-sCy>MSTnxU+ z|A>C(p8@tf!a3x4QM#i!U~LIa?rBIrJmjy2Fc@d|?oH%)th!?gkxWZG$)G6?`kWj6 z)X4`>oR;{xxLXO<2G>BF!UNRc`Z92X8JtAO2chPGwIwwr`ofS5*%|7cT95AV48Z4+ z;ZsDfIit}Qt;a*%i8O@z^OJs$h|BpNRnCx&*#G2n`D{Le_ay!2A{K+^Aa|@UV(+BX ze=j5cli)&~TCy`9Rso?t->9NZx!<>c_a(drEy+O8>WQKfa}y7<_+bvKOH1xZI*ZfU z+p2=InT)Eq*R^F_$6DQ7R&l-2(DGQz=2SeB#kpB`1S~nMVHGc9HLtqy9Il%=Z06me zI?mx4)kA09u{utNJDgT=UYS+g%OB~4maA*n+_Z^FX}MOti|^laZ|jtr#KE`H_Li#9 zcKN%4Dln(k;r8fI231G@Y=k8hupTundiu zHqq9s+KO&zRlQ=eghusM(}UT_oPP}nJ5NZBurY15Mk>1FQLyx??j=-WY^cYG67L;g z$sWSw;9`t3*^oyoC`~Td1o84T23|NAucoIzf#T8Wm5r6!v|C;UGW0EA{-{=+_UKbz zYJM?D#@=Eh{-sKKwTrzD!MvX)`W^gOZKDn!ACo&M6x$zmE}_wj+aDZWne3pLbi)@r z$qp|kZXBg9wlBT?+iM_T?xzX|sX{wdI2yn8bbWt3doZ5exp$Zv`=u(J@lK*Y&|)MWeAdf5V;3H2?qr literal 0 HcmV?d00001 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)>)"))