aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2020-11-05 01:27:58 -0700
committerMelody Horn <melody@boringcactus.com>2020-11-05 01:27:58 -0700
commitb6258d36b6534d521e9cdf1307665c38e5ae409d (patch)
tree7e98020964173869f2799533553bcdcd1f64ea1a /tests
parent9dfc552c0703c5e14ea472eb5431719b2e0d6400 (diff)
downloadreference-compiler-b6258d36b6534d521e9cdf1307665c38e5ae409d.tar.gz
reference-compiler-b6258d36b6534d521e9cdf1307665c38e5ae409d.zip
compile based on the fancy new AST
Diffstat (limited to 'tests')
-rw-r--r--tests/test_hello_world.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/tests/test_hello_world.py b/tests/test_hello_world.py
index 594ab4f..0377392 100644
--- a/tests/test_hello_world.py
+++ b/tests/test_hello_world.py
@@ -1,12 +1,12 @@
import unittest
-from crowbar_reference_compiler import compile_to_ssa, parse_header, parse_implementation, scan
+from crowbar_reference_compiler import build_ast, build_ssa, parse_header, parse_implementation, scan
class TestHelloWorld(unittest.TestCase):
def test_ssa(self):
code = r"""
-include "stdio.hro";
+//include "stdio.hro";
int32 main() {
printf("Hello, world!\n");
@@ -15,14 +15,17 @@ int32 main() {
"""
tokens = scan(code)
parse_tree = parse_implementation(tokens)
- actual_ssa = compile_to_ssa(parse_tree)
+ ast = build_ast(parse_tree, [])
+ actual_ssa = build_ssa(ast)
expected_ssa = r"""
data $data0 = { b "Hello, world!\n", b 0 }
export function w $main() {
@start
- call $printf(l $data0, ...)
- ret 0
+ %t0 =l copy $data0
+ call $printf(l %t0, ...)
+ %t1 =w copy 0
+ ret %t1
}
""".strip()
self.assertEqual(expected_ssa, actual_ssa)