source: trunk/source/tests/ansi-tests/format-underscore.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: 6.4 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Wed Aug  4 03:36:50 2004
4;;;; Contains: Tests of the ~_ format directive
5
6(in-package :cl-test)
7
8(compile-and-load "printer-aux.lsp")
9
10(def-ppblock-test format._.1
11  (progn
12    (dotimes (i 2) (write "A ") (pprint-newline :fill))
13    ;; (write "B ") (pprint-newline :linear)
14    (format t "B ~_")
15    (dotimes (i 3) (write "A ") (pprint-newline :fill)))
16  "A A B
17A A A "
18  :margin 10)
19
20(def-ppblock-test format._.2
21  (progn
22   (dotimes (i 2) (write "A ") (pprint-newline :fill))
23   ;; (write "B ") (pprint-newline :linear)
24   (format t "B ~_")
25   (dotimes (i 2) (write "C ") (pprint-newline :fill))
26   (format t "D ~_")
27   (dotimes (i 3) (write "A ") (pprint-newline :fill)))
28  "A A B
29C C D
30A A A "
31  :margin 10)
32
33(def-ppblock-test format._.3
34  (format t "A ~_A ~_A ~_A ~_")
35  "A A A A "
36  :margin 10)
37
38(def-ppblock-test format._.4
39  (format t "A ~_A ~_A ~_A ~_")
40  "A A A A "
41  :margin 10
42  :miser 10)
43
44(def-ppblock-test format._.5
45  (format t "A ~_A ~_A ~_A ~_A ~_A ~_A ~_A ~_A ~_A ~_")
46  "A A A A A A A A A A "
47  :margin 10
48  :pretty nil)
49
50(def-ppblock-test format._.6
51  (dotimes (i 4) (format t "A             ~_"))
52  "A
53A
54A
55A
56"
57  :margin 10)
58
59(def-ppblock-test format._.7
60  (format t "A ~_A ~_A ~_A ~_~%A ~_A ~_A ~_A ~_")
61  "A
62A
63A
64A
65
66A
67A
68A
69A
70"
71  :margin 10)
72
73(def-ppblock-test format._.8
74  (progn
75    (pprint-logical-block (*standard-output* nil)
76                          (format t "A ~_A ~_A ~_A ~_"))
77    (format t "~_")
78    (pprint-logical-block (*standard-output* nil)
79                          (format t "A ~_A ~_A ~_A ~_")))
80  "A A A A
81A A A A "
82  :margin 10)
83
84(deftest format._.9
85  (with-output-to-string
86    (s)
87    (with-standard-io-syntax
88     (let ((*print-readably* nil)
89           (*print-escape* nil)
90           (*print-pretty* t)
91           (*print-right-margin* 4)
92           (*print-miser-width* nil))
93       (format s "A ~_A ~_A ~_A ~_A ~_"))))
94  "A A A A A ")
95
96(deftest formatter._.9
97  (with-standard-io-syntax
98   (let ((*print-readably* nil)
99         (*print-escape* nil)
100         (*print-pretty* t)
101         (*print-right-margin* 4)
102         (*print-miser-width* nil))
103     (formatter-call-to-string
104      (formatter "A ~_A ~_A ~_A ~_A ~_"))))
105  "A A A A A ")
106
107;;; miser
108
109(def-ppblock-test format.@_.1
110  (format t "A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_")
111  "A A A A A A A A A A "
112  :margin 10)
113
114(def-ppblock-test format.@_.2
115  (format t "A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_")
116  "A A A A A A A A A A "
117  :margin 10
118  :miser 0)
119
120(def-ppblock-test format.@_.3
121  (format t "A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_")
122  "A A A A A A A A A A "
123  :margin 10
124  :miser 9)
125
126(def-ppblock-test format.@_.4
127  (format t "A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_")
128  "A
129A
130A
131A
132A
133A
134A
135A
136A
137A
138"
139  :margin 10
140  :miser 10)
141
142(def-ppblock-test format.@_.5
143  (format t "A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_A ~@_")
144  "A A A A A A A A A A "
145  :margin 10
146  :miser 10
147  :pretty nil)
148
149(def-ppblock-test format.@_.6
150  (format t "~%A~@_")
151  "
152A
153"
154  :margin 20
155  :miser 20)
156
157(def-ppblock-test format.@_.7
158  (format t "~@_A~%")
159  "
160A
161"
162  :margin 20
163  :miser 20)
164
165(def-ppblock-test format.@_.8
166  (progn
167    (format t "AAAA ~_")
168    (pprint-logical-block
169     (*standard-output* nil)
170     (format t "A ~@_A ~@_A ~@_A ~@_")))
171  "AAAA
172A A A A "
173  :margin 10
174  :miser 8)
175
176(def-ppblock-test format.@_.9
177  (progn
178    (format t "AAAA ~:@_")
179    (pprint-logical-block
180     (*standard-output* nil)
181     (format t "A ~@_A ~@_A ~@_A ~@_")))
182  "AAAA
183A A A A "
184  :margin 10
185  :miser 8)
186
187(deftest format.@_.10
188  (with-output-to-string
189    (s)
190    (with-standard-io-syntax
191     (let ((*print-readably* nil)
192           (*print-escape* nil)
193           (*print-pretty* t)
194           (*print-right-margin* 4)
195           (*print-miser-width* 4))
196       (format s "A ~@_A ~@_A ~@_A ~@_A ~@_"))))
197  "A A A A A ")
198
199(deftest formatter.@_.10
200  (with-standard-io-syntax
201   (let ((*print-readably* nil)
202         (*print-escape* nil)
203         (*print-pretty* t)
204         (*print-right-margin* 4)
205         (*print-miser-width* 4))
206     (formatter-call-to-string
207      (formatter "A ~@_A ~@_A ~@_A ~@_A ~@_"))))
208  "A A A A A ")
209
210;;; fill
211
212(def-ppblock-test format.\:_.1
213  (format t "A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_")
214  "A A A A A
215A A A A A "
216  :margin 10)
217
218(def-ppblock-test format.\:_.2
219  (format t "A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_")
220  "A A A
221A A A
222A A A
223A "
224  :margin 6)
225
226(def-ppblock-test format.\:_.3
227  (format t "A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_")
228  "A A A
229A A A
230A A A
231A "
232  :margin 7)
233
234(def-ppblock-test format.\:_.4
235  (format t "A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_")
236  "A A A A A
237A A A A A "
238  :margin 10
239  :miser 9)
240
241(def-ppblock-test format.\:_.5
242  (format t "A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_A ~:_")
243  "A
244A
245A
246A
247A
248A
249A
250A
251A
252A
253"
254  :margin 10
255  :miser 10)
256
257(def-ppblock-test format.\:_.6
258  (format t "~W~W~:_~W~W~:_~W~W~:_~W~W~:_~W~W~:_"
259          '(A B) #\Space
260          '(A B) #\Space
261          '(A B) #\Space
262          '(A B) #\Space
263          '(A B) #\Space)
264  "(A B) (A B)
265(A B) (A B)
266(A B) "
267  :margin 12)
268
269(deftest format.\:_.7
270  (with-output-to-string
271    (s)
272    (with-standard-io-syntax
273     (let ((*print-readably* nil)
274           (*print-escape* nil)
275           (*print-right-margin* 4)
276           (*print-pretty* t)
277           (*print-miser-width* nil))
278       (format s "A ~:_A ~:_A ~:_A ~:_A ~:_"))))
279  "A A A A A ")
280
281(deftest formatter.\:_.7
282  (with-standard-io-syntax
283   (let ((*print-readably* nil)
284         (*print-escape* nil)
285         (*print-right-margin* 4)
286         (*print-pretty* t)
287         (*print-miser-width* nil))
288     (formatter-call-to-string
289      (formatter "A ~:_A ~:_A ~:_A ~:_A ~:_"))))
290  "A A A A A ")
291
292;;; mandatory
293
294(def-ppblock-test format.\:@_.1
295  (format t "A ~:@_A ~:@_A ~:@_A ~:@_")
296  "A
297A
298A
299A
300")
301
302(def-ppblock-test format.\:@_.2
303  (format t "A ~@:_A ~@:_A ~@:_A ~@:_")
304  "A
305A
306A
307A
308"
309  :margin 10)
310
311(def-ppblock-test format.\:@_.3
312  (format t "A ~@:_A ")
313  "A
314A "
315  :margin 1)
316
317(def-ppblock-test format.\:@_.4
318  (format t "A ~@:_A ~@:_A ~@:_A ~@:_")
319  "A A A A "
320  :pretty nil)
321
322(deftest format.\:@_.5
323  (with-output-to-string
324    (s)
325    (with-standard-io-syntax
326     (let ((*print-readably* nil)
327           (*print-escape* nil)
328           (*print-pretty* t)
329           (*print-right-margin* 4)
330           (*print-miser-width* nil))
331       (format s "A ~:@_A ~:@_A ~:@_A ~:@_A ~:@_"))))
332  "A A A A A ")
333
334(deftest formatter.\:@_.5
335  (with-standard-io-syntax
336   (let ((*print-readably* nil)
337         (*print-escape* nil)
338         (*print-pretty* t)
339         (*print-right-margin* 4)
340         (*print-miser-width* nil))
341     (formatter-call-to-string (formatter "A ~:@_A ~:@_A ~:@_A ~:@_A ~:@_"))))
342  "A A A A A ")
Note: See TracBrowser for help on using the repository browser.