From 18f2033852f4888af498394e184b1cb498f08956 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Mon, 16 Mar 2026 23:00:16 +0000 Subject: Show off example output on the website. Change-Id: Ia78a5476a786a8894a75ca0e5b763ab19f492554 --- example.scm | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 example.scm (limited to 'example.scm') 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") -- cgit 1.4.1