aboutsummaryrefslogtreecommitdiffstats
path: root/linker-test.csc
diff options
context:
space:
mode:
authorRose Hogenson <rhogenson@posteo.net>2022-01-09 22:55:59 -0800
committerRose Hogenson <rhogenson@posteo.net>2022-01-09 22:55:59 -0800
commit77583a881b03ce38c8065c40641489fe88b61eb2 (patch)
treed4f65cfd698fee8e63168b4a5b64ab4123177fc3 /linker-test.csc
parentRemove str- prefixes from the strings library. (diff)
downloadchromatopelma-77583a881b03ce38c8065c40641489fe88b61eb2.tar.zst
Write the linker.
Diffstat (limited to 'linker-test.csc')
-rw-r--r--linker-test.csc24
1 files changed, 24 insertions, 0 deletions
diff --git a/linker-test.csc b/linker-test.csc
new file mode 100644
index 0000000..084e9ae
--- /dev/null
+++ b/linker-test.csc
@@ -0,0 +1,24 @@
+(import (scheme base)
+ (only (csc encoding) encode)
+ (only (csc testing)
+ assert-equal
+ test)
+ (csc linker))
+
+
+(test link-if
+ (assert-equal
+ (encode '((const 5) (const 1) (if 2) (const 5) add exit))
+ (link '((const 5) (const 1) (if "label1") (const 5) add (label "label1") exit))))
+
+
+(test link-backwards-if
+ (assert-equal
+ (encode '((const 10) (const 5) add (if -3)))
+ (link '((const 10) (label "label1") (const 5) add (if "label1")))))
+
+
+(test link-call
+ (assert-equal
+ (encode '((call 3) (const 10) exit (const 5) exit))
+ (link '((call "label1") (const 10) (label "label0") exit (label "label1") (const 5) exit))))