source: trunk/source/tests/ansi-tests/format-logical-block.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: 7.5 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sun Aug  8 12:17:31 2004
4;;;; Contains: Tests of the ~< ~:> format directives
5
6(in-package :cl-test)
7
8(compile-and-load "printer-aux.lsp")
9
10;;; Error cases
11
12;;; Prefix and suffix cannot contain format directives
13
14(deftest format.logical-block.error.1
15  (signals-error-always (format nil "~<foo~A~;~A~;bar~:>" '(X) '(Y)) error)
16  t t)
17
18(deftest format.logical-block.error.2
19  (signals-error-always (format nil "~<foo~A~@;~A~;bar~:>" '(X) '(Y)) error)
20  t t)
21
22(deftest format.logical-block.error.3
23  (signals-error-always (format nil "~<foo~;~A~;bar~A~:>" '(X) '(Y)) error)
24  t t)
25
26(deftest format.logical-block.error.4
27  (signals-error-always (format nil "~<foo~@;~A~;bar~A~:>" '(X) '(Y)) error)
28  t t)
29
30(deftest format.logical-block.error.5
31  (signals-error-always (format nil "~<foo~A~;~A~:>" '(X) '(Y)) error)
32  t t)
33
34(deftest format.logical-block.error.6
35  (signals-error-always (format nil "~<foo~A~@;~A~:>" '(X) '(Y)) error)
36  t t)
37
38(deftest format.logical-block.error.7
39  (signals-error-always (format nil "~<~;~A~;bar~A~:>" '(X) '(Y)) error)
40  t t)
41
42(deftest format.logical-block.error.8
43  (signals-error-always (format nil "~<~@;~A~;bar~A~:>" '(X) '(Y)) error)
44  t t)
45
46(deftest format.logical-block.error.9
47  (signals-error-always (format nil "~:<foo~A~;~A~;bar~:>" '(X) '(Y)) error)
48  t t)
49
50(deftest format.logical-block.error.10
51  (signals-error-always (format nil "~:<foo~A~@;~A~;bar~:>" '(X) '(Y)) error)
52  t t)
53
54(deftest format.logical-block.error.11
55  (signals-error-always (format nil "~:<foo~;~A~;bar~A~:>" '(X) '(Y)) error)
56  t t)
57
58(deftest format.logical-block.error.12
59  (signals-error-always (format nil "~:<foo~@;~A~;bar~A~:>" '(X) '(Y)) error)
60  t t)
61
62(deftest format.logical-block.error.13
63  (signals-error-always (format nil "~:<foo~A~;~A~:>" '(X) '(Y)) error)
64  t t)
65
66(deftest format.logical-block.error.14
67  (signals-error-always (format nil "~:<foo~A~@;~A~:>" '(X) '(Y)) error)
68  t t)
69
70(deftest format.logical-block.error.15
71  (signals-error-always (format nil "~:<~;~A~;bar~A~:>" '(X) '(Y)) error)
72  t t)
73
74(deftest format.logical-block.error.16
75  (signals-error-always (format nil "~:<~@;~A~;bar~A~:>" '(X) '(Y)) error)
76  t t)
77
78(deftest format.logical-block.error.17
79  (signals-error-always (format nil "~@<foo~A~;~A~;bar~:>" '(X) '(Y)) error)
80  t t)
81
82(deftest format.logical-block.error.18
83  (signals-error-always (format nil "~@<foo~A~@;~A~;bar~:>" '(X) '(Y)) error)
84  t t)
85
86(deftest format.logical-block.error.19
87  (signals-error-always (format nil "~@<foo~;~A~;bar~A~:>" '(X) '(Y)) error)
88  t t)
89
90(deftest format.logical-block.error.20
91  (signals-error-always (format nil "~@<foo~@;~A~;bar~A~:>" '(X) '(Y)) error)
92  t t)
93
94(deftest format.logical-block.error.21
95  (signals-error-always (format nil "~@<foo~A~;~A~:>" '(X) '(Y)) error)
96  t t)
97
98(deftest format.logical-block.error.22
99  (signals-error-always (format nil "~@<foo~A~@;~A~:>" '(X) '(Y)) error)
100  t t)
101
102(deftest format.logical-block.error.23
103  (signals-error-always (format nil "~@<~;~A~;bar~A~:>" '(X) '(Y)) error)
104  t t)
105
106(deftest format.logical-block.error.24
107  (signals-error-always (format nil "~@<~@;~A~;bar~A~:>" '(X) '(Y)) error)
108  t t)
109
110(deftest format.logical-block.error.25
111  (signals-error-always (format nil "1~<X~<Y~:>Z~>2" nil nil nil) error)
112  t t)
113
114;;; "an error is also signaled if the ~<...~:;...~> form of ~<...~> is used
115;;; in the same format string with ~W, ~_, ~<...~:>, ~I, or ~:T."
116
117(deftest format.logical-block.error.26
118  (signals-error-always (format nil "~<~:;~>~<~:>" nil nil nil) error)
119  t t)
120
121(deftest format.logical-block.error.27
122  (signals-error-always (format nil "~<~:>~<~:;~>" nil nil nil) error)
123  t t)
124
125;;; Non-error tests
126
127(def-pprint-test format.logical-block.1
128  (format nil "~<~A~:>" '(nil))
129  "NIL")
130
131(def-pprint-test format.logical-block.2
132  (format nil "~@<~A~:>" nil)
133  "NIL")
134
135(def-pprint-test format.logical-block.3
136  (format nil "~:<~A~:>" '(nil))
137  "(NIL)")
138
139(def-pprint-test format.logical-block.4
140  (format nil "~:@<~A~:>" nil)
141  "(NIL)")
142
143(def-pprint-test format.logical-block.5
144  (format nil "~@:<~A~:>" nil)
145  "(NIL)")
146
147(def-pprint-test format.logical-block.6
148  (format nil "~<~@{~A~^*~}~:>" '(1 2 3))
149  "1*2*3")
150
151(def-pprint-test format.logical-block.7
152  (format nil "~:<~@{~A~^*~}~:>" '(1 2 3))
153  "(1*2*3)")
154
155(def-pprint-test format.logical-block.8
156  (format nil "~:<~@{~A~^*~}~:>" 1)
157  "1")
158
159(def-pprint-test format.logical-block.9
160  (format nil "~<~;~A~;~:>" '(1 2 3))
161  "1")
162
163(def-pprint-test format.logical-block.10
164  (format nil "~<~;~A~:>" '(1 2 3))
165  "1")
166
167(def-pprint-test format.logical-block.11
168  (format nil "~@<~;~A~;~:>" '(1 2 3))
169  "(1 2 3)")
170
171(def-pprint-test format.logical-block.12
172  (format nil "~@<~;~A~:>" '(1 2 3))
173  "(1 2 3)")
174
175(def-pprint-test format.logical-block.13
176  (format nil "~:<[~;~@{~A~^/~}~:>" '(1 2 3))
177  "[1/2/3)")
178
179(def-pprint-test format.logical-block.14
180  (format nil "~:<~;~@{~A~^/~}~;]~:>" '(1 2 3))
181  "1/2/3]")
182
183(def-pprint-test format.logical-block.15
184  (format nil "~:<[~;~@{~A~^/~}~;]~:>" '(1 2 3))
185  "[1/2/3]")
186
187(def-pprint-test format.logical-block.16
188  (format nil "~@<~@{~A~^*~}~:>" 1 2 3)
189  "1*2*3")
190
191(def-pprint-test format.logical-block.17
192  (format nil "~@<~@{~A~^ ~_~}~:>" 1 2 3)
193  "1 2 3")
194
195(def-pprint-test format.logical-block.18
196  (format nil "~@<~@{~A~^ ~_~}~:>" 1 2 3)
197  "1
1982
1993"
200  :margin 2)
201
202(def-pprint-test format.logical-block.19
203  (format nil "~:@<~@{~A~^ ~_~}~:>" 1 2 3)
204  "(1
205 2
206 3)"
207  :margin 2)
208
209(def-pprint-test format.logical-block.20
210  (format nil "~@:<~@{~A~^ ~}~:>" 1 2 3)
211  "(1 2 3)"
212  :margin 2)
213
214(def-pprint-test format.logical-block.21
215  (format nil "~@:<~@{~A~^ ~:_~}~:>" 1 2 3)
216  "(1
217 2
218 3)"
219  :margin 2)
220
221(def-pprint-test format.logical-block.22
222  (format nil "~:@<~@{~A~^ ~}~:@>" 1 2 3)
223  "(1
224 2
225 3)"
226  :margin 2)
227
228(def-pprint-test format.logical-block.23
229  (format nil "~:@<~@{~A~^/~
230                   ~}~:@>" 1 2 3)
231  "(1/2/3)"
232  :margin 2)
233
234(def-pprint-test format.logical-block.24
235  (format nil "~:@<~@{~A~^            ~:_~}~:>" 1 2 3)
236  "(1
237 2
238 3)"
239  :margin 2)
240
241(def-pprint-test format.logical-block.25
242  (format nil "~:@<~@{~A~^            ~}~:@>" 1 2 3)
243  "(1
244 2
245 3)"
246  :margin 2)
247
248(def-pprint-test format.logical-block.26
249  (format nil "~:@<~@{~A~^~}~:@>" "1 2 3")
250  "(1 2 3)"
251  :margin 2)
252
253(def-pprint-test format.logical-block.27
254  (format nil "~@<**~@;~@{~A~^       ~}~:@>" 1 2 3)
255  "**1
256**2
257**3"
258  :margin 3)
259
260(def-pprint-test format.logical-block.28
261  (format nil "~@<**~@;~@{~A~^       ~}~;XX~:@>" 1 2 3)
262  "**1
263**2
264**3XX"
265  :margin 3)
266
267(def-pprint-test format.logical-block.29
268  (format nil "~:@<**~@;~@{~A~^       ~}~:@>" 1 2 3)
269  "**1
270**2
271**3)"
272  :margin 3)
273
274
275;;; Circularity detection
276
277(def-pprint-test format.logical-block.circle.1
278  (format nil "~:<~@{~A~^ ~}~:>" (let ((x (list 0))) (list x x)))
279  "(#1=(0) #1#)"
280  :circle t)
281
282(def-pprint-test format.logical-block.circle.2
283  (format nil "~:<~@{~A~^ ~}~:>" (let ((x (list 0))) (cons x x)))
284  "(#1=(0) . #1#)"
285  :circle t)
286
287(def-pprint-test format.logical-block.circle.3
288  (format nil "~:<~@{~A~^ ~}~:>" (let ((x (list 0)))
289                                   (setf (cdr x) x)
290                                   x))
291  "#1=(0 . #1#)"
292  :circle t
293  :len 500)
294
295(def-pprint-test format.logical-block.circle.4
296  (format nil "~:<~@{~A~^ ~}~:>" (let ((x (list 0))) (list x x)))
297  "((0) (0))")
298
299(def-pprint-test format.logical-block.circle.5
300  (format nil "~:<~@{~A~^ ~}~:>" (let ((x (list 0))) (cons x x)))
301  "((0) 0)")
302
303;;; ~^ terminates a logical block
304
305(def-pprint-test format.logical-block.escape.1
306  (format nil "~<~A~^xxxx~:>" '(1))
307  "1")
308
309(def-pprint-test format.logical-block.escape.2
310  (format nil "~<~<~A~^xxx~:>yyy~:>" '((1)))
311  "1yyy")
Note: See TracBrowser for help on using the repository browser.