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