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 | ||
24 | ||
31690700 JM |
25 | ;; Testing read of lists |
26 | (+ 1 2) | |
27 | ;=>(+ 1 2) | |
a7ed71b9 JM |
28 | () |
29 | ;=>() | |
9e8f5211 JM |
30 | (nil) |
31 | ;=>(nil) | |
31690700 JM |
32 | ((3 4)) |
33 | ;=>((3 4)) | |
34 | (+ 1 (+ 2 3)) | |
35 | ;=>(+ 1 (+ 2 3)) | |
36 | ( + 1 (+ 2 3 ) ) | |
37 | ;=>(+ 1 (+ 2 3)) | |
01c97316 JM |
38 | (* 1 2) |
39 | ;=>(* 1 2) | |
40 | (** 1 2) | |
41 | ;=>(** 1 2) | |
2c1eb1af DM |
42 | (* -3 6) |
43 | ;=>(* -3 6) | |
31690700 | 44 | |
abdd56eb JM |
45 | ;; Test commas as whitespace |
46 | (1 2, 3,,,,),, | |
47 | ;=>(1 2 3) | |
48 | ||
46e25689 | 49 | |
a1eb30fc | 50 | ;>>> deferrable=True |
46e25689 JM |
51 | |
52 | ;; | |
a1eb30fc | 53 | ;; -------- Deferrable Functionality -------- |
46e25689 JM |
54 | |
55 | ;; Testing read of nil/true/false | |
56 | nil | |
57 | ;=>nil | |
58 | true | |
59 | ;=>true | |
60 | false | |
61 | ;=>false | |
62 | ||
63 | ;; Testing read of strings | |
64 | "abc" | |
65 | ;=>"abc" | |
66 | "abc" | |
67 | ;=>"abc" | |
68 | "abc (with parens)" | |
69 | ;=>"abc (with parens)" | |
70 | "abc\"def" | |
71 | ;=>"abc\"def" | |
72 | ;;;"abc\ndef" | |
73 | ;;;;=>"abc\ndef" | |
74 | "" | |
75 | ;=>"" | |
76 | ||
77 | ;; Testing reader errors | |
78 | ;;; TODO: fix these so they fail correctly | |
79 | (1 2 | |
80 | ; expected ')', got EOF | |
81 | [1 2 | |
82 | ; expected ']', got EOF | |
83 | "abc | |
84 | ; expected '"', got EOF | |
85 | (1 "abc | |
86 | ; expected ')', got EOF | |
87 | ||
f5223195 JM |
88 | ;; Testing read of quoting |
89 | '1 | |
90 | ;=>(quote 1) | |
91 | '(1 2 3) | |
92 | ;=>(quote (1 2 3)) | |
93 | `1 | |
94 | ;=>(quasiquote 1) | |
95 | `(1 2 3) | |
96 | ;=>(quasiquote (1 2 3)) | |
97 | ~1 | |
98 | ;=>(unquote 1) | |
99 | ~(1 2 3) | |
100 | ;=>(unquote (1 2 3)) | |
9e8f5211 JM |
101 | `(1 ~a 3) |
102 | ;=>(quasiquote (1 (unquote a) 3)) | |
f5223195 JM |
103 | ~@(1 2 3) |
104 | ;=>(splice-unquote (1 2 3)) | |
105 | ||
4ee7c0f2 | 106 | |
46e25689 | 107 | ;>>> optional=True |
4ee7c0f2 JM |
108 | ;; |
109 | ;; -------- Optional Functionality -------- | |
110 | ||
b8ee29b2 JM |
111 | ;; Testing keywords |
112 | :kw | |
113 | ;=>:kw | |
114 | (:kw1 :kw2 :kw3) | |
115 | ;=>(:kw1 :kw2 :kw3) | |
116 | ||
31690700 JM |
117 | ;; Testing read of vectors |
118 | [+ 1 2] | |
119 | ;=>[+ 1 2] | |
a7ed71b9 JM |
120 | [] |
121 | ;=>[] | |
31690700 JM |
122 | [[3 4]] |
123 | ;=>[[3 4]] | |
124 | [+ 1 [+ 2 3]] | |
125 | ;=>[+ 1 [+ 2 3]] | |
126 | [ + 1 [+ 2 3 ] ] | |
127 | ;=>[+ 1 [+ 2 3]] | |
128 | ||
31690700 JM |
129 | ;; Testing read of hash maps |
130 | {"abc" 1} | |
131 | ;=>{"abc" 1} | |
132 | {"a" {"b" 2}} | |
133 | ;=>{"a" {"b" 2}} | |
134 | {"a" {"b" {"c" 3}}} | |
135 | ;=>{"a" {"b" {"c" 3}}} | |
136 | { "a" {"b" { "cde" 3 } }} | |
137 | ;=>{"a" {"b" {"cde" 3}}} | |
f6a4ddf7 | 138 | { :a {:b { :cde 3 } }} |
b8ee29b2 | 139 | ;=>{:a {:b {:cde 3}}} |
31690700 | 140 | |
9af8aee6 JM |
141 | ;; Testing read of comments |
142 | ;; whole line comment (not an exception) | |
143 | 1 ; comment after expression | |
144 | ;=>1 | |
145 | 1; comment after expression | |
146 | ;=>1 | |
31690700 | 147 | |
31690700 JM |
148 | ;; Testing read of ^/metadata |
149 | ^{"a" 1} [1 2 3] | |
150 | ;=>(with-meta [1 2 3] {"a" 1}) | |
151 | ||
152 | ||
153 | ;; Testing read of @/deref | |
154 | @a | |
155 | ;=>(deref a) |