format-logical-block.lsp 6.38 KB
Newer Older
pfdietz's avatar
pfdietz committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sun Aug  8 12:17:31 2004
;;;; Contains: Tests of the ~< ~:> format directives

(in-package :cl-test)

(compile-and-load "printer-aux.lsp")

;;; Error cases

;;; Prefix and suffix cannot contain format directives

(deftest format.logical-block.error.1
15
16
  (signals-error-always (format nil "~<foo~A~;~A~;bar~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
17
18

(deftest format.logical-block.error.2
19
20
  (signals-error-always (format nil "~<foo~A~@;~A~;bar~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
21
22

(deftest format.logical-block.error.3
23
24
  (signals-error-always (format nil "~<foo~;~A~;bar~A~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
25
26

(deftest format.logical-block.error.4
27
28
  (signals-error-always (format nil "~<foo~@;~A~;bar~A~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
29
30

(deftest format.logical-block.error.5
31
32
  (signals-error-always (format nil "~<foo~A~;~A~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
33
34

(deftest format.logical-block.error.6
35
36
  (signals-error-always (format nil "~<foo~A~@;~A~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
37
38

(deftest format.logical-block.error.7
39
40
  (signals-error-always (format nil "~<~;~A~;bar~A~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
41
42

(deftest format.logical-block.error.8
43
44
  (signals-error-always (format nil "~<~@;~A~;bar~A~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
45
46

(deftest format.logical-block.error.9
47
48
  (signals-error-always (format nil "~:<foo~A~;~A~;bar~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
49
50

(deftest format.logical-block.error.10
51
52
  (signals-error-always (format nil "~:<foo~A~@;~A~;bar~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
53
54

(deftest format.logical-block.error.11
55
56
  (signals-error-always (format nil "~:<foo~;~A~;bar~A~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
57
58

(deftest format.logical-block.error.12
59
60
  (signals-error-always (format nil "~:<foo~@;~A~;bar~A~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
61
62

(deftest format.logical-block.error.13
63
64
  (signals-error-always (format nil "~:<foo~A~;~A~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
65
66

(deftest format.logical-block.error.14
67
68
  (signals-error-always (format nil "~:<foo~A~@;~A~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
69
70

(deftest format.logical-block.error.15
71
72
  (signals-error-always (format nil "~:<~;~A~;bar~A~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
73
74

(deftest format.logical-block.error.16
75
76
  (signals-error-always (format nil "~:<~@;~A~;bar~A~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
77
78

(deftest format.logical-block.error.17
79
80
  (signals-error-always (format nil "~@<foo~A~;~A~;bar~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
81
82

(deftest format.logical-block.error.18
83
84
  (signals-error-always (format nil "~@<foo~A~@;~A~;bar~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
85
86

(deftest format.logical-block.error.19
87
88
  (signals-error-always (format nil "~@<foo~;~A~;bar~A~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
89
90

(deftest format.logical-block.error.20
91
92
  (signals-error-always (format nil "~@<foo~@;~A~;bar~A~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
93
94

(deftest format.logical-block.error.21
95
96
  (signals-error-always (format nil "~@<foo~A~;~A~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
97
98

(deftest format.logical-block.error.22
99
100
  (signals-error-always (format nil "~@<foo~A~@;~A~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
101
102

(deftest format.logical-block.error.23
103
104
  (signals-error-always (format nil "~@<~;~A~;bar~A~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
105
106

(deftest format.logical-block.error.24
107
108
  (signals-error-always (format nil "~@<~@;~A~;bar~A~:>" '(X) '(Y)) error)
  t t)
pfdietz's avatar
pfdietz committed
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232

;;; Non-error tests

(def-pprint-test format.logical-block.1
  (format nil "~<~A~:>" '(nil))
  "NIL")

(def-pprint-test format.logical-block.2
  (format nil "~@<~A~:>" nil)
  "NIL")

(def-pprint-test format.logical-block.3
  (format nil "~:<~A~:>" '(nil))
  "(NIL)")

(def-pprint-test format.logical-block.4
  (format nil "~:@<~A~:>" nil)
  "(NIL)")

(def-pprint-test format.logical-block.5
  (format nil "~@:<~A~:>" nil)
  "(NIL)")

(def-pprint-test format.logical-block.6
  (format nil "~<~@{~A~^*~}~:>" '(1 2 3))
  "1*2*3")

(def-pprint-test format.logical-block.7
  (format nil "~:<~@{~A~^*~}~:>" '(1 2 3))
  "(1*2*3)")

(def-pprint-test format.logical-block.8
  (format nil "~:<~@{~A~^*~}~:>" 1)
  "1")

(def-pprint-test format.logical-block.9
  (format nil "~<~;~A~;~:>" '(1 2 3))
  "1")

(def-pprint-test format.logical-block.10
  (format nil "~<~;~A~:>" '(1 2 3))
  "1")

(def-pprint-test format.logical-block.11
  (format nil "~@<~;~A~;~:>" '(1 2 3))
  "(1 2 3)")

(def-pprint-test format.logical-block.12
  (format nil "~@<~;~A~:>" '(1 2 3))
  "(1 2 3)")

(def-pprint-test format.logical-block.13
  (format nil "~:<[~;~@{~A~^/~}~:>" '(1 2 3))
  "[1/2/3)")

(def-pprint-test format.logical-block.14
  (format nil "~:<~;~@{~A~^/~}~;]~:>" '(1 2 3))
  "1/2/3]")

(def-pprint-test format.logical-block.15
  (format nil "~:<[~;~@{~A~^/~}~;]~:>" '(1 2 3))
  "[1/2/3]")

(def-pprint-test format.logical-block.16
  (format nil "~@<~@{~A~^*~}~:>" 1 2 3)
  "1*2*3")

(def-pprint-test format.logical-block.17
  (format nil "~@<~@{~A~^ ~_~}~:>" 1 2 3)
  "1 2 3")

(def-pprint-test format.logical-block.18
  (format nil "~@<~@{~A~^ ~_~}~:>" 1 2 3)
  "1
2
3"
  :margin 2)

(def-pprint-test format.logical-block.19
  (format nil "~:@<~@{~A~^ ~_~}~:>" 1 2 3)
  "(1
 2
 3)"
  :margin 2)

(def-pprint-test format.logical-block.20
  (format nil "~@:<~@{~A~^ ~}~:>" 1 2 3)
  "(1 2 3)"
  :margin 2)

(def-pprint-test format.logical-block.21
  (format nil "~@:<~@{~A~^ ~:_~}~:>" 1 2 3)
  "(1
 2
 3)"
  :margin 2)

(def-pprint-test format.logical-block.22
  (format nil "~:@<~@{~A~^ ~}~:@>" 1 2 3)
  "(1
 2
 3)"
  :margin 2)

(def-pprint-test format.logical-block.23
  (format nil "~:@<~@{~A~^/~
                   ~}~:@>" 1 2 3)
  "(1/2/3)"
  :margin 2)

(def-pprint-test format.logical-block.24
  (format nil "~:@<~@{~A~^            ~:_~}~:>" 1 2 3)
  "(1
 2
 3)"
  :margin 2)

(def-pprint-test format.logical-block.25
  (format nil "~:@<~@{~A~^            ~}~:@>" 1 2 3)
  "(1
 2
 3)"
  :margin 2)

233
234
235
236
237
(def-pprint-test format.logical-block.26
  (format nil "~:@<~@{~A~^~}~:@>" "1 2 3")
  "(1 2 3)"
  :margin 2)

pfdietz's avatar
pfdietz committed
238
239
;;; Circularity detection

240
(def-pprint-test format.logical-block.circle.1
pfdietz's avatar
pfdietz committed
241
242
243
244
  (format nil "~:<~@{~A~^ ~}~:>" (let ((x (list 0))) (list x x)))
  "(#1=(0) #1#)"
  :circle t)

245
(def-pprint-test format.logical-block.circle.2
pfdietz's avatar
pfdietz committed
246
247
248
249
  (format nil "~:<~@{~A~^ ~}~:>" (let ((x (list 0))) (cons x x)))
  "(#1=(0) . #1#)"
  :circle t)

250
(def-pprint-test format.logical-block.circle.3
pfdietz's avatar
pfdietz committed
251
252
253
254
255
256
  (format nil "~:<~@{~A~^ ~}~:>" (let ((x (list 0)))
				   (setf (cdr x) x)
				   x))
  "#1=(0 . #1#)"
  :circle t)

257
(def-pprint-test format.logical-block.circle.4
pfdietz's avatar
pfdietz committed
258
259
260
  (format nil "~:<~@{~A~^ ~}~:>" (let ((x (list 0))) (list x x)))
  "((0) (0))")

261
(def-pprint-test format.logical-block.circle.5
pfdietz's avatar
pfdietz committed
262
263
  (format nil "~:<~@{~A~^ ~}~:>" (let ((x (list 0))) (cons x x)))
  "((0) 0)")