aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2020-11-04 17:37:12 -0700
committerMelody Horn <melody@boringcactus.com>2020-11-04 17:37:12 -0700
commiteaf789901101b8958c2555a0af300d7471707fea (patch)
tree322eae2398cd6b3a994ba3d8bdc7f13d1f1b442d /tests
parent68c303c285032e2f0398352b70eb79736a72296f (diff)
downloadreference-compiler-eaf789901101b8958c2555a0af300d7471707fea.tar.gz
reference-compiler-eaf789901101b8958c2555a0af300d7471707fea.zip
preserve more info about declarations
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()