diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_declarations.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/test_declarations.py b/tests/test_declarations.py new file mode 100644 index 0000000..3fd6683 --- /dev/null +++ b/tests/test_declarations.py @@ -0,0 +1,38 @@ +import unittest + +from crowbar_reference_compiler import compile_to_ssa, load_declarations, parse_header, parse_implementation, scan + + +class TestDeclarationLoading(unittest.TestCase): + def test_kitchen_sink(self): + code = r""" +struct normal { + bool fake; +} + +opaque struct ope; + +enum sample { + Testing, +} + +union robust { + enum sample tag; + + switch (tag) { + case Testing: bool testPassed; + } +} + +fragile union not_robust { + int8 sample; + bool nope; +} +""" + tokens = scan(code) + parse_tree = parse_header(tokens) + decls = load_declarations(parse_tree) + self.assertListEqual(decls, ['struct normal', 'struct ope', 'enum sample', 'union robust', 'union not_robust']) + +if __name__ == '__main__': + unittest.main() |