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