generated from 8dcc/c-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
misc.lisp
52 lines (40 loc) · 1.67 KB
/
misc.lisp
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
;;------------------------------------------------------------------------------
;; Miscellaneous tests that don't fit in the other files
;;------------------------------------------------------------------------------
unbound-error-var ; Expected: Unbound symbol: unbound-error-var
(define var1 10) ; Expected: 10
(define var2 (* 2 var1)) ; Expected: 20
(define my-addition +) ; Expected: <primitive ...>
(my-addition var1 var2) ; Expected: 30
;; Because there is an implicit evaluation of each argument before calling
;; `apply', `eval' receives a symbol of content "my-addition". After evaluating
;; this simbol, the addition C primitive is returned, and then applied to `var1'
;; and `var2', which were also evaluated implicitly.
(define my-symbol 'my-addition) ; Expected: my-addition
((eval my-symbol) var1 var2) ; Expected: 30
(equal? '(1 2 3) '(1 2 3)) ; Expected: tru
(equal? '(1 2 3) '(1 2 9)) ; Expected: nil
(equal? 1 1.0) ; Expected: nil
(= 1 1.0) ; Expected: tru
(= 1 1.000001) ; Expected: nil
;; Symbol `nil' evaluates to itself, see manual.
(type-of nil) ; Expected: List
(type-of 'nil) ; Expected: Symbol
(equal? nil 'nil) ; Expected: tru
(> 1 1) ; Expected: nil
(> 1 2) ; Expected: nil
(> 2 1) ; Expected: tru
(< 1 1) ; Expected: nil
(< 2 1) ; Expected: nil
(< 1 2) ; Expected: tru
(< 1.0 2) ; Expected: tru
(> 2.0 1) ; Expected: tru
(or) ; Expected: nil
(and) ; Expected: tru
(or nil nil nil) ; Expected: nil
(and 1 2 3) ; Expected: 3
(or nil tru 'unreachable) ; Expected: tru
(and 123 nil 'unreachable) ; Expected: nil
(set-random-seed 50)
(random 1337)
(random 10.0)