source: trunk/source/tests/ansi-tests/read-suppress.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 11 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 11.4 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sat Jan 15 13:55:27 2005
4;;;; Contains: Tests of reading with *READ-SUPPRESS* bound to true
5
6(in-package :cl-test)
7
8(compile-and-load "reader-aux.lsp")
9
10(defmacro def-read-suppress-test (name string)
11  `(def-syntax-test ,name
12     (let ((*read-suppress* t))
13       (read-from-string ,string))
14     nil ,(length string)))
15
16(def-read-suppress-test read-suppress.1  "NONEXISTENT-PACKAGE::FOO")
17(def-read-suppress-test read-suppress.2  ":")
18(def-read-suppress-test read-suppress.3 "::")
19(def-read-suppress-test read-suppress.4 ":::")
20(def-read-suppress-test read-suppress.5 "123.45")
21;; (def-read-suppress-test read-suppress.6 ".")
22(def-read-suppress-test read-suppress.7 "..")
23(def-read-suppress-test read-suppress.8 "...")
24(def-read-suppress-test read-suppress.9 "(1 2)")
25(def-read-suppress-test read-suppress.10 "(1 . 2)")
26(def-read-suppress-test read-suppress.11 "(1 .. 2 . 3)")
27(def-read-suppress-test read-suppress.12 "(...)")
28
29(defparameter *non-macro-chars*
30  "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-=+_~!@$%^&*{}[]<>/?.")
31
32(declaim (type simple-base-string *non-macro-chars*))
33
34(defmacro def-random-suppress-test (name &key
35                                         (chars '*non-macro-chars*)
36                                         (reps 1000)
37                                         (maxlen 8)
38                                         (count 10)
39                                         (prefix "")
40                                         (suffix ""))
41  `(def-syntax-test ,name
42     (let* ((chars ,chars)
43            (prefix ,prefix)
44            (suffix ,suffix)
45            (*read-suppress* t)
46            (count 0)
47            (maxlen ,maxlen)
48            (reps ,reps)
49            (maxcount ,count))
50       (loop for n = (1+ (random maxlen))
51             for s = (concatenate 'string
52                                  prefix
53                                  (loop repeat n
54                                        collect (random-from-seq chars))
55                                  suffix)
56             for vals = (multiple-value-list
57                         (handler-case (read-from-string s)
58                                       (reader-error (rc) rc)))
59             repeat reps
60             unless (equal vals (list nil (length s)))
61             collect (progn (when (> (incf count) maxcount)
62                              (loop-finish))
63                            (list n s vals))))
64     nil))                                       
65
66(def-random-suppress-test read-suppress.13)
67(def-random-suppress-test read-suppress.14 :prefix "(" :suffix ")")
68(def-random-suppress-test read-suppress.15 :prefix "#(" :suffix ")")
69(def-random-suppress-test read-suppress.16 :chars "0123456789.eEfFsSdDlL+-")
70
71(def-read-suppress-test read-suppress.sharp-slash.1 "#\\boguscharname")
72(def-read-suppress-test read-suppress.sharp-slash.2 "#\\:x")
73(def-read-suppress-test read-suppress.sharp-slash.3 "#\\::::")
74(def-read-suppress-test read-suppress.sharp-slash.4 "#\\123")
75(def-read-suppress-test read-suppress.sharp-slash.5 "#0\\ ")
76(def-read-suppress-test read-suppress.sharp-slash.6 "#100000000\\Space")
77
78(def-read-suppress-test read-suppress.sharp-quote.1 "#'foo")
79(def-read-suppress-test read-suppress.sharp-quote.2 "#'1")
80(def-read-suppress-test read-suppress.sharp-quote.3 "#'(setf bar)")
81(def-read-suppress-test read-suppress.sharp-quote.5 "#'.")
82(def-read-suppress-test read-suppress.sharp-quote.6 "#'1.2.3")
83(def-read-suppress-test read-suppress.sharp-quote.7 "#0'F")
84(def-read-suppress-test read-suppress.sharp-quote.8 "#1000000'F")
85
86(def-read-suppress-test read-suppress.sharp-left-paren.1 "#()")
87(def-read-suppress-test read-suppress.sharp-left-paren.2 "#(A)")
88(def-read-suppress-test read-suppress.sharp-left-paren.3 "#(A B)")
89(def-read-suppress-test read-suppress.sharp-left-paren.4 "#0()")
90(def-read-suppress-test read-suppress.sharp-left-paren.5 "#0(A)")
91(def-read-suppress-test read-suppress.sharp-left-paren.6 "#1(A)")
92(def-read-suppress-test read-suppress.sharp-left-paren.7 "#1(A B C D E)")
93(def-read-suppress-test read-suppress.sharp-left-paren.8 "#4(A B C D E)")
94(def-read-suppress-test read-suppress.sharp-left-paren.9 "#10(A B C D E)")
95(def-read-suppress-test read-suppress.sharp-left-paren.10 "#100()")
96(def-read-suppress-test read-suppress.sharp-left-paren.11 "#10000000000000()")
97(def-read-suppress-test read-suppress.sharp-left-paren.12 "#10000000000000(A)")
98
99(def-read-suppress-test read-suppress.sharp-asterisk.1 "#*")
100(def-read-suppress-test read-suppress.sharp-asterisk.2 "#0*")
101(def-read-suppress-test read-suppress.sharp-asterisk.3 "#*1")
102(def-read-suppress-test read-suppress.sharp-asterisk.4 "#*0111001")
103(def-read-suppress-test read-suppress.sharp-asterisk.5 "#*73298723497132")
104(def-read-suppress-test read-suppress.sharp-asterisk.6
105  "#*abcdefghijklmnopqrstuvwxyz")
106(def-read-suppress-test read-suppress.sharp-asterisk.7
107  "#*ABCDEFGHIJKLMNOPQRSTUVWXYZ")
108(def-read-suppress-test read-suppress.sharp-asterisk.8 "#*:")
109(def-read-suppress-test read-suppress.sharp-asterisk.9 "#*::::")
110(def-read-suppress-test read-suppress.sharp-asterisk.10 "#1*")
111(def-read-suppress-test read-suppress.sharp-asterisk.11 "#10000*")
112(def-read-suppress-test read-suppress.sharp-asterisk.12 "#10000000000000*")
113(def-read-suppress-test read-suppress.sharp-asterisk.13 "#4*001101001")
114(def-read-suppress-test read-suppress.sharp-asterisk.14 "#2*")
115
116(def-read-suppress-test read-suppress.sharp-colon.1 "#:1")
117(def-read-suppress-test read-suppress.sharp-colon.2 "#:foo")
118(def-read-suppress-test read-suppress.sharp-colon.3 "#0:1/2")
119(def-read-suppress-test read-suppress.sharp-colon.4 "#10:-2")
120(def-read-suppress-test read-suppress.sharp-colon.5 "#100000000000:x")
121(def-read-suppress-test read-suppress.sharp-colon.6 "#3:foo")
122(def-read-suppress-test read-suppress.sharp-colon.7 "#::")
123(def-read-suppress-test read-suppress.sharp-colon.8 "#:123")
124(def-read-suppress-test read-suppress.sharp-colon.9 "#:.")
125
126(def-read-suppress-test read-suppress.sharp-dot.1 "#.1")
127(def-read-suppress-test read-suppress.sharp-dot.2 "#.#:foo")
128(def-read-suppress-test read-suppress.sharp-dot.3 "#.(throw 'foo nil)")
129(def-read-suppress-test read-suppress.sharp-dot.4 "#0.1")
130(def-read-suppress-test read-suppress.sharp-dot.5 "#10.1")
131(def-read-suppress-test read-suppress.sharp-dot.6 "#1000000000000000.1")
132
133(def-read-suppress-test read-suppress.sharp-b.1 "#b0")
134(def-read-suppress-test read-suppress.sharp-b.2 "#B1")
135(def-read-suppress-test read-suppress.sharp-b.3 "#BX")
136(def-read-suppress-test read-suppress.sharp-b.4 "#b.")
137(def-read-suppress-test read-suppress.sharp-b.5 "#0b0")
138(def-read-suppress-test read-suppress.sharp-b.6 "#1B1")
139(def-read-suppress-test read-suppress.sharp-b.7 "#100b010")
140(def-read-suppress-test read-suppress.sharp-b.8 "#1000000000000b010")
141(def-read-suppress-test read-suppress.sharp-b.9 "#B101/100")
142(def-read-suppress-test read-suppress.sharp-b.10 "#b101/100/11")
143
144(def-read-suppress-test read-suppress.sharp-o.1 "#o0")
145(def-read-suppress-test read-suppress.sharp-o.2 "#O1")
146(def-read-suppress-test read-suppress.sharp-o.3 "#OX")
147(def-read-suppress-test read-suppress.sharp-o.4 "#o.")
148(def-read-suppress-test read-suppress.sharp-o.5 "#od6")
149(def-read-suppress-test read-suppress.sharp-o.6 "#1O9")
150(def-read-suppress-test read-suppress.sharp-o.7 "#100O010")
151(def-read-suppress-test read-suppress.sharp-o.8 "#1000000000000o27423")
152(def-read-suppress-test read-suppress.sharp-o.9 "#O123/457")
153(def-read-suppress-test read-suppress.sharp-o.10 "#o12/17/21")
154
155(def-read-suppress-test read-suppress.sharp-c.1 "#c(0 0)")
156(def-read-suppress-test read-suppress.sharp-c.2 "#C(1.0 1.0)")
157(def-read-suppress-test read-suppress.sharp-c.3 "#cFOO")
158(def-read-suppress-test read-suppress.sharp-c.4 "#c1")
159(def-read-suppress-test read-suppress.sharp-c.5 "#C(1 2 3)")
160(def-read-suppress-test read-suppress.sharp-c.6 "#c.")
161(def-read-suppress-test read-suppress.sharp-c.7 "#c()")
162(def-read-suppress-test read-suppress.sharp-c.8 "#c(1)")
163(def-read-suppress-test read-suppress.sharp-c.9 "#C(1 . 2)")
164(def-read-suppress-test read-suppress.sharp-c.10 "#c(1 2 3)")
165(def-read-suppress-test read-suppress.sharp-c.11 "#0c(1 2)")
166(def-read-suppress-test read-suppress.sharp-c.12 "#1C(1 2)")
167(def-read-suppress-test read-suppress.sharp-c.13 "#10c(1 2)")
168(def-read-suppress-test read-suppress.sharp-c.14 "#123456789c(1 2)")
169(def-read-suppress-test read-suppress.sharp-c.15 "#c(..)")
170
171(def-read-suppress-test read-suppress.sharp-x.1 "#x0")
172(def-read-suppress-test read-suppress.sharp-x.2 "#X1")
173(def-read-suppress-test read-suppress.sharp-x.3 "#XX")
174(def-read-suppress-test read-suppress.sharp-x.4 "#x.")
175(def-read-suppress-test read-suppress.sharp-x.5 "#xy6")
176(def-read-suppress-test read-suppress.sharp-x.6 "#1X9")
177(def-read-suppress-test read-suppress.sharp-x.7 "#100X010")
178(def-read-suppress-test read-suppress.sharp-x.8 "#1000000000000x2af23")
179(def-read-suppress-test read-suppress.sharp-x.9 "#X123/DE7")
180(def-read-suppress-test read-suppress.sharp-x.10 "#x12/17/21")
181
182(def-read-suppress-test read-suppress.sharp-r.1 "#2r1101")
183(def-read-suppress-test read-suppress.sharp-r.2 "#10R9871")
184(def-read-suppress-test read-suppress.sharp-r.3 "#36r721zwoqnASLDKJA22")
185(def-read-suppress-test read-suppress.sharp-r.4 "#r.")
186(def-read-suppress-test read-suppress.sharp-r.5 "#2r379ze")
187(def-read-suppress-test read-suppress.sharp-r.6 "#0r0")
188(def-read-suppress-test read-suppress.sharp-r.7 "#1r0")
189(def-read-suppress-test read-suppress.sharp-r.8 "#100r0A")
190(def-read-suppress-test read-suppress.sharp-r.9 "#1000000000000r0A")
191(def-read-suppress-test read-suppress.sharp-r.10 "#2r!@#$%^&*_-+={}[]:<>.?/")
192
193(def-read-suppress-test read-suppress.sharp-a.1 "#a()")
194(def-read-suppress-test read-suppress.sharp-a.2 "#2a((a)(b c))")
195(def-read-suppress-test read-suppress.sharp-a.3 "#a1")
196(def-read-suppress-test read-suppress.sharp-a.4 "#1a1")
197(def-read-suppress-test read-suppress.sharp-a.5 "#10a(a b c)")
198(def-read-suppress-test read-suppress.sharp-a.6 "#100a(a b c)")
199(def-read-suppress-test read-suppress.sharp-a.7 "#10000000000000a(a b c)")
200(def-read-suppress-test read-suppress.sharp-a.8 "#a..")
201(def-read-suppress-test read-suppress.sharp-a.9 "#a(...)")
202
203(def-read-suppress-test read-suppress.sharp-s.1 "#s()")
204(def-read-suppress-test read-suppress.sharp-s.2 "#S(invalid-sname)")
205(def-read-suppress-test read-suppress.sharp-s.3 "#s(..)")
206(def-read-suppress-test read-suppress.sharp-s.4 "#S(foo bar)")
207(def-read-suppress-test read-suppress.sharp-s.5 "#0s()")
208(def-read-suppress-test read-suppress.sharp-s.6 "#1S()")
209(def-read-suppress-test read-suppress.sharp-s.7 "#10s()")
210(def-read-suppress-test read-suppress.sharp-s.8 "#271S()")
211(def-read-suppress-test read-suppress.sharp-s.9 "#712897459812s()")
212
213(def-read-suppress-test read-suppress.sharp-p.1 "#p\"\"")
214(def-read-suppress-test read-suppress.sharp-p.2 "#P123")
215(def-read-suppress-test read-suppress.sharp-p.3 "#p1/3")
216(def-read-suppress-test read-suppress.sharp-p.4 "#0P\"\"")
217(def-read-suppress-test read-suppress.sharp-p.5 "#1p\"\"")
218(def-read-suppress-test read-suppress.sharp-p.6 "#100P\"\"")
219(def-read-suppress-test read-suppress.sharp-p.7 "#1234567890p\"\"")
220
221(def-read-suppress-test read-suppress.sharp-equal.1 "#=nil")
222(def-read-suppress-test read-suppress.sharp-equal.2 "#1=nil")
223(def-read-suppress-test read-suppress.sharp-equal.3 "#100=nil")
224(def-read-suppress-test read-suppress.sharp-equal.4 "(#1=nil #1=nil)")
225
226(def-read-suppress-test read-suppress.sharp-sharp.1 "##")
227(def-read-suppress-test read-suppress.sharp-sharp.2 "#1#")
228(def-read-suppress-test read-suppress.sharp-sharp.3 "#100#")
229(def-read-suppress-test read-suppress.sharp-sharp.4 "#123456789#")
230
231;;; Error cases
232
233(def-syntax-test read-suppress.error.1
234  (signals-error (let ((*read-suppress* t)) (read-from-string "')"))
235                 reader-error)
236  t)
237
238(def-syntax-test read-suppress.error.2
239  (signals-error (let ((*read-suppress* t)) (read-from-string "#<"))
240                 reader-error)
241  t)
242
243(def-syntax-test read-suppress.error.3
244  (signals-error (let ((*read-suppress* t)) (read-from-string "# "))
245                 reader-error)
246  t)
247
248(def-syntax-test read-suppress.error.4
249  (signals-error (let ((*read-suppress* t)) (read-from-string "#)"))
250                 reader-error)
251  t)
Note: See TracBrowser for help on using the repository browser.