aboutsummaryrefslogtreecommitdiffstats
path: root/csc/encoding-test.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-01-11 22:01:23 -0800
committerRose Hogenson <rhogenson@posteo.net>2022-01-11 22:01:23 -0800
commit68986fe0410584c6934c835bb0ee784655f5f8c5 (patch)
treed51bc2f3e09df35ef81b7a0c462ff555b4344701 /csc/encoding-test.csc
parent4fc8b3c1c9dc4aa730e471708dcab7aed68f5a4b (diff)
downloadchromatopelma-68986fe0410584c6934c835bb0ee784655f5f8c5.tar.zst
Move scheme compiler into a separate directory.
Diffstat (limited to 'csc/encoding-test.csc')
-rw-r--r--csc/encoding-test.csc117
1 files changed, 117 insertions, 0 deletions
diff --git a/csc/encoding-test.csc b/csc/encoding-test.csc
new file mode 100644
index 0000000..a7f4ace
--- /dev/null
+++ b/csc/encoding-test.csc
@@ -0,0 +1,117 @@
+(import (scheme base)
+ (only (csc testing) test assert-equal)
+ (csc encoding))
+
+
+(test encode-const
+ (assert-equal
+ '(#xf2 #x3 0 0 0 0 0 0 #xf6 #xff #xff #xff #xff #xff #xff #xff)
+ (encode '((const -10)))))
+
+
+(test encode-add
+ (assert-equal
+ '(#xfc #x3 0 0 0 0 0 0)
+ (encode '(add))))
+
+
+(test encode-sub
+ (assert-equal
+ '(#x6 #x4 0 0 0 0 0 0)
+ (encode '(sub))))
+
+
+(test encode-mul
+ (assert-equal
+ '(#x10 #x4 0 0 0 0 0 0)
+ (encode '(mul))))
+
+
+(test encode-div
+ (assert-equal
+ '(#x1a #x4 0 0 0 0 0 0)
+ (encode '(div))))
+
+
+(test encode-mod
+ (assert-equal
+ '(#x24 #x4 0 0 0 0 0 0)
+ (encode '(mod))))
+
+
+(test encode-alloc
+ (assert-equal
+ '(#xda #x7 0 0 0 0 0 0)
+ (encode '(alloc))))
+
+
+(test encode-peek
+ (assert-equal
+ '(#xe4 #x7 0 0 0 0 0 0 #xa)
+ (encode '((peek 10)))))
+
+
+(test encode-poke
+ (assert-equal
+ '(#xee #x7 0 0 0 0 0 0 #xa)
+ (encode '((poke 10)))))
+
+
+(test encode-peekbyte
+ (assert-equal
+ '(#xf8 #x7 0 0 0 0 0 0)
+ (encode '(peekbyte))))
+
+
+(test encode-pokebyte
+ (assert-equal
+ '(#x2 #x8 0 0 0 0 0 0)
+ (encode '(pokebyte))))
+
+
+(test encode-pop
+ (assert-equal
+ '(#xc2 #xb 0 0 0 0 0 0)
+ (encode '(pop))))
+
+
+(test encode-local
+ (assert-equal
+ '(#xcc #xb 0 0 0 0 0 0 #xa)
+ (encode '((local 10)))))
+
+
+(test encode-if
+ (assert-equal
+ '(#xaa #xf 0 0 0 0 0 0 #xf6 #xff #xff #xff #xff #xff #xff #xff)
+ (encode '((if -10)))))
+
+
+(test encode-call
+ (assert-equal
+ '(#xb4 #xf 0 0 0 0 0 0 #xa)
+ (encode '((call 10)))))
+
+
+(test encode-ret
+ (assert-equal
+ '(#xbe #xf 0 0 0 0 0 0)
+ (encode '(ret))))
+
+
+(test encode-exit
+ (assert-equal
+ '(#xc8 #xf 0 0 0 0 0 0)
+ (encode '(exit))))
+
+
+(test encode-putc
+ (assert-equal
+ '(#x92 #x13 0 0 0 0 0 0)
+ (encode '(putc))))
+
+
+(test encode-getc
+ (assert-equal
+ '(#x9c #x13 0 0 0 0 0 0)
+ (encode '(getc))))