source/projects/shoggoth/test/python/ichor/test_parsers.py
2022-07-15 19:37:34 -06:00

21 lines
683 B
Python

#!/usr/bin/env python3
from ichor.state import FUNC, TYPE
import pytest
@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",))),
])
def test_func_parses(sig, parse):
assert FUNC.parse(sig) == parse
@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"))),))),
])
def test_type_parses(sig, parse):
assert TYPE.parse(sig) == parse