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

23 lines
684 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-06-15 07:12:22 +00:00
@pytest.mark.parametrize('sig,parse', [
(";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-06-15 07:12:22 +00:00
@pytest.mark.parametrize('sig,parse', [
(";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