about summary refs log tree commit diff
path: root/example.scm
diff options
context:
space:
mode:
authorArun Isaac2026-03-16 23:00:16 +0000
committerArun Isaac2026-03-17 00:23:39 +0000
commit18f2033852f4888af498394e184b1cb498f08956 (patch)
treea2ffc1939c83be593849773682953094f975eb13 /example.scm
parent7a86d1bef0758691cc9ca708d59b272d173fee84 (diff)
downloadrun64-18f2033852f4888af498394e184b1cb498f08956.tar.gz
run64-18f2033852f4888af498394e184b1cb498f08956.tar.lz
run64-18f2033852f4888af498394e184b1cb498f08956.zip
Show off example output on the website.
Change-Id: Ia78a5476a786a8894a75ca0e5b763ab19f492554
Diffstat (limited to 'example.scm')
-rw-r--r--example.scm45
1 files changed, 45 insertions, 0 deletions
diff --git a/example.scm b/example.scm
new file mode 100644
index 0000000..beb0fda
--- /dev/null
+++ b/example.scm
@@ -0,0 +1,45 @@
+(test-begin "arithmetic")
+
+(test-equal "addition" 4 (+ 2 2))
+(test-equal "subtraction" 0 (- 5 5))
+(test-equal "multiplication" 12 (* 3 4))
+(test-equal "division" 5 (/ 10 2))
+
+(test-end "arithmetic")
+
+(test-begin "strings")
+
+(test-equal "concatenation"
+  "hello world"
+  (string-append "hello" " " "world"))
+
+(test-equal "length"
+  5
+  (string-length "hello"))
+
+(test-equal "case conversion"
+  "HELLO"
+  (string-upcase "hello"))
+
+(test-end "strings")
+
+(test-begin "lists")
+
+(test-equal "append"
+  '(1 2 3 4)
+  (append '(1 2) '(3 4)))
+
+(test-equal "reverse"
+  '(3 2 1)
+  (reverse '(1 2 3)))
+
+(test-equal "map"
+  '(2 4 6)
+  (map (lambda (x) (* x 2))
+       '(1 2 3)))
+
+(test-equal "wrong result"
+  '(a b c d)
+  '(a x c y))
+
+(test-end "lists")