source: trunk/source/tests/ansi-tests/format-paren.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: 3.9 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sun Oct 17 20:28:24 2004
4;;;; Contains: Tests of the ~( format directives
5
6(in-package :cl-test)
7
8(compile-and-load "printer-aux.lsp")
9
10(def-format-test format.paren.1
11  "~(XXyy~AuuVV~)" ("ABc dEF ghI") "xxyyabc def ghiuuvv")
12
13;;; Conversion of simple characters to downcase
14(deftest format.paren.2
15  (loop for i from 0 below (min char-code-limit (ash 1 16))
16        for c = (code-char i)
17        when (and c
18                  (eql (char-code c) (char-int c))
19                  (upper-case-p c)
20                  (let ((s1 (format nil "~(~c~)" c))
21                        (s2 (string (char-downcase c))))
22                    (if
23                        (or (not (eql (length s1) 1))
24                            (not (eql (length s2) 1))
25                            (not (eql (elt s1 0)
26                                      (elt s2 0))))
27                        (list i c s1 s2)
28                      nil)))
29        collect it)
30  nil)
31
32(deftest formatter.paren.2
33  (let ((fn (formatter "~(~c~)")))
34    (loop for i from 0 below (min char-code-limit (ash 1 16))
35          for c = (code-char i)
36          when (and c
37                    (eql (char-code c) (char-int c))
38                    (upper-case-p c)
39                    (let ((s1 (formatter-call-to-string fn c))
40                          (s2 (string (char-downcase c))))
41                      (if
42                          (or (not (eql (length s1) 1))
43                              (not (eql (length s2) 1))
44                              (not (eql (elt s1 0)
45                                        (elt s2 0))))
46                          (list i c s1 s2)
47                        nil)))
48          collect it))
49  nil)
50
51
52(def-format-test format.paren.3
53  "~@(this is a TEST.~)" nil "This is a test.")
54
55(def-format-test format.paren.4
56  "~@(!@#$%^&*this is a TEST.~)" nil "!@#$%^&*This is a test.")
57
58(def-format-test format.paren.5
59  "~:(this is a TEST.~)" nil "This Is A Test.")
60                       
61(def-format-test format.paren.6
62  "~:(this is7a TEST.~)" nil "This Is7a Test.")
63
64(def-format-test format.paren.7
65  "~:@(this is AlSo A teSt~)" nil "THIS IS ALSO A TEST")
66
67(deftest format.paren.8
68  (loop for i from 0 below (min char-code-limit (ash 1 16))
69        for c = (code-char i)
70        when (and c
71                  (eql (char-code c) (char-int c))
72                  (lower-case-p c)
73                  (let ((s1 (format nil "~@:(~c~)" c))
74                        (s2 (string (char-upcase c))))
75                    (if
76                        (or (not (eql (length s1) 1))
77                            (not (eql (length s2) 1))
78                            (not (eql (elt s1 0)
79                                      (elt s2 0))))
80                        (list i c s1 s2)
81                      nil)))
82        collect it)
83  nil)
84
85(deftest formatter.paren.8
86  (let ((fn (formatter "~@:(~c~)")))
87    (loop for i from 0 below (min char-code-limit (ash 1 16))
88          for c = (code-char i)
89          when (and c
90                    (eql (char-code c) (char-int c))
91                    (lower-case-p c)
92                    (let ((s1 (formatter-call-to-string fn c))
93                          (s2 (string (char-upcase c))))
94                      (if
95                          (or (not (eql (length s1) 1))
96                              (not (eql (length s2) 1))
97                              (not (eql (elt s1 0)
98                                        (elt s2 0))))
99                          (list i c s1 s2)
100                        nil)))
101          collect it))
102  nil)
103
104;;; Nested conversion
105
106(def-format-test format.paren.9
107  "~(aBc ~:(def~) GHi~)" nil "abc def ghi")
108
109(def-format-test format.paren.10
110  "~(aBc ~(def~) GHi~)" nil "abc def ghi")
111
112(def-format-test format.paren.11
113  "~@(aBc ~:(def~) GHi~)" nil "Abc def ghi")
114
115(def-format-test format.paren.12
116  "~(aBc ~@(def~) GHi~)" nil "abc def ghi")
117
118(def-format-test format.paren.13
119  "~(aBc ~:(def~) GHi~)" nil "abc def ghi")
120
121(def-format-test format.paren.14
122  "~:(aBc ~(def~) GHi~)" nil "Abc Def Ghi")
123
124(def-format-test format.paren.15
125  "~:(aBc ~:(def~) GHi~)" nil "Abc Def Ghi")
126
127(def-format-test format.paren.16
128  "~:(aBc ~@(def~) GHi~)" nil "Abc Def Ghi")
129
130(def-format-test format.paren.17
131  "~:(aBc ~@:(def~) GHi~)" nil "Abc Def Ghi")
132
133(def-format-test format.paren.18
134  "~@(aBc ~(def~) GHi~)" nil "Abc def ghi")
135
136(def-format-test format.paren.19
137  "~@(aBc ~:(def~) GHi~)" nil "Abc def ghi")
138
139(def-format-test format.paren.20
140  "~@(aBc ~@(def~) GHi~)" nil "Abc def ghi")
141
142(def-format-test format.paren.21
143  "~@(aBc ~@:(def~) GHi~)" nil "Abc def ghi")
144
145(def-format-test format.paren.22
146  "~:@(aBc ~(def~) GHi~)" nil "ABC DEF GHI")
147
148(def-format-test format.paren.23
149  "~@:(aBc ~:(def~) GHi~)" nil "ABC DEF GHI")
150
151(def-format-test format.paren.24
152  "~:@(aBc ~@(def~) GHi~)" nil "ABC DEF GHI")
153
154(def-format-test format.paren.25
155  "~@:(aBc ~@:(def~) GHi~)" nil "ABC DEF GHI")
Note: See TracBrowser for help on using the repository browser.