about summary refs log tree commit diff
path: root/example.scm
blob: beb0fda6265a4102761ca5cf3956d8dc09de506c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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")