source/projects/shoggoth/test/ichor/test_parsers.py

22 lines
683 B
Python
Raw Normal View History

2022-06-14 07:19:30 +00:00
#!/usr/bin/env python3
2022-06-28 04:35:21 +00:00
from ichor.state import FUNC, TYPE
2022-06-14 07:19:30 +00:00
import pytest
2022-07-16 01:37:34 +00:00
@pytest.mark.parametrize("sig,parse", [
2022-06-15 07:12:22 +00:00
(";not;bool;bool", ((), "not", ("bool",), ("bool",))),
(";and;bool,bool;bool", ((), "and", ("bool", "bool"), ("bool",))),
(";or;bool,bool,bool;bool", ((), "or", ("bool", "bool", "bool"), ("bool",))),
2022-06-14 07:19:30 +00:00
])
2022-06-15 07:12:22 +00:00
def test_func_parses(sig, parse):
assert FUNC.parse(sig) == parse
2022-06-14 07:19:30 +00:00
2022-07-16 01:37:34 +00:00
@pytest.mark.parametrize("sig,parse", [
2022-06-15 07:12:22 +00:00
(";bool;true(),false()", ((), "bool", (("true", ()), ("false", ())))),
("A,B;pair;pair(a:A,b:B)", (("A", "B"), "pair", (("pair", (("a", "A"), ("b", "B"))),))),
2022-06-14 07:19:30 +00:00
])
2022-06-28 04:35:21 +00:00
def test_type_parses(sig, parse):
assert TYPE.parse(sig) == parse