Commit | Line | Data |
---|---|---|
31690700 JM |
1 | ;; Testing read of numbers |
2 | 1 | |
3 | ;=>1 | |
4 | 7 | |
5 | ;=>7 | |
6 | 7 | |
7 | ;=>7 | |
2c1eb1af DM |
8 | -123 |
9 | ;=>-123 | |
31690700 JM |
10 | |
11 | ||
12 | ;; Testing read of symbols | |
13 | + | |
14 | ;=>+ | |
15 | abc | |
16 | ;=>abc | |
17 | abc | |
18 | ;=>abc | |
19 | abc5 | |
20 | ;=>abc5 | |
21 | abc-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) | |
31690700 | 53 | |
abdd56eb JM |
54 | ;; Test commas as whitespace |
55 | (1 2, 3,,,,),, | |
56 | ;=>(1 2 3) | |
57 | ||
46e25689 | 58 | |
a1eb30fc | 59 | ;>>> deferrable=True |
46e25689 JM |
60 | |
61 | ;; | |
a1eb30fc | 62 | ;; -------- Deferrable Functionality -------- |
46e25689 JM |
63 | |
64 | ;; Testing read of nil/true/false | |
65 | nil | |
66 | ;=>nil | |
67 | true | |
68 | ;=>true | |
69 | false | |
70 | ;=>false | |
71 | ||
72 | ;; Testing read of strings | |
73 | "abc" | |
74 | ;=>"abc" | |
75 | "abc" | |
76 | ;=>"abc" | |
77 | "abc (with parens)" | |
78 | ;=>"abc (with parens)" | |
79 | "abc\"def" | |
80 | ;=>"abc\"def" | |
81 | ;;;"abc\ndef" | |
82 | ;;;;=>"abc\ndef" | |
83 | "" | |
84 | ;=>"" | |
85 | ||
86 | ;; Testing reader errors | |
46e25689 | 87 | (1 2 |
f6f5d4f2 | 88 | ;/.*(EOF|end of input|unbalanced).* |
46e25689 | 89 | [1 2 |
f6f5d4f2 JM |
90 | ;/.*(EOF|end of input|unbalanced).* |
91 | ||
92 | ;;; These should throw some error with no return value | |
46e25689 | 93 | "abc |
4aa0ebdf | 94 | ;/.*(EOF|end of input|unbalanced).* |
46e25689 | 95 | (1 "abc |
4aa0ebdf | 96 | ;/.*(EOF|end of input|unbalanced).* |
f6f5d4f2 | 97 | (1 "abc" |
4aa0ebdf | 98 | ;/.*(EOF|end of input|unbalanced).* |
46e25689 | 99 | |
f5223195 JM |
100 | ;; Testing read of quoting |
101 | '1 | |
102 | ;=>(quote 1) | |
103 | '(1 2 3) | |
104 | ;=>(quote (1 2 3)) | |
105 | `1 | |
106 | ;=>(quasiquote 1) | |
107 | `(1 2 3) | |
108 | ;=>(quasiquote (1 2 3)) | |
109 | ~1 | |
110 | ;=>(unquote 1) | |
111 | ~(1 2 3) | |
112 | ;=>(unquote (1 2 3)) | |
9e8f5211 JM |
113 | `(1 ~a 3) |
114 | ;=>(quasiquote (1 (unquote a) 3)) | |
f5223195 JM |
115 | ~@(1 2 3) |
116 | ;=>(splice-unquote (1 2 3)) | |
117 | ||
4ee7c0f2 | 118 | |
46e25689 | 119 | ;>>> optional=True |
4ee7c0f2 JM |
120 | ;; |
121 | ;; -------- Optional Functionality -------- | |
122 | ||
b8ee29b2 JM |
123 | ;; Testing keywords |
124 | :kw | |
125 | ;=>:kw | |
126 | (:kw1 :kw2 :kw3) | |
127 | ;=>(:kw1 :kw2 :kw3) | |
128 | ||
31690700 JM |
129 | ;; Testing read of vectors |
130 | [+ 1 2] | |
131 | ;=>[+ 1 2] | |
a7ed71b9 JM |
132 | [] |
133 | ;=>[] | |
f7983f72 BH |
134 | [ ] |
135 | ;=>[] | |
31690700 JM |
136 | [[3 4]] |
137 | ;=>[[3 4]] | |
138 | [+ 1 [+ 2 3]] | |
139 | ;=>[+ 1 [+ 2 3]] | |
140 | [ + 1 [+ 2 3 ] ] | |
141 | ;=>[+ 1 [+ 2 3]] | |
142 | ||
31690700 | 143 | ;; Testing read of hash maps |
f7983f72 BH |
144 | {} |
145 | ;=>{} | |
f0338adf BH |
146 | { } |
147 | ;=>{} | |
31690700 JM |
148 | {"abc" 1} |
149 | ;=>{"abc" 1} | |
150 | {"a" {"b" 2}} | |
151 | ;=>{"a" {"b" 2}} | |
152 | {"a" {"b" {"c" 3}}} | |
153 | ;=>{"a" {"b" {"c" 3}}} | |
154 | { "a" {"b" { "cde" 3 } }} | |
155 | ;=>{"a" {"b" {"cde" 3}}} | |
f6a4ddf7 | 156 | { :a {:b { :cde 3 } }} |
b8ee29b2 | 157 | ;=>{:a {:b {:cde 3}}} |
31690700 | 158 | |
9af8aee6 JM |
159 | ;; Testing read of comments |
160 | ;; whole line comment (not an exception) | |
161 | 1 ; comment after expression | |
162 | ;=>1 | |
163 | 1; comment after expression | |
164 | ;=>1 | |
31690700 | 165 | |
31690700 JM |
166 | ;; Testing read of ^/metadata |
167 | ^{"a" 1} [1 2 3] | |
168 | ;=>(with-meta [1 2 3] {"a" 1}) | |
169 | ||
170 | ||
171 | ;; Testing read of @/deref | |
172 | @a | |
173 | ;=>(deref a) |