Travis: split build and test into separate scripts.
[jackhill/mal.git] / tests / step1_read_print.mal
CommitLineData
31690700
JM
1;; Testing read of nil/true/false
2nil
3;=>nil
4true
5;=>true
6false
7;=>false
8
9
10;; Testing read of numbers
111
12;=>1
137
14;=>7
15 7
16;=>7
17
18
19;; Testing read of symbols
20+
21;=>+
22abc
23;=>abc
24 abc
25;=>abc
26abc5
27;=>abc5
28abc-def
29;=>abc-def
30
31
32;; Testing read of strings
33"abc"
34;=>"abc"
35 "abc"
36;=>"abc"
37"abc (with parens)"
38;=>"abc (with parens)"
39"abc\"def"
40;=>"abc\"def"
41;;;"abc\ndef"
42;;;;=>"abc\ndef"
f4c8a091
JM
43""
44;=>""
31690700
JM
45
46
47;; Testing read of lists
48(+ 1 2)
49;=>(+ 1 2)
50((3 4))
51;=>((3 4))
52(+ 1 (+ 2 3))
53;=>(+ 1 (+ 2 3))
54 ( + 1 (+ 2 3 ) )
55;=>(+ 1 (+ 2 3))
01c97316
JM
56(* 1 2)
57;=>(* 1 2)
58(** 1 2)
59;=>(** 1 2)
31690700 60
abdd56eb
JM
61;; Test commas as whitespace
62(1 2, 3,,,,),,
63;=>(1 2 3)
64
f5223195
JM
65;; Testing read of quoting
66'1
67;=>(quote 1)
68'(1 2 3)
69;=>(quote (1 2 3))
70`1
71;=>(quasiquote 1)
72`(1 2 3)
73;=>(quasiquote (1 2 3))
74~1
75;=>(unquote 1)
76~(1 2 3)
77;=>(unquote (1 2 3))
78~@(1 2 3)
79;=>(splice-unquote (1 2 3))
80
4ee7c0f2
JM
81;;
82;; Testing reader errors
83;;; TODO: fix these so they fail correctly
84(1 2
85; expected ')', got EOF
86[1 2
87; expected ']', got EOF
88"abc
89; expected '"', got EOF
90
91;;
92;; -------- Optional Functionality --------
93
b8ee29b2
JM
94;; Testing keywords
95:kw
96;=>:kw
97(:kw1 :kw2 :kw3)
98;=>(:kw1 :kw2 :kw3)
99
31690700
JM
100;; Testing read of vectors
101[+ 1 2]
102;=>[+ 1 2]
103[[3 4]]
104;=>[[3 4]]
105[+ 1 [+ 2 3]]
106;=>[+ 1 [+ 2 3]]
107 [ + 1 [+ 2 3 ] ]
108;=>[+ 1 [+ 2 3]]
109
31690700
JM
110;; Testing read of hash maps
111{"abc" 1}
112;=>{"abc" 1}
113{"a" {"b" 2}}
114;=>{"a" {"b" 2}}
115{"a" {"b" {"c" 3}}}
116;=>{"a" {"b" {"c" 3}}}
117{ "a" {"b" { "cde" 3 } }}
118;=>{"a" {"b" {"cde" 3}}}
f6a4ddf7 119{ :a {:b { :cde 3 } }}
b8ee29b2 120;=>{:a {:b {:cde 3}}}
31690700 121
9af8aee6
JM
122;; Testing read of comments
123 ;; whole line comment (not an exception)
1241 ; comment after expression
125;=>1
1261; comment after expression
127;=>1
31690700 128
31690700
JM
129;; Testing read of ^/metadata
130^{"a" 1} [1 2 3]
131;=>(with-meta [1 2 3] {"a" 1})
132
133
134;; Testing read of @/deref
135@a
136;=>(deref a)