blob: dae6cbd7b1fa6fcdb2eeea66d6567894fff8bc0e (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
;; Testing cons function
(cons 1 (list))
;=>(1)
(cons 1 (list 2))
;=>(1 2)
(cons 1 (list 2 3))
;=>(1 2 3)
(cons (list 1) (list 2 3))
;=>((1) 2 3)
;; Testing concat function
(concat)
;=>()
(concat (list 1 2))
;=>(1 2)
(concat (list 1 2) (list 3 4))
;=>(1 2 3 4)
(concat (list 1 2) (list 3 4) (list 5 6))
;=>(1 2 3 4 5 6)
(concat (concat))
;=>()
;; Testing regular quote
(quote 7)
;=>7
'7
;=>7
(quote (1 2 3))
;=>(1 2 3)
'(1 2 3)
;=>(1 2 3)
(quote (1 2 (3 4)))
;=>(1 2 (3 4))
'(1 2 (3 4))
;=>(1 2 (3 4))
;; Testing simple quasiquote
(quasiquote 7)
;=>7
`7
;=>7
(quasiquote (1 2 3))
;=>(1 2 3)
`(1 2 3)
;=>(1 2 3)
(quasiquote (1 2 (3 4)))
;=>(1 2 (3 4))
`(1 2 (3 4))
;=>(1 2 (3 4))
;; Testing unquote
`~7
;=>7
(def! a 8)
;=>8
`a
;=>a
`~a
;=>8
`(1 a 3)
;=>(1 a 3)
`(1 ~a 3)
;=>(1 8 3)
(def! b '(1 "b" "d"))
;=>(1 "b" "d")
`(1 b 3)
;=>(1 b 3)
`(1 ~b 3)
;=>(1 (1 "b" "d") 3)
;; Testing splice-unquote
(def! c '(1 "b" "d"))
;=>(1 "b" "d")
`(1 c 3)
;=>(1 c 3)
`(1 ~@c 3)
;=>(1 1 "b" "d" 3)
;; Testing symbol equality
(= 'abc 'abc)
;=>true
(= 'abc 'abcd)
;=>false
(= 'abc "abc")
;=>false
(= "abc" 'abc)
;=>false
;;;;; Test quine
;;; TODO: needs expect line length fix
;;;((fn* [q] (quasiquote ((unquote q) (quote (unquote q))))) (quote (fn* [q] (quasiquote ((unquote q) (quote (unquote q)))))))
;;;=>((fn* [q] (quasiquote ((unquote q) (quote (unquote q))))) (quote (fn* [q] (quasiquote ((unquote q) (quote (unquote q)))))))
;;
;; -------- Optional Functionality --------
;; Testing cons, concat, first, rest with vectors
(cons [1] [2 3])
;=>([1] 2 3)
(cons 1 [2 3])
;=>(1 2 3)
(concat [1 2] (list 3 4) [5 6])
;=>(1 2 3 4 5 6)
;; Testing unquote with vectors
(def! a 8)
;=>8
`[1 a 3]
;=>(1 a 3)
;;; TODO: fix this
;;;;=>[1 a 3]
;; Testing splice-unquote with vectors
(def! c '(1 "b" "d"))
;=>(1 "b" "d")
`[1 ~@c 3]
;=>(1 1 "b" "d" 3)
;;; TODO: fix this
;;;;=>[1 1 "b" "d" 3]
|