aboutsummaryrefslogtreecommitdiffstats
path: root/csc/codegen-test.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-07-24 20:29:19 -0700
committerRose Hogenson <rhogenson@posteo.net>2022-07-24 20:29:19 -0700
commitac23fca796d6dc6fc7aab0ac5bdf8987aa490761 (patch)
tree05280a50eb2f9fb4229bb0e9d2be037ca4aa3d5c /csc/codegen-test.csc
parent498040c3d1532bb6de01dbbb55348f631c3745d6 (diff)
downloadchromatopelma-ac23fca796d6dc6fc7aab0ac5bdf8987aa490761.tar.zst
Write a test for codegen.
I'm not sure yet how to test regalloc.
Diffstat (limited to 'csc/codegen-test.csc')
-rw-r--r--csc/codegen-test.csc17
1 files changed, 14 insertions, 3 deletions
diff --git a/csc/codegen-test.csc b/csc/codegen-test.csc
index 9c47661..b85ebc3 100644
--- a/csc/codegen-test.csc
+++ b/csc/codegen-test.csc
@@ -8,10 +8,14 @@
make-fix
make-primitive
make-variable)
+ (only (csc loop)
+ loop
+ return)
(only (csc match)
match)
(only (csc testing)
- assert-equal)
+ assert-equal
+ test)
(csc codegen))
@@ -21,7 +25,12 @@
(match expr
(('label _) #t)
(_ #f)))
- (lambda (expr) 'label))))
+ (lambda (expr) 'label))
+ (cons (lambda (expr)
+ (match expr
+ (('local _) #t)
+ (_ #f)))
+ (lambda (expr) 'local))))
(define (test-var)
@@ -30,7 +39,9 @@
(test codegen-apply
(assert-equal
- 'something
+ '((peek (local #f) (local #f) (const 5))
+ (mov (local #f) (const 10))
+ (jmp (local #f)))
(ir2->ir3
(make-fix '()
(make-primitive 'peek (list *globals* (make-constant 5)) (list (test-var))