go: update README. Backport Func usage.
[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"
43
44
45;; Testing read of lists
46(+ 1 2)
47;=>(+ 1 2)
48((3 4))
49;=>((3 4))
50(+ 1 (+ 2 3))
51;=>(+ 1 (+ 2 3))
52 ( + 1 (+ 2 3 ) )
53;=>(+ 1 (+ 2 3))
54
31690700
JM
55;; Testing read of vectors
56[+ 1 2]
57;=>[+ 1 2]
58[[3 4]]
59;=>[[3 4]]
60[+ 1 [+ 2 3]]
61;=>[+ 1 [+ 2 3]]
62 [ + 1 [+ 2 3 ] ]
63;=>[+ 1 [+ 2 3]]
64
31690700
JM
65;; Testing read of hash maps
66{"abc" 1}
67;=>{"abc" 1}
68{"a" {"b" 2}}
69;=>{"a" {"b" 2}}
70{"a" {"b" {"c" 3}}}
71;=>{"a" {"b" {"c" 3}}}
72{ "a" {"b" { "cde" 3 } }}
73;=>{"a" {"b" {"cde" 3}}}
74
9af8aee6 75;; Test commas as whitespace
70ea599b
JM
76(1 2, 3,,,,),,
77;=>(1 2 3)
9af8aee6
JM
78
79;;
80;; Testing reader errors
1771ab50 81;;; TODO: fix these so they fail correctly
9af8aee6
JM
82(1 2
83; expected ')', got EOF
84[1 2
85; expected ']', got EOF
86"abc
87; expected '"', got EOF
88
89;;
90;; -------- Optional Functionality --------
91
92;; Testing read of comments
93 ;; whole line comment (not an exception)
941 ; comment after expression
95;=>1
961; comment after expression
97;=>1
31690700
JM
98
99;; Testing read of quoting
100'1
101;=>(quote 1)
102'(1 2 3)
103;=>(quote (1 2 3))
104`1
105;=>(quasiquote 1)
106`(1 2 3)
107;=>(quasiquote (1 2 3))
108~1
109;=>(unquote 1)
110~(1 2 3)
111;=>(unquote (1 2 3))
112~@(1 2 3)
113;=>(splice-unquote (1 2 3))
114
115
116;; Testing read of ^/metadata
117^{"a" 1} [1 2 3]
118;=>(with-meta [1 2 3] {"a" 1})
119
120
121;; Testing read of @/deref
122@a
123;=>(deref a)