1/*
2Nov 2015 results:
3GCL  : The following 8 problems failed: (7    29 38 39 40 47 48             69)
4SBCL : The following 4 problems failed: (        38                63 65    69)
5CCL  : The following 2 problems failed: (  27                   54            )
6ECL  : The following 6 problems failed: (        38             54 63 65 66 69)
7CLISP: The following 5 problems failed: (  27    38                63 65    69)
8CMUCL: The following 0 problems failed: (                                     )
9*/
10
11printf(false, "|~5a|~5:a|~5@a|~5:@a|", 42,42,42,42);
12"|42   |42   |   42|   42|"$
13
14printf(false, "|~5a|~5:a|~5@a|~5:@a|", "42","42","42","42");
15"|42   |42   |   42|   42|"$
16
17printf(false, "|~5s|~5:s|~5@s|~5:@s|", "42","42","42","42");
18"|\"42\" |\"42\" | \"42\"| \"42\"|"$
19
20printf(false, "|~10b|~10:b|~10@b|~10:@b|", 42,42,42,42);
21"|    101010|   101,010|   +101010|  +101,010|"$
22
23printf(false, "~{ ~c ~:c ~@c ~:@c ~}", makelist("w", n,1,4) );
24" w w #\\w w "$
25
26printf(false, "|~10d|~10:d|~10@d|~10:@d|", 42,42,42,42);
27"|        42|        42|       +42|       +42|"$
28
29printf(false, "~{~a ~s ~d ~f ~h ~}", makelist( sqrt(2), n,1,5) ), fpprec: 24$
30"sqrt(2) \"sqrt(2)\" 1 1.4142135623730951 1.41421356237309504880169 "$
31
32printf(false, "|~v,v,v,,vf|", 12, 3, 0 ,"f", 9);
33"|fffffff9.000|"$
34
35printf(false, "|~v,v,v,,,vh|", 12, 3, 0 ,"h", 9);
36"|hhhh9.000b+0|"$
37
38printf(false , "|~#,vf|", 2,3,4,5,6,7);
39"|  3.00|"$
40
41printf(false , "|~#,vh|", 2,3,4,5,6,7);
42"|  3.00|"$
43
44printf(false, "~{~[Siamese~;Manx~;Persian~] Cat ~%~}", [1,2,3,4]);
45"Siamese Cat
46Manx Cat
47Persian Cat
48 Cat
49"$
50
51printf(false, "~{~[Siamese~;Manx~:;Persian~] Cat ~%~}", [1,2,3,4]);
52"Siamese Cat
53Manx Cat
54Persian Cat
55Persian Cat
56"$
57
58printf(false, "~{~:[Siamese~;Manx~] Cat ~%~}", [true,false,1,0]);
59"Manx Cat
60Siamese Cat
61Manx Cat
62Manx Cat
63"$
64
65printf(false, "|~@[x~]|", true );
66"|x|"$
67
68printf(false, "|~@[x~]|", false );
69"||"$
70
71printf(false, "|~@{~#d|~}",6,5,4,3,2,1);
72"|     6|    5|   4|  3| 2|1|"$
73
74printf(false, "~d ~{~d ~}~d",7,[6,5,4,3,2,1],0);
75"7 6 5 4 3 2 1 0"$
76printf(false, "~d ~@{~d ~}",7,6,5,4,3,2,1,0);
77"7 6 5 4 3 2 1 0 "$
78printf(false, "~d ~{~{~d ~}~}",7,[[6,5],[4,3],[2,1],[0]]);
79"7 6 5 4 3 2 1 0 "$
80printf(false, "~d ~:{~d ~}",7,[[6,5],[4,3],[2,1],[0]]);
81"7 6 4 2 0 "$
82printf(false, "~d ~:{~d ~^~d ~}",7,[[6,5],[4,3],[2,1],[0]]);
83"7 6 5 4 3 2 1 0 "$
84printf(false, "~d ~:@{~d ~^~d ~}",7,[6,5],[4,3],[2,1],[0]);
85"7 6 5 4 3 2 1 0 "$
86printf(false, "~d ~:@{~d ~}",7,[6,5],[4,3],[2,1],[0]);
87"7 6 4 2 0 "$
88
89printf(false, "~{~h|~%~16,10h|~%~16,10,,,,'#h|~%~16,10@h|~%~,10,2,-3h|~%~10,,,,'xh|~%~}",
90   makelist( sqrt(2), n,1,6) ), fpprec: 24;
91"1.41421356237309504880169|
92    1.4142135624|
93####1.4142135624|
94   +1.4142135624|
951414.2135623731b-03|
96xxxxxxxxxx|
97"$
98
99printf(false, "|~10<foo~;bar~>|");
100"|foo    bar|"$
101printf(false, "|~30<foo~;bar~;baz~>|");
102"|foo          bar           baz|"$
103
104printf(false, "~:{/~a~^ ...~}", [[hot, dog], [hamburger], [ice, cream]] );
105"/hot .../hamburger/ice ..."$
106
107printf(false, "~:{/~a~:^ ...~}", [[hot, dog], [hamburger], [ice, cream]] );
108"/hot .../hamburger .../ice"$
109
110printf(false, "~? ~d", "|~a ~f|", ["Foo", 5], 7 );
111"|Foo 5.0| 7"$
112
113printf(false, "~@? ~d", "|~a ~f|", "Foo", 5, 7 );
114"|Foo 5.0| 7"$
115
116
117
118printf(false,"~{|~a|~5a|~5@a|~5,,,'.a|~5,,3,'.a|~6,2,,'.a|~6,5,,'.a|~}", makelist('x,n,1,7));
119"|x|x    |    x|x....|x....|x......|x.....|"$
120
121printf(false,"~{|~s|~5s|~5@s|~5,,,'.s|~5,,3,'.s|~6,2,,'.s|~6,5,,'.s|~}", makelist('x,n,1,7));
122"|\"x\"|\"x\"  |  \"x\"|\"x\"..|\"x\"...|\"x\"....|\"x\".....|"$
123
124
125printf(false,"[~a, ~a, ~a, ~a, ~a, ~a, ~a]", true,sqrt(2),%pi,2/6,1.234b0,[a+a,[b,c]],"foo");
126"[true, sqrt(2), %pi, 1/3, 1.234b0, [2*a,[b,c]], foo]"$
127
128printf(false,"[~s, ~s, ~s, ~s, ~s, ~s, ~s]", true,sqrt(2),%pi,2/6,1.234b0,[a+a,[b,c]],"foo");
129"[\"true\", \"sqrt(2)\", \"%pi\", \"1/3\", \"1.234b0\", \"[2*a,[b,c]]\", \"foo\"]"$
130
131
132
133args: [42,1.5,sqrt(2),%pi,7/2,1.234b0];
134[42,1.5,sqrt(2),%pi,7/2,1.234b0]$
135
136printf(false,"[~{~d~^, ~}]", args);
137"[42, 1, 1, 3, 3, 1]"$
138
139( ans: "[4.2E+1, 1.5E+0, 1.4142135623730951E+0, 3.141592653589793E+0, 3.5E+0, 1.234E+0]",
140  printf(false, "[~{~e~^, ~}]", args),
141  if sequalignore (%%, ans) then true else %%);
142true;
143
144printf(false,"[~{~f~^, ~}]", args);
145"[42.0, 1.5, 1.4142135623730951, 3.141592653589793, 3.5, 1.234]"$
146
147printf(false,"[~{~g~^, ~}]", args);
148"[42.    , 1.5    , 1.4142135623730951    , 3.141592653589793    , 3.5    , 1.234    ]"$
149
150printf(false,"[~{~h~^, ~}]", args), fpprintprec=16;
151"[42.0, 1.5, 1.414213562373095, 3.141592653589793, 3.5, 1.234]"$
152
153
154printf(false,"~{[~b, ~o, ~x, ~2r, ~3r, ~4r, ~10r, ~22r, ~36r]~}", makelist(42,n,1,9) );
155"[101010, 52, 2A, 101010, 1120, 222, 42, 1K, 16]"$
156
157printf(false,"~{[~r, ~:r, ~@r, ~:@r]~}", makelist(42,n,1,4) );
158"[forty-two, forty-second, XLII, XXXXII]"$
159
160
161printf(false,"~d dog~p. ~d bone~p.", 2, 2, 1, 1 );
162"2 dogs. 1 bone."$
163
164printf(false,"~d dog~:p. ~d bone~:p.", 2, 1 );
165"2 dogs. 1 bone."$
166
167printf(false,"~d fl~:@p. ~d fl~:@p.", 1, 2 );
168"1 fly. 2 flies."$
169
170
171printf(false,"[~$, ~$, ~$, ~@$]", 2, 1.985, 1.995, 2 );
172"[2.00, 1.99, 2.00, +2.00]"$
173
174
175printf(false,"0123456789~%|~5t|~4,3t|~,2t|~%|~4,3t|~,2t|");
176"0123456789
177|    | | |
178|   |  |"$
179
180
181printf(false,"012345678901234~%|~5@t|~4,3@t|~,2@t|~%|~4,3@t|~,2@t|");
182"012345678901234
183|     |     | |
184|     | |"$
185
186
187printf(false,"~~  ~3~");
188"~  ~~~"$
189
190
191printf(false, "A long format string can simply be sepa~
192      rated by a single ~~ immediately ~%followed by newline. Add~
193      itional blanks are ignored.~:
194      ~~: causes the ~%blanks to be printed. ~~@ enf~
195      orces the linebrea~@
196      k and ignores following blanks.");
197"A long format string can simply be separated by a single ~ immediately
198followed by newline. Additional blanks are ignored.      ~: causes the
199blanks to be printed. ~@ enforces the linebrea
200k and ignores following blanks."$
201
202
203printf(false, "~d aaa ~? bbb ~d", 0, "~d ~d ~d", [1,2,3], 4);
204"0 aaa 1 2 3 bbb 4"$
205
206printf(false, "~d aaa ~@? bbb ~d", 0, "~d ~d ~d", 1,2,3, 4);
207"0 aaa 1 2 3 bbb 4"$
208
209printf(false, "~d ~v,v^~f ", 0, 1, 2, 3);
210"0 3.0 "$
211printf(false, "~d ~v,v^~f ", 0, 1, 1, 3);
212"0 "$
213
214fpprec:100;
215100$
216printf(false,"~h",2.b0^-64);
217"0.0000000000000000000542101086242752217003726400434970855712890625"$
218printf(false,"~,17,0h",1.23456789012345678901234567890b9);
219"1234567890.12345678901234568b+0"$
220printf(false,"~50h",2.b0^64);
221"                            18446744073709551616.0"$
222fpprec:16;
22316$
224
225makelist (ev (printf (false, "~h", bfloat (%pi)), fpprintprec=i), i, 2, 16);
226["3.1", "3.14", "3.141", "3.1415", "3.14159", "3.141592", "3.1415926",
227"3.14159265", "3.141592653", "3.1415926535", "3.14159265358",
228"3.141592653589", "3.1415926535897", "3.14159265358979", "3.141592653589793"];
229
230/* printing numbers close to 1 exposes bug in FORMAT
231 * reported to mailing list 2015-03-10: "Rounding problem with format"
232 */
233
234(fpprec : 100, 0);
2350;
236
237(3.486966909006701254309886183074014693622265540576239825103417070695233093147180625237524509429931641b-22
238*2.867821881007928e+21,
239 printf(false, "~13,6,3,1e", %%),
240 if sequalignore (%%, "1.000000e+000") then true else %%);
241true;
242
243(reset (fpprec), 0);
2440;
245
246(printf (false, "~13,6,3,1e", 0.9999999999999999),
247 if sequalignore (%%, "1.000000e+000") then true else %%);
248true;
249
250(printf (false, "~9,3,2,1e", 1.0),
251 if sequalignore (%%, "1.000e+00") then true else %%);
252true;
253
254(printf (false, "~9,3,2,1e", 0.999),
255 if sequalignore (%%, "9.990e-01") then true else %%);
256true;
257
258(printf (false, "~9,3,2,1e", 0.9999),
259 if sequalignore (%%, "9.999e-01") then true else %%);
260true;
261
262(printf (false, "~9,3,2,1e", 0.99999),
263 if sequalignore (%%, "1.000e+00") then true else %%);
264true;
265
266
267/* changing fpprec should not change the printed result
268 */
269
270(fpprec: 22,
271 bf: 1.23456789012345678901234567890b-10,
272 a1: printf(false, "~,42,,0h~%", bf),
273 a2: printf(false, "~,42,,10h~%", bf),
274 a3: printf(false, "~,42,,-10h~%", bf),
275 fpprec: 42,
276 b1: printf(false, "~,42,,0h~%", bf),
277 b2: printf(false, "~,42,,10h~%", bf),
278 b3: printf(false, "~,42,,-10h~%", bf),
279 reset(fpprec),
280 is(a1=b1) and is(a2=b2) and is(a3=b3) );
281true$
282
283(remvalue(args,bf,a1,a2,b1,b2,c1,c2), 0);
2840;
285
286