runtest: Don't worry about how implementation echoes input
[jackhill/mal.git] / impls / tests / step1_read_print.mal
CommitLineData
31690700
JM
1;; Testing read of numbers
21
3;=>1
47
5;=>7
6 7
7;=>7
2c1eb1af
DM
8-123
9;=>-123
31690700
JM
10
11
12;; Testing read of symbols
13+
14;=>+
15abc
16;=>abc
17 abc
18;=>abc
19abc5
20;=>abc5
21abc-def
22;=>abc-def
23
78c71a51
NB
24;; Testing non-numbers starting with a dash.
25-
26;=>-
27-abc
28;=>-abc
29->>
30;=>->>
31690700 31
31690700
JM
32;; Testing read of lists
33(+ 1 2)
34;=>(+ 1 2)
a7ed71b9
JM
35()
36;=>()
f7983f72
BH
37( )
38;=>()
9e8f5211
JM
39(nil)
40;=>(nil)
31690700
JM
41((3 4))
42;=>((3 4))
43(+ 1 (+ 2 3))
44;=>(+ 1 (+ 2 3))
45 ( + 1 (+ 2 3 ) )
46;=>(+ 1 (+ 2 3))
01c97316
JM
47(* 1 2)
48;=>(* 1 2)
49(** 1 2)
50;=>(** 1 2)
2c1eb1af
DM
51(* -3 6)
52;=>(* -3 6)
beeffb02
BH
53(()())
54;=>(() ())
31690700 55
abdd56eb
JM
56;; Test commas as whitespace
57(1 2, 3,,,,),,
58;=>(1 2 3)
59
46e25689 60
a1eb30fc 61;>>> deferrable=True
46e25689
JM
62
63;;
a1eb30fc 64;; -------- Deferrable Functionality --------
46e25689
JM
65
66;; Testing read of nil/true/false
67nil
68;=>nil
69true
70;=>true
71false
72;=>false
73
74;; Testing read of strings
75"abc"
76;=>"abc"
77 "abc"
78;=>"abc"
79"abc (with parens)"
80;=>"abc (with parens)"
81"abc\"def"
82;=>"abc\"def"
46e25689
JM
83""
84;=>""
ca89606b
BH
85"\\"
86;=>"\\"
87"\\\\\\\\\\\\\\\\\\"
88;=>"\\\\\\\\\\\\\\\\\\"
3b797cd5
NB
89"&"
90;=>"&"
91"'"
92;=>"'"
93"("
94;=>"("
95")"
96;=>")"
97"*"
98;=>"*"
99"+"
100;=>"+"
101","
102;=>","
103"-"
104;=>"-"
748df6f7
DM
105"/"
106;=>"/"
3b797cd5
NB
107":"
108;=>":"
109";"
110;=>";"
111"<"
112;=>"<"
113"="
114;=>"="
115">"
116;=>">"
117"?"
118;=>"?"
119"@"
120;=>"@"
121"["
122;=>"["
123"]"
124;=>"]"
125"^"
126;=>"^"
127"_"
128;=>"_"
129"`"
130;=>"`"
131"{"
132;=>"{"
133"}"
134;=>"}"
135"~"
136;=>"~"
46e25689
JM
137
138;; Testing reader errors
46e25689 139(1 2
f6f5d4f2 140;/.*(EOF|end of input|unbalanced).*
46e25689 141[1 2
f6f5d4f2
JM
142;/.*(EOF|end of input|unbalanced).*
143
144;;; These should throw some error with no return value
46e25689 145"abc
4aa0ebdf 146;/.*(EOF|end of input|unbalanced).*
d35721f8
BH
147"
148;/.*(EOF|end of input|unbalanced).*
149"\"
150;/.*(EOF|end of input|unbalanced).*
ca89606b
BH
151"\\\\\\\\\\\\\\\\\\\"
152;/.*(EOF|end of input|unbalanced).*
46e25689 153(1 "abc
4aa0ebdf 154;/.*(EOF|end of input|unbalanced).*
f6f5d4f2 155(1 "abc"
4aa0ebdf 156;/.*(EOF|end of input|unbalanced).*
46e25689 157
f5223195
JM
158;; Testing read of quoting
159'1
160;=>(quote 1)
161'(1 2 3)
162;=>(quote (1 2 3))
163`1
164;=>(quasiquote 1)
165`(1 2 3)
166;=>(quasiquote (1 2 3))
167~1
168;=>(unquote 1)
169~(1 2 3)
170;=>(unquote (1 2 3))
9e8f5211
JM
171`(1 ~a 3)
172;=>(quasiquote (1 (unquote a) 3))
f5223195
JM
173~@(1 2 3)
174;=>(splice-unquote (1 2 3))
175
4ee7c0f2 176
b8ee29b2
JM
177;; Testing keywords
178:kw
179;=>:kw
180(:kw1 :kw2 :kw3)
181;=>(:kw1 :kw2 :kw3)
182
31690700
JM
183;; Testing read of vectors
184[+ 1 2]
185;=>[+ 1 2]
a7ed71b9
JM
186[]
187;=>[]
f7983f72
BH
188[ ]
189;=>[]
31690700
JM
190[[3 4]]
191;=>[[3 4]]
192[+ 1 [+ 2 3]]
193;=>[+ 1 [+ 2 3]]
194 [ + 1 [+ 2 3 ] ]
195;=>[+ 1 [+ 2 3]]
beeffb02
BH
196([])
197;=>([])
31690700 198
31690700 199;; Testing read of hash maps
f7983f72
BH
200{}
201;=>{}
f0338adf
BH
202{ }
203;=>{}
31690700
JM
204{"abc" 1}
205;=>{"abc" 1}
206{"a" {"b" 2}}
207;=>{"a" {"b" 2}}
208{"a" {"b" {"c" 3}}}
209;=>{"a" {"b" {"c" 3}}}
210{ "a" {"b" { "cde" 3 } }}
211;=>{"a" {"b" {"cde" 3}}}
e69f0ea3
BH
212;;; The regexp sorcery here ensures that each key goes with the correct
213;;; value and that each key appears only once.
d6383c83
BH
214{"a1" 1 "a2" 2 "a3" 3}
215;/{"a([1-3])" \1 "a(?!\1)([1-3])" \2 "a(?!\1)(?!\2)([1-3])" \3}
f6a4ddf7 216{ :a {:b { :cde 3 } }}
b8ee29b2 217;=>{:a {:b {:cde 3}}}
80512fcc
BH
218{"1" 1}
219;=>{"1" 1}
beeffb02
BH
220({})
221;=>({})
31690700 222
9af8aee6
JM
223;; Testing read of comments
224 ;; whole line comment (not an exception)
2251 ; comment after expression
226;=>1
2271; comment after expression
228;=>1
31690700 229
31690700
JM
230;; Testing read of @/deref
231@a
232;=>(deref a)
3b797cd5
NB
233
234;>>> soft=True
77fd710c
JM
235;>>> optional=True
236;;
237;; -------- Optional Functionality --------
238
31690700
JM
239;; Testing read of ^/metadata
240^{"a" 1} [1 2 3]
241;=>(with-meta [1 2 3] {"a" 1})
242
243
3b797cd5
NB
244;; Non alphanumerice characters in strings
245;;; \t is not specified enough to be tested
246"\n"
247;=>"\n"
248"#"
249;=>"#"
250"$"
251;=>"$"
252"%"
253;=>"%"
254"."
255;=>"."
256"\\"
257;=>"\\"
258"|"
259;=>"|"
260
261;; Non alphanumeric characters in comments
2621;!
263;=>1
2641;"
265;=>1
2661;#
267;=>1
2681;$
269;=>1
2701;%
271;=>1
2721;'
273;=>1
2741;\
275;=>1
2761;\\
277;=>1
2781;\\\
279;=>1
2801;`
281;=>1
282;;; Hopefully less problematic characters
2831; &()*+,-./:;<=>?@[]^_{|}~
284
285;; FIXME: These tests have no reasons to be optional, but...
286;; fantom fails this one
287"!"
288;=>"!"