Re: sprintf 64 test
[p5sagit/p5-mst-13.2.git] / t / op / sprintf.t
1 #!./perl
2
3 # Tests sprintf, excluding handling of 64-bit integers or long
4 # doubles (if supported), of machine-specific short and long
5 # integers, machine-specific floating point exceptions (infinity,
6 # not-a-number ...), of the effects of locale, and of features
7 # specific to multi-byte characters (under the utf8 pragma and such).
8
9 BEGIN {
10     chdir 't' if -d 't';
11     @INC = '../lib';
12 }
13 use warnings;
14 use version;
15 use Config;
16 use strict;
17
18 my @tests = ();
19 my ($i, $template, $data, $result, $comment, $w, $x, $evalData, $n, $p);
20
21 my $Is_VMS_VAX = 0;
22 # We use HW_MODEL since ARCH_NAME was not in VMS V5.*
23 if ($^O eq 'VMS') {
24     my $hw_model;
25     chomp($hw_model = `write sys\$output f\$getsyi("HW_MODEL")`);
26     $Is_VMS_VAX = $hw_model < 1024 ? 1 : 0;
27 }
28
29 # No %Config.
30 my $Is_Ultrix_VAX = $^O eq 'ultrix' && `uname -m` =~ /^VAX$/;
31
32 while (<DATA>) {
33     s/^\s*>//; s/<\s*$//;
34     ($template, $data, $result, $comment) = split(/<\s*>/, $_, 4);
35     if ($^O eq 'os390' || $^O eq 's390') { # non-IEEE (s390 is UTS)
36         $data   =~ s/([eE])96$/${1}63/;      # smaller exponents
37         $result =~ s/([eE]\+)102$/${1}69/;   #  "       "
38         $data   =~ s/([eE])\-101$/${1}-56/;  # larger exponents
39         $result =~ s/([eE])\-102$/${1}-57/;  #  "       "
40     }
41     if ($Is_VMS_VAX || $Is_Ultrix_VAX) {
42         # VAX DEC C 5.3 at least since there is no
43         # ccflags =~ /float=ieee/ on VAX.
44         # AXP is unaffected whether or not it's using ieee.
45         $data   =~ s/([eE])96$/${1}26/;      # smaller exponents
46         $result =~ s/([eE]\+)102$/${1}32/;   #  "       "
47         $data   =~ s/([eE])\-101$/${1}-24/;  # larger exponents
48         $result =~ s/([eE])\-102$/${1}-25/;  #  "       "
49     }
50
51     $evalData = eval $data;
52     $data = ref $evalData ? $evalData : [$evalData];
53     push @tests, [$template, $data, $result, $comment];
54 }
55
56 print '1..', scalar @tests, "\n";
57
58 $SIG{__WARN__} = sub {
59     if ($_[0] =~ /^Invalid conversion/) {
60         $w = ' INVALID';
61     } elsif ($_[0] =~ /^Use of uninitialized value/) {
62         $w = ' UNINIT';
63     } else {
64         warn @_;
65     }
66 };
67
68 for ($i = 1; @tests; $i++) {
69     ($template, $data, $result, $comment) = @{shift @tests};
70     $w = undef;
71     $x = sprintf(">$template<", @$data);
72     substr($x, -1, 0) = $w if $w;
73     # $x may have 3 exponent digits, not 2
74     my $y = $x;
75     if ($y =~ s/([Ee][-+])0(\d)/$1$2/) {
76         # if result is left-adjusted, append extra space
77         if ($template =~ /%\+?\-/ and $result =~ / $/) {
78             $y =~ s/<$/ </;
79         }
80         # if result is zero-filled, add extra zero
81         elsif ($template =~ /%\+?0/ and $result =~ /^0/) {
82             $y =~ s/^>0/>00/;
83         }
84         # if result is right-adjusted, prepend extra space
85         elsif ($result =~ /^ /) {
86             $y =~ s/^>/> /;
87         }
88     }
89
90     my $skip = 0;
91     if ($comment =~ s/\s+skip:\s*(.*)//) {
92         my $os  = $1;
93         my $osv = exists $Config{osvers} ? $Config{osvers} : "0";
94         # >comment skip: all<
95         if ($os =~ /\ball\b/i) {
96             $skip = 1;
97         # >comment skip: VMS hpux:10.20<
98         } elsif ($os =~ /\b$^O(?::(\S+))?\b/i) {
99             my $vsn = defined $1 ? $1 : "0";
100             # Only compare on the the first pair of digits, as numeric
101             # compares don't like 2.6.10-3mdksmp or 2.6.8-24.10-default
102             s/^(\d+(\.\d+)?).*/$1/ for $osv, $vsn;
103             $skip = $vsn ? ($osv <= $vsn ? 1 : 0) : 1;
104         }
105         $skip and $comment =~ s/$/, failure expected on $^O $osv/;
106     }
107
108     if ($x eq ">$result<") {
109         print "ok $i\n";
110     }
111     elsif ($skip) {
112         print "ok $i # skip $comment\n";
113     }
114     elsif ($y eq ">$result<")   # Some C libraries always give
115     {                           # three-digit exponent
116                 print("ok $i # >$result< $x three-digit exponent accepted\n");
117     }
118         elsif ($result =~ /[-+]\d{3}$/ &&
119                    # Suppress tests with modulo of exponent >= 100 on platforms
120                    # which can't handle such magnitudes (or where we can't tell).
121                    ((!eval {require POSIX}) || # Costly: only do this if we must!
122                         (length(&POSIX::DBL_MAX) - rindex(&POSIX::DBL_MAX, '+')) == 3))
123         {
124                 print("ok $i # >$template< >$data< >$result<",
125                           " Suppressed: exponent out of range?\n");
126         }
127     else {
128         $y = ($x eq $y ? "" : " => $y");
129         print("not ok $i >$template< >$data< >$result< $x$y",
130             $comment ? " # $comment\n" : "\n");
131     }
132 }
133
134 # In each of the following lines, there are three required fields:
135 # printf template, data to be formatted (as a Perl expression), and
136 # expected result of formatting.  An optional fourth field can contain
137 # a comment.  Each field is delimited by a starting '>' and a
138 # finishing '<'; any whitespace outside these start and end marks is
139 # not part of the field.  If formatting requires more than one data
140 # item (for example, if variable field widths are used), the Perl data
141 # expression should return a reference to an array having the requisite
142 # number of elements.  Even so, subterfuge is sometimes required: see
143 # tests for %n and %p.
144 #
145 # Tests that are expected to fail on a certain OS can be marked as such
146 # by trailing the comment with a skip: section. Skips are tags separated
147 # bu space consisting of a $^O optionally trailed with :osvers. In the
148 # latter case, all os-levels below that are expected to fail. A special
149 # tag 'all' is allowed for todo tests that should fail on any system
150 #
151 # >%G<   >1234567e96<  >1.23457E+102<   >exponent too big skip: os390<
152 # >%.0g< >-0.0<        >-0<             >No minus skip: MSWin32 VMS hpux:10.20<
153 # >%d<   >4<           >1<              >4 != 1 skip: all<
154 #
155 # The following tests are not currently run, for the reasons stated:
156
157 =pod
158
159 =begin problematic
160
161 >%.0f<      >1.5<         >2<   >Standard vague: no rounding rules<
162 >%.0f<      >2.5<         >2<   >Standard vague: no rounding rules<
163
164 =end problematic
165
166 =cut
167
168 # template    data          result
169 __END__
170 >%6. 6s<    >''<          >%6. 6s INVALID< >(See use of $w in code above)<
171 >%6 .6s<    >''<          >%6 .6s INVALID<
172 >%6.6 s<    >''<          >%6.6 s INVALID<
173 >%A<        >''<          >%A INVALID<
174 >%B<        >''<          >%B INVALID<
175 >%C<        >''<          >%C INVALID<
176 >%D<        >0x7fffffff<  >2147483647<     >Synonym for %ld<
177 >%E<        >123456.789<  >1.234568E+05<   >Like %e, but using upper-case "E"<
178 >%F<        >123456.789<  >123456.789000<  >Synonym for %f<
179 >%G<        >1234567.89<  >1.23457E+06<    >Like %g, but using upper-case "E"<
180 >%G<        >1234567e96<  >1.23457E+102<
181 >%G<        >.1234567e-101< >1.23457E-102<
182 >%G<        >12345.6789<  >12345.7<
183 >%G<        >1234567e96<  >1.23457E+102<        >exponent too big skip: os390<
184 >%G<        >.1234567e-101< >1.23457E-102<      >exponent too small skip: os390<
185 >%H<        >''<          >%H INVALID<
186 >%I<        >''<          >%I INVALID<
187 >%J<        >''<          >%J INVALID<
188 >%K<        >''<          >%K INVALID<
189 >%L<        >''<          >%L INVALID<
190 >%M<        >''<          >%M INVALID<
191 >%N<        >''<          >%N INVALID<
192 >%O<        >2**32-1<     >37777777777<    >Synonym for %lo<
193 >%P<        >''<          >%P INVALID<
194 >%Q<        >''<          >%Q INVALID<
195 >%R<        >''<          >%R INVALID<
196 >%S<        >''<          >%S INVALID<
197 >%T<        >''<          >%T INVALID<
198 >%U<        >2**32-1<     >4294967295<     >Synonym for %lu<
199 >%V<        >''<          >%V INVALID<
200 >%W<        >''<          >%W INVALID<
201 >%X<        >2**32-1<     >FFFFFFFF<       >Like %x, but with u/c letters<
202 >%#X<       >2**32-1<     >0XFFFFFFFF<
203 >%Y<        >''<          >%Y INVALID<
204 >%Z<        >''<          >%Z INVALID<
205 >%a<        >''<          >%a INVALID<
206 >%b<        >2**32-1<     >11111111111111111111111111111111<
207 >%+b<       >2**32-1<     >11111111111111111111111111111111<
208 >%#b<       >2**32-1<     >0b11111111111111111111111111111111<
209 >%34b<      >2**32-1<     >  11111111111111111111111111111111<
210 >%034b<     >2**32-1<     >0011111111111111111111111111111111<
211 >%-34b<     >2**32-1<     >11111111111111111111111111111111  <
212 >%-034b<    >2**32-1<     >11111111111111111111111111111111  <
213 >%6b<       >12<          >  1100<
214 >%6.5b<     >12<          > 01100<
215 >%-6.5b<    >12<          >01100 <
216 >%+6.5b<    >12<          > 01100<
217 >% 6.5b<    >12<          > 01100<
218 >%06.5b<    >12<          > 01100<         >0 flag with precision: no effect<
219 >%.5b<      >12<          >01100<
220 >%c<        >ord('A')<    >A<
221 >%10c<      >ord('A')<    >         A<
222 >%#10c<     >ord('A')<    >         A<     ># modifier: no effect<
223 >%010c<     >ord('A')<    >000000000A<
224 >%10lc<     >ord('A')<    >         A<     >l modifier: no effect<
225 >%10hc<     >ord('A')<    >         A<     >h modifier: no effect<
226 >%10.5c<    >ord('A')<    >         A<     >precision: no effect<
227 >%-10c<     >ord('A')<    >A         <
228 >%d<        >123456.789<  >123456<
229 >%d<        >-123456.789< >-123456<
230 >%d<        >0<           >0<
231 >%-d<       >0<           >0<
232 >%+d<       >0<           >+0<
233 >% d<       >0<           > 0<
234 >%0d<       >0<           >0<
235 >%-3d<      >1<           >1  <
236 >%+3d<      >1<           > +1<
237 >% 3d<      >1<           >  1<
238 >%03d<      >1<           >001<
239 >%+ 3d<     >1<           > +1<
240 >% +3d<     >1<           > +1<
241 >%.0d<      >0<           ><
242 >%+.0d<     >0<           >+<
243 >% .0d<     >0<           > <
244 >%-.0d<     >0<           ><
245 >%#.0d<     >0<           ><
246 >%.0d<      >1<           >1<
247 >%d<        >1<           >1<
248 >%+d<       >1<           >+1<
249 >%#3.2d<    >1<           > 01<            ># modifier: no effect<
250 >%3.2d<     >1<           > 01<
251 >%03.2d<    >1<           > 01<            >0 flag with precision: no effect<
252 >%-3.2d<    >1<           >01 <
253 >%+3.2d<    >1<           >+01<
254 >% 3.2d<    >1<           > 01<
255 >%-03.2d<   >1<           >01 <            >zero pad + left just.: no effect<
256 >%3.*d<     >[2,1]<       > 01<
257 >%3.*d<     >[1,1]<       >  1<
258 >%3.*d<     >[0,1]<       >  1<
259 >%3.*d<     >[-1,1]<      >  1<
260 >%.*d<      >[0,0]<       ><
261 >%-.*d<     >[0,0]<       ><
262 >%+.*d<     >[0,0]<       >+<
263 >% .*d<     >[0,0]<       > <
264 >%0.*d<     >[0,0]<       ><
265 >%.*d<      >[-2,0]<      >0<
266 >%-.*d<     >[-2,0]<      >0<
267 >%+.*d<     >[-2,0]<      >+0<
268 >% .*d<     >[-2,0]<      > 0<
269 >%0.*d<     >[-2,0]<      >0<
270 >%d<        >-1<          >-1<
271 >%-d<       >-1<          >-1<
272 >%+d<       >-1<          >-1<
273 >% d<       >-1<          >-1<
274 >%-3d<      >-1<          >-1 <
275 >%+3d<      >-1<          > -1<
276 >% 3d<      >-1<          > -1<
277 >%03d<      >-1<          >-01<
278 >%hd<       >1<           >1<              >More extensive testing of<
279 >%ld<       >1<           >1<              >length modifiers would be<
280 >%Vd<       >1<           >1<              >platform-specific<
281 >%vd<       >chr(1)<      >1<
282 >%+vd<      >chr(1)<      >+1<
283 >%#vd<      >chr(1)<      >1<
284 >%vd<       >"\01\02\03"< >1.2.3<
285 >%vd<       >v1.2.3<      >1.2.3<
286 >%vd<       >[version::qv("1.2.3")]< >1.2.3<
287 >%vd<       >[version->new("1.2")]< >1.200<
288 >%vd<       >[version->new("1.02")]< >1.20<
289 >%vd<       >[version->new("1.002")]< >1.2<
290 >%vd<       >[version->new("1048576.5")]< >1048576.500<
291 >%vd<       >[version->new("50")]< >50.0<
292 >%v.3d<     >"\01\02\03"< >001.002.003<
293 >%0v3d<     >"\01\02\03"< >001.002.003<
294 >%v.3d<     >[version::qv("1.2.3")]< >001.002.003<
295 >%-v3d<     >"\01\02\03"< >1  .2  .3  <
296 >%+-v3d<    >"\01\02\03"< >+1 .2  .3  <
297 >%+-v3d<    >[version::qv("1.2.3")]< >+1 .2  .3  <
298 >%v4.3d<    >"\01\02\03"< > 001. 002. 003<
299 >%0v4.3d<   >"\01\02\03"< > 001. 002. 003<
300 >%0*v2d<    >['-', "\0\7\14"]< >00-07-12<
301 >%v.*d<     >["\01\02\03", 3]< >001.002.003<
302 >%0v*d<     >["\01\02\03", 3]< >001.002.003<
303 >%-v*d<     >["\01\02\03", 3]< >1  .2  .3  <
304 >%+-v*d<    >["\01\02\03", 3]< >+1 .2  .3  <
305 >%v*.*d<    >["\01\02\03", 4, 3]< > 001. 002. 003<
306 >%0v*.*d<   >["\01\02\03", 4, 3]< > 001. 002. 003<
307 >%0*v*d<    >['-', "\0\7\13", 2]< >00-07-11<
308 >%0*v*d<    >['-', version::qv("0.7.11"), 2]< >00-07-11<
309 >%e<        >1234.875<    >1.234875e+03<
310 >%e<        >0.000012345< >1.234500e-05<
311 >%e<        >1234567E96<  >1.234567e+102<
312 >%e<        >0<           >0.000000e+00<
313 >%e<        >.1234567E-101< >1.234567e-102<
314 >%+e<       >1234.875<    >+1.234875e+03<
315 >%#e<       >1234.875<    >1.234875e+03<
316 >%e<        >-1234.875<   >-1.234875e+03<
317 >%+e<       >-1234.875<   >-1.234875e+03<
318 >%#e<       >-1234.875<   >-1.234875e+03<
319 >%.0e<      >1234.875<    >1e+03<
320 >%#.0e<     >1234.875<    >1.e+03<
321 >%.0e<      >1.875<       >2e+00<
322 >%.0e<      >0.875<       >9e-01<
323 >%.*e<      >[0, 1234.875]< >1e+03<
324 >%.1e<      >1234.875<    >1.2e+03<
325 >%-12.4e<   >1234.875<    >1.2349e+03  <
326 >%12.4e<    >1234.875<    >  1.2349e+03<
327 >%+-12.4e<  >1234.875<    >+1.2349e+03 <
328 >%+12.4e<   >1234.875<    > +1.2349e+03<
329 >%+-12.4e<  >-1234.875<   >-1.2349e+03 <
330 >%+12.4e<   >-1234.875<   > -1.2349e+03<
331 >%e<        >1234567E96<  >1.234567e+102<       >exponent too big skip: os390<
332 >%e<        >.1234567E-101< >1.234567e-102<     >exponent too small skip: os390<
333 >%f<        >1234.875<    >1234.875000<
334 >%+f<       >1234.875<    >+1234.875000<
335 >%#f<       >1234.875<    >1234.875000<
336 >%f<        >-1234.875<   >-1234.875000<
337 >%+f<       >-1234.875<   >-1234.875000<
338 >%#f<       >-1234.875<   >-1234.875000<
339 >%6f<       >1234.875<    >1234.875000<
340 >%*f<       >[6, 1234.875]< >1234.875000<
341 >%.0f<      >-0.1<        >-0<  >C library bug: no minus skip: VMS<
342 >%.0f<      >1234.875<    >1235<
343 >%.1f<      >1234.875<    >1234.9<
344 >%-8.1f<    >1234.875<    >1234.9  <
345 >%8.1f<     >1234.875<    >  1234.9<
346 >%+-8.1f<   >1234.875<    >+1234.9 <
347 >%+8.1f<    >1234.875<    > +1234.9<
348 >%+-8.1f<   >-1234.875<   >-1234.9 <
349 >%+8.1f<    >-1234.875<   > -1234.9<
350 >%*.*f<     >[5, 2, 12.3456]< >12.35<
351 >%f<        >0<           >0.000000<
352 >%.0f<      >0<           >0<
353 >%.0f<      >2**38<       >274877906944<   >Should have exact int'l rep'n<
354 >%.0f<      >0.1<         >0<
355 >%.0f<      >0.6<         >1<              >Known to fail with sfio, (irix|nonstop-ux|powerux); -DHAS_LDBL_SPRINTF_BUG may fix<
356 >%.0f<      >-0.6<        >-1<             >Known to fail with sfio, (irix|nonstop-ux|powerux); -DHAS_LDBL_SPRINTF_BUG may fix<
357 >%.0f<      >1.6<         >2<
358 >%.0f<      >-1.6<        >-2<
359 >%.0f<      >1<           >1<
360 >%#.0f<     >1<           >1.<
361 >%.0lf<     >1<           >1<              >'l' should have no effect<
362 >%.0hf<     >1<           >%.0hf INVALID<  >'h' should be rejected<
363 >%g<        >12345.6789<  >12345.7<
364 >%+g<       >12345.6789<  >+12345.7<
365 >%#g<       >12345.6789<  >12345.7<
366 >%.0g<      >-0.0<        >-0<             >C99 standard mandates minus sign but C89 does not skip: MSWin32 VMS hpux:10.20 openbsd netbsd:1.5 irix darwin<
367 >%.0g<      >12345.6789<  >1e+04<
368 >%#.0g<     >12345.6789<  >1.e+04<
369 >%.2g<      >12345.6789<  >1.2e+04<
370 >%.*g<      >[2, 12345.6789]< >1.2e+04<
371 >%.9g<      >12345.6789<  >12345.6789<
372 >%12.9g<    >12345.6789<  >  12345.6789<
373 >%012.9g<   >12345.6789<  >0012345.6789<
374 >%-12.9g<   >12345.6789<  >12345.6789  <
375 >%*.*g<     >[-12, 9, 12345.6789]< >12345.6789  <
376 >%-012.9g<  >12345.6789<  >12345.6789  <
377 >%g<        >-12345.6789< >-12345.7<
378 >%+g<       >-12345.6789< >-12345.7<
379 >%g<        >1234567.89<  >1.23457e+06<
380 >%+g<       >1234567.89<  >+1.23457e+06<
381 >%#g<       >1234567.89<  >1.23457e+06<
382 >%g<        >-1234567.89< >-1.23457e+06<
383 >%+g<       >-1234567.89< >-1.23457e+06<
384 >%#g<       >-1234567.89< >-1.23457e+06<
385 >%g<        >0.00012345<  >0.00012345<
386 >%g<        >0.000012345< >1.2345e-05<
387 >%g<        >1234567E96<  >1.23457e+102<
388 >%g<        >.1234567E-101< >1.23457e-102<
389 >%g<        >0<           >0<
390 >%13g<      >1234567.89<  >  1.23457e+06<
391 >%+13g<     >1234567.89<  > +1.23457e+06<
392 >%013g<     >1234567.89<  >001.23457e+06<
393 >%-13g<     >1234567.89<  >1.23457e+06  <
394 >%g<        >.1234567E-101< >1.23457e-102<      >exponent too small skip: os390<
395 >%g<        >1234567E96<  >1.23457e+102<        >exponent too big skip: os390<
396 >%h<        >''<          >%h INVALID<
397 >%i<        >123456.789<  >123456<         >Synonym for %d<
398 >%j<        >''<          >%j INVALID<
399 >%k<        >''<          >%k INVALID<
400 >%l<        >''<          >%l INVALID<
401 >%m<        >''<          >%m INVALID<
402 >%s< >sprintf('%%n%n %d', $n, $n)< >%n 2< >Slight sneakiness to test %n<
403 >%o<        >2**32-1<     >37777777777<
404 >%+o<       >2**32-1<     >37777777777<
405 >%#o<       >2**32-1<     >037777777777<
406 >%o<        >642<         >1202<          >check smaller octals across platforms<
407 >%+o<       >642<         >1202<
408 >% o<       >642<         >1202<
409 >%#o<       >642<         >01202<
410 >%4o<       >18<          >  22<
411 >%4.3o<     >18<          > 022<
412 >%-4.3o<    >18<          >022 <
413 >%+4.3o<    >18<          > 022<
414 >% 4.3o<    >18<          > 022<
415 >%04.3o<    >18<          > 022<          >0 flag with precision: no effect<
416 >%4.o<      >36<          >  44<
417 >%-4.o<     >36<          >44  <
418 >%+4.o<     >36<          >  44<
419 >% 4.o<     >36<          >  44<
420 >%04.o<     >36<          >  44<          >0 flag with precision: no effect<
421 >%.3o<      >18<          >022<
422 >%#4o<      >17<          > 021<
423 >%#-4o<     >17<          >021 <
424 >%-#4o<     >17<          >021 <
425 >%#+4o<     >17<          > 021<
426 >%# 4o<     >17<          > 021<
427 >%#04o<     >17<          >0021<
428 >%#4.o<     >16<          > 020<
429 >%#-4.o<    >16<          >020 <
430 >%-#4.o<    >16<          >020 <
431 >%#+4.o<    >16<          > 020<
432 >%# 4.o<    >16<          > 020<
433 >%#04.o<    >16<          > 020<          >0 flag with precision: no effect<
434 >%#4.3o<    >18<          > 022<
435 >%#-4.3o<   >18<          >022 <
436 >%-#4.3o<   >18<          >022 <
437 >%#+4.3o<   >18<          > 022<
438 >%# 4.3o<   >18<          > 022<
439 >%#04.3o<   >18<          > 022<          >0 flag with precision: no effect<
440 >%#6.4o<    >18<          >  0022<
441 >%#-6.4o<   >18<          >0022  <
442 >%-#6.4o<   >18<          >0022  <
443 >%#+6.4o<   >18<          >  0022<
444 >%# 6.4o<   >18<          >  0022<
445 >%#06.4o<   >18<          >  0022<        >0 flag with precision: no effect<
446 >%d< >$p=sprintf('%p',$p);$p=~/^[0-9a-f]+$/< >1< >Coarse hack: hex from %p?<
447 >%d< >$p=sprintf('%-8p',$p);$p=~/^[0-9a-f]+\s*$/< >1< >Coarse hack: hex from %p?<
448 >%#p<       >''<          >%#p INVALID<
449 >%q<        >''<          >%q INVALID<
450 >%r<        >''<          >%r INVALID<
451 >%s<        >'string'<    >string<
452 >%10s<      >'string'<    >    string<
453 >%+10s<     >'string'<    >    string<
454 >%#10s<     >'string'<    >    string<
455 >%010s<     >'string'<    >0000string<
456 >%0*s<      >[10, 'string']< >0000string<
457 >%-10s<     >'string'<    >string    <
458 >%3s<       >'string'<    >string<
459 >%.3s<      >'string'<    >str<
460 >%.*s<      >[3, 'string']< >str<
461 >%.*s<      >[2, 'string']< >st<
462 >%.*s<      >[1, 'string']< >s<
463 >%.*s<      >[0, 'string']< ><
464 >%.*s<      >[-1,'string']< >string<  >negative precision to be ignored<
465 >%3.*s<     >[3, 'string']< >str<
466 >%3.*s<     >[2, 'string']< > st<
467 >%3.*s<     >[1, 'string']< >  s<
468 >%3.*s<     >[0, 'string']< >   <
469 >%3.*s<     >[-1,'string']< >string<  >negative precision to be ignored<
470 >%t<        >''<          >%t INVALID<
471 >%u<        >2**32-1<     >4294967295<
472 >%+u<       >2**32-1<     >4294967295<
473 >%#u<       >2**32-1<     >4294967295<
474 >%12u<      >2**32-1<     >  4294967295<
475 >%012u<     >2**32-1<     >004294967295<
476 >%-12u<     >2**32-1<     >4294967295  <
477 >%-012u<    >2**32-1<     >4294967295  <
478 >%4u<       >18<          >  18<
479 >%4.3u<     >18<          > 018<
480 >%-4.3u<    >18<          >018 <
481 >%+4.3u<    >18<          > 018<
482 >% 4.3u<    >18<          > 018<
483 >%04.3u<    >18<          > 018<         >0 flag with precision: no effect<
484 >%.3u<      >18<          >018<
485 >%v<        >''<          >%v INVALID<
486 >%w<        >''<          >%w INVALID<
487 >%x<        >2**32-1<     >ffffffff<
488 >%+x<       >2**32-1<     >ffffffff<
489 >%#x<       >2**32-1<     >0xffffffff<
490 >%10x<      >2**32-1<     >  ffffffff<
491 >%010x<     >2**32-1<     >00ffffffff<
492 >%-10x<     >2**32-1<     >ffffffff  <
493 >%-010x<    >2**32-1<     >ffffffff  <
494 >%0-10x<    >2**32-1<     >ffffffff  <
495 >%4x<       >18<          >  12<
496 >%4.3x<     >18<          > 012<
497 >%-4.3x<    >18<          >012 <
498 >%+4.3x<    >18<          > 012<
499 >% 4.3x<    >18<          > 012<
500 >%04.3x<    >18<          > 012<         >0 flag with precision: no effect<
501 >%.3x<      >18<          >012<
502 >%4X<       >28<          >  1C<
503 >%4.3X<     >28<          > 01C<
504 >%-4.3X<    >28<          >01C <
505 >%+4.3X<    >28<          > 01C<
506 >% 4.3X<    >28<          > 01C<
507 >%04.3X<    >28<          > 01C<         >0 flag with precision: no effect<
508 >%.3X<      >28<          >01C<
509 >%.0x<      >0<           ><
510 >%+.0x<     >0<           ><
511 >% .0x<     >0<           ><
512 >%-.0x<     >0<           ><
513 >%#.0x<     >0<           ><
514 >%#4x<      >28<          >0x1c<
515 >%#4.3x<    >28<          >0x01c<
516 >%#-4.3x<   >28<          >0x01c<
517 >%#+4.3x<   >28<          >0x01c<
518 >%# 4.3x<   >28<          >0x01c<
519 >%#04.3x<   >28<          >0x01c<         >0 flag with precision: no effect<
520 >%#.3x<     >28<          >0x01c<
521 >%#6.3x<    >28<          > 0x01c<
522 >%#-6.3x<   >28<          >0x01c <
523 >%-#6.3x<   >28<          >0x01c <
524 >%#+6.3x<   >28<          > 0x01c<
525 >%+#6.3x<   >28<          > 0x01c<
526 >%# 6.3x<   >28<          > 0x01c<
527 >% #6.3x<   >28<          > 0x01c<
528 >%0*x<      >[-10, ,2**32-1]< >ffffffff  <
529 >%vx<       >[version::qv("1.2.3")]< >1.2.3<
530 >%vx<       >[version::qv("1.20.300")]< >1.14.12c<
531 >%.*x<      >[0,0]<       ><
532 >%-.*x<     >[0,0]<       ><
533 >%+.*x<     >[0,0]<       ><
534 >% .*x<     >[0,0]<       ><
535 >%0.*x<     >[0,0]<       ><
536 >%.*x<      >[-3,0]<      >0<
537 >%-.*x<     >[-3,0]<      >0<
538 >%+.*x<     >[-3,0]<      >0<
539 >% .*x<     >[-3,0]<      >0<
540 >%0.*x<     >[-3,0]<      >0<
541 >%#.*x<     >[0,0]<       ><
542 >%#-.*x<    >[0,0]<       ><
543 >%#+.*x<    >[0,0]<       ><
544 >%# .*x<    >[0,0]<       ><
545 >%#0.*x<    >[0,0]<       ><
546 >%#.*x<     >[-1,0]<      >0<
547 >%#-.*x<    >[-1,0]<      >0<
548 >%#+.*x<    >[-1,0]<      >0<
549 >%# .*x<    >[-1,0]<      >0<
550 >%#0.*x<    >[-1,0]<      >0<
551 >%y<        >''<          >%y INVALID<
552 >%z<        >''<          >%z INVALID<
553 >%2$d %1$d<     >[12, 34]<      >34 12<
554 >%*2$d<         >[12, 3]<       > 12<
555 >%2$d %d<       >[12, 34]<      >34 12<
556 >%2$d %d %d<    >[12, 34]<      >34 12 34<
557 >%3$d %d %d<    >[12, 34, 56]<  >56 12 34<
558 >%2$*3$d %d<    >[12, 34, 3]<   > 34 12<
559 >%*3$2$d %d<    >[12, 34, 3]<   >%*3$2$d 12 INVALID<
560 >%2$d<          >12<    >0 UNINIT<
561 >%0$d<          >12<    >%0$d INVALID<
562 >%1$$d<         >12<    >%1$$d INVALID<
563 >%1$1$d<        >12<    >%1$1$d INVALID<
564 >%*2$*2$d<      >[12, 3]<       >%*2$*2$d INVALID<
565 >%*2*2$d<       >[12, 3]<       >%*2*2$d INVALID<
566 >%*2$1d<        >[12, 3]<       >%*2$1d INVALID<
567 >%0v2.2d<       >''<    ><
568 >%vc,%d<        >[63, 64, 65]<  >%vc,63 INVALID<
569 >%v%,%d<        >[63, 64, 65]<  >%v%,63 INVALID<
570 >%vd,%d<        >["\x1", 2, 3]< >1,2<
571 >%vf,%d<        >[1, 2, 3]<     >%vf,1 INVALID<
572 >%vF,%d<        >[1, 2, 3]<     >%vF,1 INVALID<
573 >%ve,%d<        >[1, 2, 3]<     >%ve,1 INVALID<
574 >%vE,%d<        >[1, 2, 3]<     >%vE,1 INVALID<
575 >%vg,%d<        >[1, 2, 3]<     >%vg,1 INVALID<
576 >%vG,%d<        >[1, 2, 3]<     >%vG,1 INVALID<
577 >%vp<   >''<    >%vp INVALID<
578 >%vn<   >''<    >%vn INVALID<
579 >%vs,%d<        >[1, 2, 3]<     >%vs,1 INVALID<
580 >%v_<   >''<    >%v_ INVALID<
581 >%v#x<  >''<    >%v#x INVALID<
582 >%v02x< >"\x66\x6f\x6f\012"<    >66.6f.6f.0a<
583 >%#v.8b<        >"\141\000\142"<        >0b01100001.00000000.0b01100010<        >perl #39530<
584 >%#v.4o<        >"\141\000\142"<        >0141.0000.0142<        >perl #39530<
585 >%#v.3i<        >"\141\000\142"<        >097.000.098<   >perl #39530<
586 >%#v.2x<        >"\141\000\142"<        >0x61.00.0x62<  >perl #39530<
587 >%#v.2X<        >"\141\000\142"<        >0X61.00.0X62<  >perl #39530<
588 >%#v.8b<        >"\141\017\142"<        >0b01100001.0b00001111.0b01100010<      >perl #39530<
589 >%#v.4o<        >"\141\017\142"<        >0141.0017.0142<        >perl #39530<
590 >%#v.3i<        >"\141\017\142"<        >097.015.098<   >perl #39530<
591 >%#v.2x<        >"\141\017\142"<        >0x61.0x0f.0x62<        >perl #39530<
592 >%#v.2X<        >"\141\017\142"<        >0X61.0X0F.0X62<        >perl #39530<
593 >%#*v.8b<       >["][", "\141\000\142"]<        >0b01100001][00000000][0b01100010<      >perl #39530<
594 >%#*v.4o<       >["][", "\141\000\142"]<        >0141][0000][0142<      >perl #39530<
595 >%#*v.3i<       >["][", "\141\000\142"]<        >097][000][098< >perl #39530<
596 >%#*v.2x<       >["][", "\141\000\142"]<        >0x61][00][0x62<        >perl #39530<
597 >%#*v.2X<       >["][", "\141\000\142"]<        >0X61][00][0X62<        >perl #39530<
598 >%#*v.8b<       >["][", "\141\017\142"]<        >0b01100001][0b00001111][0b01100010<    >perl #39530<
599 >%#*v.4o<       >["][", "\141\017\142"]<        >0141][0017][0142<      >perl #39530<
600 >%#*v.3i<       >["][", "\141\017\142"]<        >097][015][098< >perl #39530<
601 >%#*v.2x<       >["][", "\141\017\142"]<        >0x61][0x0f][0x62<      >perl #39530<
602 >%#*v.2X<       >["][", "\141\017\142"]<        >0X61][0X0F][0X62<      >perl #39530<
603 >%#v.8b<        >"\141\x{1e01}\000\142\x{1e03}"<        >0b01100001.0b1111000000001.00000000.0b01100010.0b1111000000011<        >perl #39530<
604 >%#v.4o<        >"\141\x{1e01}\000\142\x{1e03}"<        >0141.017001.0000.0142.017003<  >perl #39530<
605 >%#v.3i<        >"\141\x{1e01}\000\142\x{1e03}"<        >097.7681.000.098.7683< >perl #39530<
606 >%#v.2x<        >"\141\x{1e01}\000\142\x{1e03}"<        >0x61.0x1e01.00.0x62.0x1e03<    >perl #39530<
607 >%#v.2X<        >"\141\x{1e01}\000\142\x{1e03}"<        >0X61.0X1E01.00.0X62.0X1E03<    >perl #39530<
608 >%#v.8b<        >"\141\x{1e01}\017\142\x{1e03}"<        >0b01100001.0b1111000000001.0b00001111.0b01100010.0b1111000000011<      >perl #39530<
609 >%#v.4o<        >"\141\x{1e01}\017\142\x{1e03}"<        >0141.017001.0017.0142.017003<  >perl #39530<
610 >%#v.3i<        >"\141\x{1e01}\017\142\x{1e03}"<        >097.7681.015.098.7683< >perl #39530<
611 >%#v.2x<        >"\141\x{1e01}\017\142\x{1e03}"<        >0x61.0x1e01.0x0f.0x62.0x1e03<  >perl #39530<
612 >%#v.2X<        >"\141\x{1e01}\017\142\x{1e03}"<        >0X61.0X1E01.0X0F.0X62.0X1E03<  >perl #39530<
613 >%V-%s<         >["Hello"]<     >%V-Hello INVALID<
614 >%K %d %d<      >[13, 29]<      >%K 13 29 INVALID<
615 >%*.*K %d<      >[13, 29, 76]<  >%*.*K 13 INVALID<
616 >%4$K %d<       >[45, 67]<      >%4$K 45 INVALID<
617 >%d %K %d<      >[23, 45]<      >23 %K 45 INVALID<
618 >%*v*999\$d %d %d<      >[11, 22, 33]<  >%*v*999\$d 11 22 INVALID<
619 >%#b<           >0<     >0<
620 >%#o<           >0<     >0<
621 >%#x<           >0<     >0<
622 >%2147483647$v2d<       >''<    ><
623 >%*2147483647$v2d<      >''<    > UNINIT<