This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove CR characters from raw input in op/magic.t on Windows
[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 >%hhd<      >1<           >1<              >length modifiers would be<
305 >%ld<       >1<           >1<              >platform-specific<
306 >%Vd<       >1<           >1<
307 >%zd<       >1<           >1<
308 >%td<       >1<           >1<
309 >%vd<       >chr(1)<      >1<
310 >%+vd<      >chr(1)<      >+1<
311 >%#vd<      >chr(1)<      >1<
312 >%vd<       >"\01\02\03"< >1.2.3<
313 >%vd<       >v1.2.3<      >1.2.3<
314 >%vd<       >[version::qv("1.2.3")]< >1.2.3<
315 >%vd<       >[version->new("1.2")]< >1.2<
316 >%vd<       >[version->new("1.02")]< >1.2<
317 >%vd<       >[version->new("1.002")]< >1.2<
318 >%vd<       >[version->new("1048576.5")]< >1048576.5<
319 >%vd<       >[version->new("50")]< >50<
320 >%v.3d<     >"\01\02\03"< >001.002.003<
321 >%0v3d<     >"\01\02\03"< >001.002.003<
322 >%v.3d<     >[version::qv("1.2.3")]< >001.002.003<
323 >%-v3d<     >"\01\02\03"< >1  .2  .3  <
324 >%+-v3d<    >"\01\02\03"< >+1 .2  .3  <
325 >%+-v3d<    >[version::qv("1.2.3")]< >+1 .2  .3  <
326 >%v4.3d<    >"\01\02\03"< > 001. 002. 003<
327 >%0v4.3d<   >"\01\02\03"< > 001. 002. 003<
328 >%0*v2d<    >['-', "\0\7\14"]< >00-07-12<
329 >%v.*d<     >[3, "\01\02\03"]< >001.002.003< >cf perl #83194<
330 >%0v*d<     >[3, "\01\02\03"]< >001.002.003< >cf perl #83194<
331 >%-v*d<     >[3, "\01\02\03"]< >1  .2  .3  < >cf perl #83194<
332 >%+-v*d<    >[3, "\01\02\03"]< >+1 .2  .3  < >cf perl #83194<
333 >%v*.*d<    >[4, 3, "\01\02\03"]< > 001. 002. 003< >cf perl #83194<
334 >%0v*.*d<   >[4, 3, "\01\02\03"]< > 001. 002. 003< >cf perl #83194<
335 >%0*v*d<    >['-', 2, "\0\7\13"]< >00-07-11< >cf perl #83194<
336 >%0*v*d<    >['-', 2, version::qv("0.7.11")]< >00-07-11< >cf perl #83194<
337 >%e<        >1234.875<    >1.234875e+03<
338 >%e<        >0.000012345< >1.234500e-05<
339 >%e<        >1234567E96<  >1.234567e+102<
340 >%e<        >0<           >0.000000e+00<
341 >%e<        >.1234567E-101< >1.234567e-102<
342 >%+e<       >1234.875<    >+1.234875e+03<
343 >%#e<       >1234.875<    >1.234875e+03<
344 >%e<        >-1234.875<   >-1.234875e+03<
345 >%+e<       >-1234.875<   >-1.234875e+03<
346 >%#e<       >-1234.875<   >-1.234875e+03<
347 >%.0e<      >1234.875<    >1e+03<
348 >%#.0e<     >1234.875<    >1.e+03<
349 >%.0e<      >1.875<       >2e+00<
350 >%.0e<      >0.875<       >9e-01<
351 >%.*e<      >[0, 1234.875]< >1e+03<
352 >%.1e<      >1234.875<    >1.2e+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 >%+12.4e<   >1234.875<    > +1.2349e+03<
357 >%+-12.4e<  >-1234.875<   >-1.2349e+03 <
358 >%+12.4e<   >-1234.875<   > -1.2349e+03<
359 >%e<        >1234567E96<  >1.234567e+102<       >exponent too big skip: os390<
360 >%e<        >.1234567E-101< >1.234567e-102<     >exponent too small skip: os390<
361 >%f<        >1234.875<    >1234.875000<
362 >%+f<       >1234.875<    >+1234.875000<
363 >%#f<       >1234.875<    >1234.875000<
364 >%f<        >-1234.875<   >-1234.875000<
365 >%+f<       >-1234.875<   >-1234.875000<
366 >%#f<       >-1234.875<   >-1234.875000<
367 >%6f<       >1234.875<    >1234.875000<
368 >%*f<       >[6, 1234.875]< >1234.875000<
369 >%.0f<      >-0.1<        >-0<  >C library bug: no minus skip: VMS<
370 >%.0f<      >1234.875<    >1235<
371 >%.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 >%+8.1f<    >1234.875<    > +1234.9<
376 >%+-8.1f<   >-1234.875<   >-1234.9 <
377 >%+8.1f<    >-1234.875<   > -1234.9<
378 >%*.*f<     >[5, 2, 12.3456]< >12.35<
379 >%f<        >0<           >0.000000<
380 >%.0f<      >[]<          >0 MISSING<
381 > %.0f<     >[]<          > 0 MISSING<
382 >%.2f<      >[]<          >0.00 MISSING<
383 >%.2fC<      >[]<          >0.00C MISSING<
384 >%.0f<      >0<           >0<
385 >%.0f<      >2**38<       >274877906944<   >Should have exact int'l rep'n<
386 >%.0f<      >0.1<         >0<
387 >%.0f<      >0.6<         >1<              >Known to fail with sfio, (irix|nonstop-ux|powerux); -DHAS_LDBL_SPRINTF_BUG may fix<
388 >%.0f<      >-0.6<        >-1<             >Known to fail with sfio, (irix|nonstop-ux|powerux); -DHAS_LDBL_SPRINTF_BUG may fix<
389 >%.0f<      >1.6<         >2<
390 >%.0f<      >-1.6<        >-2<
391 >%.0f<      >1<           >1<
392 >%#.0f<     >1<           >1.<
393 >%.0lf<     >1<           >1<              >'l' should have no effect<
394 >%.0hf<     >1<           >%.0hf INVALID<  >'h' should be rejected<
395 >%g<        >12345.6789<  >12345.7<
396 >%+g<       >12345.6789<  >+12345.7<
397 >%#g<       >12345.6789<  >12345.7<
398 >%.0g<      >[]<          >0 MISSING<
399 > %.0g<     >[]<          > 0 MISSING<
400 >%.2g<      >[]<          >0 MISSING<
401 >%.2gC<      >[]<          >0C MISSING<
402 >%.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 freebsd:4.9<
403 >%.0g<      >12345.6789<  >1e+04<
404 >%#.0g<     >12345.6789<  >1.e+04<
405 >%.2g<      >12345.6789<  >1.2e+04<
406 >%.*g<      >[2, 12345.6789]< >1.2e+04<
407 >%.9g<      >12345.6789<  >12345.6789<
408 >%12.9g<    >12345.6789<  >  12345.6789<
409 >%012.9g<   >12345.6789<  >0012345.6789<
410 >%-12.9g<   >12345.6789<  >12345.6789  <
411 >%*.*g<     >[-12, 9, 12345.6789]< >12345.6789  <
412 >%-012.9g<  >12345.6789<  >12345.6789  <
413 >%g<        >-12345.6789< >-12345.7<
414 >%+g<       >-12345.6789< >-12345.7<
415 >%g<        >1234567.89<  >1.23457e+06<
416 >%+g<       >1234567.89<  >+1.23457e+06<
417 >%#g<       >1234567.89<  >1.23457e+06<
418 >%g<        >-1234567.89< >-1.23457e+06<
419 >%+g<       >-1234567.89< >-1.23457e+06<
420 >%#g<       >-1234567.89< >-1.23457e+06<
421 >%g<        >0.00012345<  >0.00012345<
422 >%g<        >0.000012345< >1.2345e-05<
423 >%g<        >1234567E96<  >1.23457e+102<
424 >%g<        >.1234567E-101< >1.23457e-102<
425 >%g<        >0<           >0<
426 >%13g<      >1234567.89<  >  1.23457e+06<
427 >%+13g<     >1234567.89<  > +1.23457e+06<
428 >%013g<     >1234567.89<  >001.23457e+06<
429 >%-13g<     >1234567.89<  >1.23457e+06  <
430 >%g<        >.1234567E-101< >1.23457e-102<      >exponent too small skip: os390<
431 >%g<        >1234567E96<  >1.23457e+102<        >exponent too big skip: os390<
432 >%h<        >''<          >%h INVALID<
433 >%i<        >123456.789<  >123456<         >Synonym for %d<
434 >%j<        >''<          >%j INVALID<
435 >%k<        >''<          >%k INVALID<
436 >%l<        >''<          >%l INVALID<
437 >%m<        >''<          >%m INVALID<
438 >%s< >sprintf('%%n%n %d', $n, $n)< >%n 2< >Slight sneakiness to test %n<
439 >%s< >$n="abc"; sprintf(' %n%s', substr($n,1,1), $n)< > a1c< >%n w/magic<
440 >%s< >no warnings; sprintf('%s%n', chr(256)x5, $n),$n< >5< >Unicode %n<
441 >%o<        >2**32-1<     >37777777777<
442 >%+o<       >2**32-1<     >37777777777<
443 >%#o<       >2**32-1<     >037777777777<
444 >%o<        >642<         >1202<          >check smaller octals across platforms<
445 >%+o<       >642<         >1202<
446 >% o<       >642<         >1202<
447 >%#o<       >642<         >01202<
448 >%4o<       >18<          >  22<
449 >%4.3o<     >18<          > 022<
450 >%-4.3o<    >18<          >022 <
451 >%+4.3o<    >18<          > 022<
452 >% 4.3o<    >18<          > 022<
453 >%04.3o<    >18<          > 022<          >0 flag with precision: no effect<
454 >%4.o<      >36<          >  44<
455 >%-4.o<     >36<          >44  <
456 >%+4.o<     >36<          >  44<
457 >% 4.o<     >36<          >  44<
458 >%04.o<     >36<          >  44<          >0 flag with precision: no effect<
459 >%.3o<      >18<          >022<
460 >%.0o<      >0<           ><
461 >%+.0o<     >0<           ><
462 >% .0o<     >0<           ><
463 >%-.0o<     >0<           ><
464 >%#.0o<     >0<           >0<
465 >%#3.0o<    >0<           >  0<
466 >%#3.1o<    >0<           >  0<
467 >%#3.2o<    >0<           > 00<
468 >%#3.3o<    >0<           >000<
469 >%#3.4o<    >0<           >0000<
470 >%.0o<      >1<           >1<
471 >%+.0o<     >1<           >1<
472 >% .0o<     >1<           >1<
473 >%-.0o<     >1<           >1<
474 >%#.0o<     >1<           >01<
475 >%#3.0o<    >1<           > 01<
476 >%#3.1o<    >1<           > 01<
477 >%#3.2o<    >1<           > 01<
478 >%#3.3o<    >1<           >001<
479 >%#3.4o<    >1<           >0001<
480 >%#.5o<     >012345<      >012345<
481 >%#.5o<     >012<         >00012<
482 >%#4o<      >17<          > 021<
483 >%#-4o<     >17<          >021 <
484 >%-#4o<     >17<          >021 <
485 >%#+4o<     >17<          > 021<
486 >%# 4o<     >17<          > 021<
487 >%#04o<     >17<          >0021<
488 >%#4.o<     >16<          > 020<
489 >%#-4.o<    >16<          >020 <
490 >%-#4.o<    >16<          >020 <
491 >%#+4.o<    >16<          > 020<
492 >%# 4.o<    >16<          > 020<
493 >%#04.o<    >16<          > 020<          >0 flag with precision: no effect<
494 >%#4.3o<    >18<          > 022<
495 >%#-4.3o<   >18<          >022 <
496 >%-#4.3o<   >18<          >022 <
497 >%#+4.3o<   >18<          > 022<
498 >%# 4.3o<   >18<          > 022<
499 >%#04.3o<   >18<          > 022<          >0 flag with precision: no effect<
500 >%#6.4o<    >18<          >  0022<
501 >%#-6.4o<   >18<          >0022  <
502 >%-#6.4o<   >18<          >0022  <
503 >%#+6.4o<   >18<          >  0022<
504 >%# 6.4o<   >18<          >  0022<
505 >%#06.4o<   >18<          >  0022<        >0 flag with precision: no effect<
506 >%d< >$p=sprintf('%p',$p);$p=~/^[0-9a-f]+$/< >1< >Coarse hack: hex from %p?<
507 >%d< >$p=sprintf('%-8p',$p);$p=~/^[0-9a-f]+\s*$/< >1< >Coarse hack: hex from %p?<
508 >%#p<       >''<          >%#p INVALID<
509 >%q<        >''<          >%q INVALID<
510 >%r<        >''<          >%r INVALID<
511 >%s<        >[]<          > MISSING<
512 > %s<       >[]<          >  MISSING<
513 >%s<        >'string'<    >string<
514 >%10s<      >'string'<    >    string<
515 >%+10s<     >'string'<    >    string<
516 >%#10s<     >'string'<    >    string<
517 >%010s<     >'string'<    >0000string<
518 >%0*s<      >[10, 'string']< >0000string<
519 >%-10s<     >'string'<    >string    <
520 >%3s<       >'string'<    >string<
521 >%.3s<      >'string'<    >str<
522 >%.*s<      >[3, 'string']< >str<
523 >%.*s<      >[2, 'string']< >st<
524 >%.*s<      >[1, 'string']< >s<
525 >%.*s<      >[0, 'string']< ><
526 >%.*s<      >[-1,'string']< >string<  >negative precision to be ignored<
527 >%3.*s<     >[3, 'string']< >str<
528 >%3.*s<     >[2, 'string']< > st<
529 >%3.*s<     >[1, 'string']< >  s<
530 >%3.*s<     >[0, 'string']< >   <
531 >%3.*s<     >[-1,'string']< >string<  >negative precision to be ignored<
532 >%t<        >''<          >%t INVALID<
533 >%u<        >2**32-1<     >4294967295<
534 >%+u<       >2**32-1<     >4294967295<
535 >%#u<       >2**32-1<     >4294967295<
536 >%12u<      >2**32-1<     >  4294967295<
537 >%012u<     >2**32-1<     >004294967295<
538 >%-12u<     >2**32-1<     >4294967295  <
539 >%-012u<    >2**32-1<     >4294967295  <
540 >%4u<       >18<          >  18<
541 >%4.3u<     >18<          > 018<
542 >%-4.3u<    >18<          >018 <
543 >%+4.3u<    >18<          > 018<
544 >% 4.3u<    >18<          > 018<
545 >%04.3u<    >18<          > 018<         >0 flag with precision: no effect<
546 >%.3u<      >18<          >018<
547 >%v<        >''<          >%v INVALID<
548 >%w<        >''<          >%w INVALID<
549 >%x<        >2**32-1<     >ffffffff<
550 >%+x<       >2**32-1<     >ffffffff<
551 >%#x<       >2**32-1<     >0xffffffff<
552 >%10x<      >2**32-1<     >  ffffffff<
553 >%010x<     >2**32-1<     >00ffffffff<
554 >%-10x<     >2**32-1<     >ffffffff  <
555 >%-010x<    >2**32-1<     >ffffffff  <
556 >%0-10x<    >2**32-1<     >ffffffff  <
557 >%4x<       >18<          >  12<
558 >%4.3x<     >18<          > 012<
559 >%-4.3x<    >18<          >012 <
560 >%+4.3x<    >18<          > 012<
561 >% 4.3x<    >18<          > 012<
562 >%04.3x<    >18<          > 012<         >0 flag with precision: no effect<
563 >%.3x<      >18<          >012<
564 >%4X<       >28<          >  1C<
565 >%4.3X<     >28<          > 01C<
566 >%-4.3X<    >28<          >01C <
567 >%+4.3X<    >28<          > 01C<
568 >% 4.3X<    >28<          > 01C<
569 >%04.3X<    >28<          > 01C<         >0 flag with precision: no effect<
570 >%.3X<      >28<          >01C<
571 >%.0x<      >0<           ><
572 >%+.0x<     >0<           ><
573 >% .0x<     >0<           ><
574 >%-.0x<     >0<           ><
575 >%#.0x<     >0<           ><
576 >%#3.0x<    >0<           >   <
577 >%#3.1x<    >0<           >  0<
578 >%#3.2x<    >0<           > 00<
579 >%#3.3x<    >0<           >000<
580 >%#3.4x<    >0<           >0000<
581 >%.0x<      >1<           >1<
582 >%+.0x<     >1<           >1<
583 >% .0x<     >1<           >1<
584 >%-.0x<     >1<           >1<
585 >%#.0x<     >1<           >0x1<
586 >%#3.0x<    >1<           >0x1<
587 >%#3.1x<    >1<           >0x1<
588 >%#3.2x<    >1<           >0x01<
589 >%#3.3x<    >1<           >0x001<
590 >%#3.4x<    >1<           >0x0001<
591 >%#.5x<     >0x12345<     >0x12345<
592 >%#.5x<     >0x12<        >0x00012<
593 >%#4x<      >28<          >0x1c<
594 >%#4.3x<    >28<          >0x01c<
595 >%#-4.3x<   >28<          >0x01c<
596 >%#+4.3x<   >28<          >0x01c<
597 >%# 4.3x<   >28<          >0x01c<
598 >%#04.3x<   >28<          >0x01c<         >0 flag with precision: no effect<
599 >%#.3x<     >28<          >0x01c<
600 >%#6.3x<    >28<          > 0x01c<
601 >%#-6.3x<   >28<          >0x01c <
602 >%-#6.3x<   >28<          >0x01c <
603 >%#+6.3x<   >28<          > 0x01c<
604 >%+#6.3x<   >28<          > 0x01c<
605 >%# 6.3x<   >28<          > 0x01c<
606 >% #6.3x<   >28<          > 0x01c<
607 >%0*x<      >[-10, ,2**32-1]< >ffffffff  <
608 >%vx<       >[version::qv("1.2.3")]< >1.2.3<
609 >%vx<       >[version::qv("1.20.300")]< >1.14.12c<
610 >%.*x<      >[0,0]<       ><
611 >%-.*x<     >[0,0]<       ><
612 >%+.*x<     >[0,0]<       ><
613 >% .*x<     >[0,0]<       ><
614 >%0.*x<     >[0,0]<       ><
615 >%.*x<      >[-3,0]<      >0<
616 >%-.*x<     >[-3,0]<      >0<
617 >%+.*x<     >[-3,0]<      >0<
618 >% .*x<     >[-3,0]<      >0<
619 >%0.*x<     >[-3,0]<      >0<
620 >%#.*x<     >[0,0]<       ><
621 >%#-.*x<    >[0,0]<       ><
622 >%#+.*x<    >[0,0]<       ><
623 >%# .*x<    >[0,0]<       ><
624 >%#0.*x<    >[0,0]<       ><
625 >%#.*x<     >[-1,0]<      >0<
626 >%#-.*x<    >[-1,0]<      >0<
627 >%#+.*x<    >[-1,0]<      >0<
628 >%# .*x<    >[-1,0]<      >0<
629 >%#0.*x<    >[-1,0]<      >0<
630 >%y<        >''<          >%y INVALID<
631 >%z<        >''<          >%z INVALID<
632 >%2$d %1$d<     >[12, 34]<      >34 12<
633 >%*2$d<         >[12, 3]<       > 12<
634 >%2$d %d<       >[12, 34]<      >34 12<
635 >%2$d %d %d<    >[12, 34]<      >34 12 34<
636 >%3$d %d %d<    >[12, 34, 56]<  >56 12 34<
637 >%2$*3$d %d<    >[12, 34, 3]<   > 34 12<
638 >%*3$2$d %d<    >[12, 34, 3]<   >%*3$2$d 12 INVALID<
639 >%2$d<          >12<    >0 MISSING<
640 >%0$d<          >12<    >%0$d INVALID<
641 >%1$$d<         >12<    >%1$$d INVALID<
642 >%1$1$d<        >12<    >%1$1$d INVALID<
643 >%*2$*2$d<      >[12, 3]<       >%*2$*2$d INVALID<
644 >%*2*2$d<       >[12, 3]<       >%*2*2$d INVALID<
645 >%*2$1d<        >[12, 3]<       >%*2$1d INVALID<
646 >%0v2.2d<       >''<    ><
647 >%vc,%d<        >[63, 64, 65]<  >%vc,63 INVALID<
648 >%v%,%d<        >[63, 64, 65]<  >%v%,63 INVALID<
649 >%vd,%d<        >["\x1", 2, 3]< >1,2<
650 >%vf,%d<        >[1, 2, 3]<     >%vf,1 INVALID<
651 >%vF,%d<        >[1, 2, 3]<     >%vF,1 INVALID<
652 >%ve,%d<        >[1, 2, 3]<     >%ve,1 INVALID<
653 >%vE,%d<        >[1, 2, 3]<     >%vE,1 INVALID<
654 >%vg,%d<        >[1, 2, 3]<     >%vg,1 INVALID<
655 >%vG,%d<        >[1, 2, 3]<     >%vG,1 INVALID<
656 >%vp<   >''<    >%vp INVALID<
657 >%vn<   >''<    >%vn INVALID<
658 >%vs,%d<        >[1, 2, 3]<     >%vs,1 INVALID<
659 >%v_<   >''<    >%v_ INVALID<
660 >%v#x<  >''<    >%v#x INVALID<
661 >%v02x< >"\x66\x6f\x6f\012"<    >66.6f.6f.0a<
662 >%#v.8b<        >"\141\000\142"<        >0b01100001.00000000.0b01100010<        >perl #39530<
663 >%#v.0o<        >"\001\000\002\000"<    >01.0.02.0<
664 >%#v.1o<        >"\001\000\002\000"<    >01.0.02.0<
665 >%#v.4o<        >"\141\000\142"<        >0141.0000.0142<        >perl #39530<
666 >%#v.3i<        >"\141\000\142"<        >097.000.098<   >perl #39530<
667 >%#v.0x<        >"\001\000\002\000"<    >0x1..0x2.<
668 >%#v.1x<        >"\001\000\002\000"<    >0x1.0.0x2.0<
669 >%#v.2x<        >"\141\000\142"<        >0x61.00.0x62<  >perl #39530<
670 >%#v.2X<        >"\141\000\142"<        >0X61.00.0X62<  >perl #39530<
671 >%#v.8b<        >"\141\017\142"<        >0b01100001.0b00001111.0b01100010<      >perl #39530<
672 >%#v.4o<        >"\141\017\142"<        >0141.0017.0142<        >perl #39530<
673 >%#v.3i<        >"\141\017\142"<        >097.015.098<   >perl #39530<
674 >%#v.2x<        >"\141\017\142"<        >0x61.0x0f.0x62<        >perl #39530<
675 >%#v.2X<        >"\141\017\142"<        >0X61.0X0F.0X62<        >perl #39530<
676 >%#*v.8b<       >["][", "\141\000\142"]<        >0b01100001][00000000][0b01100010<      >perl #39530<
677 >%#*v.4o<       >["][", "\141\000\142"]<        >0141][0000][0142<      >perl #39530<
678 >%#*v.3i<       >["][", "\141\000\142"]<        >097][000][098< >perl #39530<
679 >%#*v.2x<       >["][", "\141\000\142"]<        >0x61][00][0x62<        >perl #39530<
680 >%#*v.2X<       >["][", "\141\000\142"]<        >0X61][00][0X62<        >perl #39530<
681 >%#*v.8b<       >["][", "\141\017\142"]<        >0b01100001][0b00001111][0b01100010<    >perl #39530<
682 >%#*v.4o<       >["][", "\141\017\142"]<        >0141][0017][0142<      >perl #39530<
683 >%#*v.3i<       >["][", "\141\017\142"]<        >097][015][098< >perl #39530<
684 >%#*v.2x<       >["][", "\141\017\142"]<        >0x61][0x0f][0x62<      >perl #39530<
685 >%#*v.2X<       >["][", "\141\017\142"]<        >0X61][0X0F][0X62<      >perl #39530<
686 >%#v.8b<        >"\141\x{1e01}\000\142\x{1e03}"<        >0b01100001.0b1111000000001.00000000.0b01100010.0b1111000000011<        >perl #39530<
687 >%#v.4o<        >"\141\x{1e01}\000\142\x{1e03}"<        >0141.017001.0000.0142.017003<  >perl #39530<
688 >%#v.3i<        >"\141\x{1e01}\000\142\x{1e03}"<        >097.7681.000.098.7683< >perl #39530<
689 >%#v.2x<        >"\141\x{1e01}\000\142\x{1e03}"<        >0x61.0x1e01.00.0x62.0x1e03<    >perl #39530<
690 >%#v.2X<        >"\141\x{1e01}\000\142\x{1e03}"<        >0X61.0X1E01.00.0X62.0X1E03<    >perl #39530<
691 >%#v.8b<        >"\141\x{1e01}\017\142\x{1e03}"<        >0b01100001.0b1111000000001.0b00001111.0b01100010.0b1111000000011<      >perl #39530<
692 >%#v.4o<        >"\141\x{1e01}\017\142\x{1e03}"<        >0141.017001.0017.0142.017003<  >perl #39530<
693 >%#v.3i<        >"\141\x{1e01}\017\142\x{1e03}"<        >097.7681.015.098.7683< >perl #39530<
694 >%#v.2x<        >"\141\x{1e01}\017\142\x{1e03}"<        >0x61.0x1e01.0x0f.0x62.0x1e03<  >perl #39530<
695 >%#v.2X<        >"\141\x{1e01}\017\142\x{1e03}"<        >0X61.0X1E01.0X0F.0X62.0X1E03<  >perl #39530<
696 >%V-%s<         >["Hello"]<     >%V-Hello INVALID<
697 >%K %d %d<      >[13, 29]<      >%K 13 29 INVALID<
698 >%*.*K %d<      >[13, 29, 76]<  >%*.*K 13 INVALID<
699 >%4$K %d<       >[45, 67]<      >%4$K 45 MISSING INVALID<
700 >%d %K %d<      >[23, 45]<      >23 %K 45 INVALID<
701 >%*v*999\$d %d %d<      >[11, 22, 33]<  >%*v*999\$d 11 22 INVALID<
702 >%#b<           >0<     >0<
703 >%#o<           >0<     >0<
704 >%#x<           >0<     >0<
705 >%2147483647$v2d<       >''<    ><
706 >%*2147483647$v2d<      >''<    > MISSING<
707 >%.3X<          >[11]<                  >00B<           >perl #83194: hex, zero-padded to 3 places<
708 >%.*X<          >[3, 11]<               >00B<           >perl #83194: dynamic precision<
709 >%vX<           >['012']<               >30.31.32<      >perl #83194: vector flag<
710 >%*vX<          >[':', '012']<          >30:31:32<      >perl #83194: vector flag + custom separator<
711 >%v.3X<         >['012']<               >030.031.032<   >perl #83194: vector flag + static precision<
712 >%v.*X<         >[3, '012']<            >030.031.032<   >perl #83194: vector flag + dynamic precision<
713 >%*v.3X<        >[':', '012']<          >030:031:032<   >perl #83194: vector flag + custom separator + static precision<
714 >%*v.*X<        >[':', 3, '012']<       >030:031:032<   >perl #83194: vector flag + custom separator + dynamic precision<
715 >%vd<   >"version"<     >118.101.114.115.105.111.110<   >perl #102586: vector flag + "version"<