/[gcl]/gcl/ansi-tests/format-s.lsp
ViewVC logotype

Diff of /gcl/ansi-tests/format-s.lsp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by pfdietz, Sat Nov 27 21:55:26 2004 UTC revision 1.4 by pfdietz, Wed Dec 8 14:30:12 2004 UTC
# Line 12  Line 12 
12      (format nil "~s" nil))      (format nil "~s" nil))
13    "NIL")    "NIL")
14    
15    (deftest formatter.s.1
16      (let ((*print-readably* nil)
17            (*print-case* :upcase))
18        (formatter-call-to-string (formatter "~s") nil))
19      "NIL")
20    
21  (def-format-test format.s.2  (def-format-test format.s.2
22    "~:s" (nil) "()")    "~:s" (nil) "()")
23    
# Line 21  Line 27 
27      (format nil "~:s" '(nil)))      (format nil "~:s" '(nil)))
28    "(NIL)")    "(NIL)")
29    
30    (deftest formatter.s.3
31      (let ((*print-readably* nil)
32            (*print-case* :upcase))
33        (formatter-call-to-string (formatter "~:s") '(nil)))
34      "(NIL)")
35    
36  (deftest format.s.4  (deftest format.s.4
37    (let ((*print-readably* nil)    (let ((*print-readably* nil)
38          (*print-case* :downcase))          (*print-case* :downcase))
39      (format nil "~s" 'nil))      (format nil "~s" 'nil))
40    "nil")    "nil")
41    
42    (deftest formatter.s.4
43      (let ((*print-readably* nil)
44            (*print-case* :downcase))
45        (formatter-call-to-string (formatter "~s") 'nil))
46      "nil")
47    
48  (deftest format.s.5  (deftest format.s.5
49    (let ((*print-readably* nil)    (let ((*print-readably* nil)
50          (*print-case* :capitalize))          (*print-case* :capitalize))
51      (format nil "~s" 'nil))      (format nil "~s" 'nil))
52    "Nil")    "Nil")
53    
54    (deftest formatter.s.5
55      (let ((*print-readably* nil)
56            (*print-case* :capitalize))
57        (formatter-call-to-string (formatter "~s") 'nil))
58      "Nil")
59    
60  (def-format-test format.s.6  (def-format-test format.s.6
61    "~:s" (#(nil)) "#(NIL)")    "~:s" (#(nil)) "#(NIL)")
62    
63  (deftest format.s.7  (deftest format.s.7
64    (with-standard-io-syntax    (let ((fn (formatter "~S")))
65     (let ((*print-readably* nil))      (with-standard-io-syntax
66       (loop for c across +standard-chars+       (let ((*print-readably* nil))
67             for s = (format nil "~S" c)         (loop for c across +standard-chars+
68             for c2 = (read-from-string s)               for s = (format nil "~S" c)
69             unless (eql c c2)               for s2 = (formatter-call-to-string fn c)
70             collect (list c s c2))))               for c2 = (read-from-string s)
71                 unless (and (eql c c2) (string= s s2))
72                 collect (list c s c2 s2)))))
73    nil)    nil)
74    
75  (deftest format.s.8  (deftest format.s.8
76    (with-standard-io-syntax    (let ((fn (formatter "~s")))
77     (let ((*print-readably* nil))      (with-standard-io-syntax
78       (loop with count = 0       (let ((*print-readably* nil))
79             for i from 0 below (min #x10000 char-code-limit)         (loop with count = 0
80             for c = (code-char i)               for i from 0 below (min #x10000 char-code-limit)
81             for s1 = (and c (format nil "#\\~:c" c))               for c = (code-char i)
82             for s2 = (and c (format nil "~S" c))               for s1 = (and c (format nil "#\\~:c" c))
83             unless (or (null c)               for s2 = (and c (format nil "~S" c))
84                        (graphic-char-p c)               for s3 = (formatter-call-to-string fn c)
85                        (string= s1 s2))               unless (or (null c)
86             do (incf count) and collect (list c s1 s2)                          (graphic-char-p c)
87             when (> count 100) collect "count limit exceeded" and do (loop-finish))))                          (and (string= s1 s2) (string= s2 s3)))
88                  do (incf count) and collect (list c s1 s2)
89                 when (> count 100)
90                  collect "count limit exceeded"
91                  and do (loop-finish)))))
92    nil)    nil)
93    
94  (deftest format.s.9  (deftest format.s.9
# Line 67  Line 97 
97       (apply       (apply
98        #'values        #'values
99        (loop for i from 1 to 10        (loop for i from 1 to 10
100              for s1 = (format nil "~~~d@s" i)              for fmt = (format nil "~~~d@s" i)
101              for s2 = (format nil s1 nil)              for s = (format nil fmt nil)
102              collect s2))))              for fn = (eval `(formatter ,fmt))
103                for s2 = (formatter-call-to-string fn nil)
104                do (assert (string= s s2))
105                collect s))))
106    "NIL"    "NIL"
107    "NIL"    "NIL"
108    "NIL"    "NIL"
# Line 87  Line 120 
120       (apply       (apply
121        #'values        #'values
122        (loop for i from 1 to 10        (loop for i from 1 to 10
123              for s1 = (format nil "~~~dS" i)              for fmt = (format nil "~~~dS" i)
124              for s2 = (format nil s1 nil)              for s = (format nil fmt nil)
125              collect s2))))              for fn = (eval `(formatter ,fmt))
126                for s2 = (formatter-call-to-string fn nil)
127                do (assert (string= s s2))
128                collect s))))
129    "NIL"    "NIL"
130    "NIL"    "NIL"
131    "NIL"    "NIL"
# Line 107  Line 143 
143       (apply       (apply
144        #'values        #'values
145        (loop for i from 1 to 10        (loop for i from 1 to 10
146              for s1 = (format nil "~~~d@:S" i)              for fmt = (format nil "~~~d@:S" i)
147              for s2 = (format nil s1 nil)              for s = (format nil fmt nil)
148              collect s2))))              for fn = (eval `(formatter ,fmt))
149                for s2 = (formatter-call-to-string fn nil)
150                do (assert (string= s s2))
151                collect s))))
152    "()"    "()"
153    "()"    "()"
154    " ()"    " ()"
# Line 127  Line 166 
166       (apply       (apply
167        #'values        #'values
168        (loop for i from 1 to 10        (loop for i from 1 to 10
169              for s1 = (format nil "~~~d:s" i)              for fmt = (format nil "~~~d:s" i)
170              for s2 = (format nil s1 nil)              for s = (format nil fmt nil)
171              collect s2))))              for fn = (eval `(formatter ,fmt))
172                for s2 = (formatter-call-to-string fn nil)
173                do (assert (string= s s2))
174                collect s))))
175    "()"    "()"
176    "()"    "()"
177    "() "    "() "
# Line 143  Line 185 
185    
186  (deftest format.s.13  (deftest format.s.13
187    (with-standard-io-syntax    (with-standard-io-syntax
188     (let ((*print-readably* nil))     (let ((*print-readably* nil)
189             (fn (formatter "~V:s")))
190       (apply       (apply
191        #'values        #'values
192        (loop for i from 1 to 10        (loop for i from 1 to 10
193              for s2 = (format nil "~v:S" i nil)              for s = (format nil "~v:S" i nil)
194              collect s2))))              for s2 = (formatter-call-to-string fn i nil)
195                do (assert (string= s s2))
196                collect s))))
197    "()"    "()"
198    "()"    "()"
199    "() "    "() "
# Line 162  Line 207 
207    
208  (deftest format.s.14  (deftest format.s.14
209    (with-standard-io-syntax    (with-standard-io-syntax
210     (let ((*print-readably* nil))     (let ((*print-readably* nil)
211             (fn (formatter "~V@:s")))
212       (apply       (apply
213        #'values        #'values
214        (loop for i from 1 to 10        (loop for i from 1 to 10
215              for s2 = (format nil "~v:@s" i nil)              for s = (format nil "~v:@s" i nil)
216              collect s2))))              for s2 = (formatter-call-to-string fn i nil)
217                do (assert (string= s s2))
218                collect s))))
219    "()"    "()"
220    "()"    "()"
221    " ()"    " ()"
# Line 228  Line 276 
276  (deftest format.s.29  (deftest format.s.29
277    (with-standard-io-syntax    (with-standard-io-syntax
278     (let ((*print-readably* nil)     (let ((*print-readably* nil)
279           (*package* (find-package :cl-test)))           (*package* (find-package :cl-test))
280             (fn (formatter "~V,,2s")))
281       (loop for i from -4 to 10       (loop for i from -4 to 10
282             collect (format nil "~v,,2S" i 'ABC))))             for s = (format nil "~v,,2S" i 'ABC)
283               for s2 = (formatter-call-to-string fn i 'ABC)
284               do (assert (string= s s2))
285               collect s)))
286    ("ABC  "    ("ABC  "
287     "ABC  "     "ABC  "
288     "ABC  "     "ABC  "
# Line 296  Line 348 
348  (deftest format.s.44  (deftest format.s.44
349    (with-standard-io-syntax    (with-standard-io-syntax
350     (let ((*print-readably* nil)     (let ((*print-readably* nil)
351           (*package* (find-package :cl-test)))           (*package* (find-package :cl-test))
352             (fn (formatter "~3,,vs")))
353       (loop for i from 0 to 6       (loop for i from 0 to 6
354             collect (format nil "~3,,vS" i 'ABC))))             for s = (format nil "~3,,vS" i 'ABC)
355               for s2 = (formatter-call-to-string fn i 'ABC)
356               do (assert (string= s s2))
357               collect s)))
358    ("ABC"    ("ABC"
359     "ABC "     "ABC "
360     "ABC  "     "ABC  "
# Line 310  Line 366 
366  (deftest format.s.44a  (deftest format.s.44a
367    (with-standard-io-syntax    (with-standard-io-syntax
368     (let ((*print-readably* nil)     (let ((*print-readably* nil)
369           (*package* (find-package :cl-test)))           (*package* (find-package :cl-test))
370             (fn (formatter "~3,,V@S")))
371       (loop for i from 0 to 6       (loop for i from 0 to 6
372             collect (format nil "~3,,v@S" i 'ABC))))             for s = (format nil "~3,,v@S" i 'ABC)
373               for s2 = (formatter-call-to-string fn i 'ABC)
374               do (assert (string= s s2))
375               collect s)))
376    ("ABC"    ("ABC"
377     " ABC"     " ABC"
378     "  ABC"     "  ABC"

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26