-
Notifications
You must be signed in to change notification settings - Fork 0
/
core_test.cmp
61 lines (52 loc) · 1.21 KB
/
core_test.cmp
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
(defun test-pair ()
(assert
(pair. '(x y z) '(a b c))
'((x a) (y b) (z c))))
(defun test-assoc-with-1 ()
(assert
(assoc. 'x '((x a) (y b)))
'a))
(defun test-assoc-with-2 ()
(assert
(assoc. 'x '((x new) (x a) (y b)))
'new))
(defun test-eval-atom ()
(assert
(eval. 'x '((x a) (y b)))
'a))
(defun test-eval-invoking-no-param ()
(assert
(eval. '(eq 'a 'a) '())
true))
(defun test-eval-invoking-with-param ()
(assert
(eval.
'(cons x '(b c))
'((x a) (y b)))
'(a b c)))
(defun test-eval-calling-evcon ()
(assert
(eval. '(cond ((atom x) 'atom)
(true 'list))
'((x '(a b))))
'list))
(defun test-eval-lambda ()
(assert
(eval. '(f '(b c))
'((f (lambda (x) (cons 'a x)))))
'(a b c)))
(defun test-eval-fun-with-lambda-param ()
(assert
(eval. '((label firstatom (lambda (x)
(cond ((atom x) x)
(true (firstatom (car x))))))
y)
'((y ((a b) (c d)))))
'a))
(defun test-eval-calling-evlis ()
(assert
(eval. '((lambda (x y) (cons x (cdr y)))
'a
'(b c d))
'())
'(a c d)))