yorick: Fix evaluation of empty vectors in steps 2 and 3
[jackhill/mal.git] / impls / tests / step7_quote.mal
CommitLineData
c30efef4
JM
1;; Testing cons function
2(cons 1 (list))
3;=>(1)
4(cons 1 (list 2))
5;=>(1 2)
6(cons 1 (list 2 3))
7;=>(1 2 3)
8(cons (list 1) (list 2 3))
9;=>((1) 2 3)
10
05ad2bf6
DM
11(def! a (list 2 3))
12(cons 1 a)
13;=>(1 2 3)
14a
15;=>(2 3)
16
c30efef4
JM
17;; Testing concat function
18(concat)
19;=>()
20(concat (list 1 2))
21;=>(1 2)
22(concat (list 1 2) (list 3 4))
23;=>(1 2 3 4)
24(concat (list 1 2) (list 3 4) (list 5 6))
25;=>(1 2 3 4 5 6)
26(concat (concat))
27;=>()
40eb57d6
BD
28(concat (list) (list))
29;=>()
c30efef4 30
05ad2bf6
DM
31(def! a (list 1 2))
32(def! b (list 3 4))
33(concat a b (list 5 6))
34;=>(1 2 3 4 5 6)
35a
36;=>(1 2)
37b
38;=>(3 4)
c30efef4 39
31690700
JM
40;; Testing regular quote
41(quote 7)
42;=>7
31690700
JM
43(quote (1 2 3))
44;=>(1 2 3)
31690700
JM
45(quote (1 2 (3 4)))
46;=>(1 2 (3 4))
31690700
JM
47
48;; Testing simple quasiquote
49(quasiquote 7)
50;=>7
31690700
JM
51(quasiquote (1 2 3))
52;=>(1 2 3)
31690700
JM
53(quasiquote (1 2 (3 4)))
54;=>(1 2 (3 4))
3dcaa6ce
DM
55(quasiquote (nil))
56;=>(nil)
31690700
JM
57
58;; Testing unquote
46e25689 59(quasiquote (unquote 7))
31690700
JM
60;=>7
61(def! a 8)
62;=>8
46e25689 63(quasiquote a)
31690700 64;=>a
46e25689 65(quasiquote (unquote a))
31690700 66;=>8
46e25689 67(quasiquote (1 a 3))
31690700 68;=>(1 a 3)
46e25689 69(quasiquote (1 (unquote a) 3))
31690700 70;=>(1 8 3)
46e25689 71(def! b (quote (1 "b" "d")))
31690700 72;=>(1 "b" "d")
46e25689 73(quasiquote (1 b 3))
31690700 74;=>(1 b 3)
46e25689 75(quasiquote (1 (unquote b) 3))
31690700 76;=>(1 (1 "b" "d") 3)
89f7cef6
BD
77(quasiquote ((unquote 1) (unquote 2)))
78;=>(1 2)
31690700
JM
79
80;; Testing splice-unquote
46e25689 81(def! c (quote (1 "b" "d")))
31690700 82;=>(1 "b" "d")
46e25689 83(quasiquote (1 c 3))
31690700 84;=>(1 c 3)
46e25689 85(quasiquote (1 (splice-unquote c) 3))
31690700
JM
86;=>(1 1 "b" "d" 3)
87
88
89;; Testing symbol equality
46e25689 90(= (quote abc) (quote abc))
31690700 91;=>true
46e25689 92(= (quote abc) (quote abcd))
31690700 93;=>false
46e25689 94(= (quote abc) "abc")
31690700 95;=>false
46e25689 96(= "abc" (quote abc))
31690700 97;=>false
46e25689 98(= "abc" (str (quote abc)))
a16bb08f 99;=>true
46e25689 100(= (quote abc) nil)
17946efb 101;=>false
46e25689 102(= nil (quote abc))
17946efb 103;=>false
1771ab50
JM
104
105;;;;; Test quine
106;;; TODO: needs expect line length fix
107;;;((fn* [q] (quasiquote ((unquote q) (quote (unquote q))))) (quote (fn* [q] (quasiquote ((unquote q) (quote (unquote q)))))))
108;;;=>((fn* [q] (quasiquote ((unquote q) (quote (unquote q))))) (quote (fn* [q] (quasiquote ((unquote q) (quote (unquote q)))))))
b554fd4e 109
a1eb30fc 110;>>> deferrable=True
46e25689 111;;
a1eb30fc 112;; -------- Deferrable Functionality --------
46e25689
JM
113
114;; Testing ' (quote) reader macro
115'7
116;=>7
117'(1 2 3)
118;=>(1 2 3)
119'(1 2 (3 4))
120;=>(1 2 (3 4))
121
77fd710c
JM
122;; Testing cons and concat with vectors
123
124(cons [1] [2 3])
125;=>([1] 2 3)
126(cons 1 [2 3])
127;=>(1 2 3)
128(concat [1 2] (list 3 4) [5 6])
129;=>(1 2 3 4 5 6)
130(concat [1 2])
131;=>(1 2)
132
133
134;>>> optional=True
135;;
136;; -------- Optional Functionality --------
137
46e25689
JM
138;; Testing ` (quasiquote) reader macro
139`7
140;=>7
141`(1 2 3)
142;=>(1 2 3)
143`(1 2 (3 4))
144;=>(1 2 (3 4))
145`(nil)
146;=>(nil)
147
148;; Testing ~ (unquote) reader macro
149`~7
150;=>7
151(def! a 8)
152;=>8
153`(1 ~a 3)
154;=>(1 8 3)
155(def! b '(1 "b" "d"))
156;=>(1 "b" "d")
157`(1 b 3)
158;=>(1 b 3)
159`(1 ~b 3)
160;=>(1 (1 "b" "d") 3)
161
162;; Testing ~@ (splice-unquote) reader macro
163(def! c '(1 "b" "d"))
164;=>(1 "b" "d")
165`(1 c 3)
166;=>(1 c 3)
167`(1 ~@c 3)
168;=>(1 1 "b" "d" 3)
169
b554fd4e
JM
170;; Testing unquote with vectors
171(def! a 8)
172;=>8
173`[1 a 3]
174;=>(1 a 3)
175;;; TODO: fix this
176;;;;=>[1 a 3]
177
178;; Testing splice-unquote with vectors
179(def! c '(1 "b" "d"))
180;=>(1 "b" "d")
181`[1 ~@c 3]
182;=>(1 1 "b" "d" 3)
183;;; TODO: fix this
184;;;;=>[1 1 "b" "d" 3]