blob: 3fd6683c2c1a76b0e73a1abbaa8c3edd28255e11 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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()
|