aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_declarations.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/test_declarations.py b/tests/test_declarations.py
index 3fd6683..9eaf488 100644
--- a/tests/test_declarations.py
+++ b/tests/test_declarations.py
@@ -1,6 +1,8 @@
import unittest
from crowbar_reference_compiler import compile_to_ssa, load_declarations, parse_header, parse_implementation, scan
+from crowbar_reference_compiler.declarations import ArrayType, BasicType, EnumDeclaration, PointerType, \
+ StructDeclaration, UnionDeclaration, VariableDeclaration
class TestDeclarationLoading(unittest.TestCase):
@@ -8,6 +10,7 @@ class TestDeclarationLoading(unittest.TestCase):
code = r"""
struct normal {
bool fake;
+ (uint8[3])* data;
}
opaque struct ope;
@@ -31,8 +34,20 @@ fragile union not_robust {
"""
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'])
+ decls = load_declarations(parse_tree, [])
+ normal = StructDeclaration('normal', [
+ VariableDeclaration('fake', BasicType('bool'), None),
+ VariableDeclaration('data', PointerType(ArrayType(BasicType('uint8'), 3)), None),
+ ])
+ ope = StructDeclaration('ope', None)
+ sample = EnumDeclaration('sample', [('Testing', None)])
+ robust = UnionDeclaration('robust', VariableDeclaration('tag', BasicType('enum sample'), None),
+ [('Testing', VariableDeclaration('testPassed', BasicType('bool'), None))])
+ not_robust = UnionDeclaration('not_robust', None,
+ [VariableDeclaration('sample', BasicType('int8'), None),
+ VariableDeclaration('nope', BasicType('bool'), None)])
+ self.assertListEqual(decls, [normal, ope, sample, robust, not_robust])
+
if __name__ == '__main__':
unittest.main()