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