This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
dial back warnings on UNIVERSAL->import
[perl5.git] / t / op / sprintf.t
CommitLineData
8d063cd8
LW
1#!./perl
2
be3174d2
GS
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
GS
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
PP
18my @tests = ();
19my ($i, $template, $data, $result, $comment, $w, $x, $evalData, $n, $p);
9f1b1f2d 20
8234e14b 21my $Is_VMS_VAX = 0;
2fba3065
PP
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
PP
27}
28
eaf637cf
JH
29# No %Config.
30my $Is_Ultrix_VAX = $^O eq 'ultrix' && `uname -m` =~ /^VAX$/;
31
0a52d15b
NC
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
PP
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
JH
43 # ccflags =~ /float=ieee/ on VAX.
44 # AXP is unaffected whether or not it's using ieee.
8234e14b
PP
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
NC
50
51 $evalData = eval $data;
7d847322
YST
52 $evalData = ref $evalData ? $evalData : [$evalData];
53 push @tests, [$template, $evalData, $result, $comment, $data];
0a52d15b
NC
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';
7baa4690
HS
63 } elsif ($_[0] =~ /^Missing argument/) {
64 $w = ' MISSING';
0a52d15b
NC
65 } else {
66 warn @_;
67 }
68};
69
70for ($i = 1; @tests; $i++) {
7d847322 71 ($template, $evalData, $result, $comment, $data) = @{shift @tests};
be3174d2 72 $w = undef;
7d847322 73 $x = sprintf(">$template<", @$evalData);
be3174d2 74 substr($x, -1, 0) = $w if $w;
48237dde
GS
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 }
65c97e0f
GS
90 }
91
e24bffee
MB
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;
6f1f3b4a 105 $skip = $vsn ? ($osv <= $vsn ? 1 : 0) : 1;
e24bffee
MB
106 }
107 $skip and $comment =~ s/$/, failure expected on $^O $osv/;
108 }
109
be3174d2
GS
110 if ($x eq ">$result<") {
111 print "ok $i\n";
112 }
e24bffee
MB
113 elsif ($skip) {
114 print "ok $i # skip $comment\n";
115 }
48237dde 116 elsif ($y eq ">$result<") # Some C libraries always give
65c97e0f 117 { # three-digit exponent
00b6c67e 118 print("ok $i # >$result< $x three-digit exponent accepted\n");
65c97e0f 119 }
f7137e37
DD
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 {
00b6c67e 126 print("ok $i # >$template< >$data< >$result<",
e24bffee 127 " Suppressed: exponent out of range?\n");
f7137e37 128 }
be3174d2 129 else {
48237dde
GS
130 $y = ($x eq $y ? "" : " => $y");
131 print("not ok $i >$template< >$data< >$result< $x$y",
65c97e0f 132 $comment ? " # $comment\n" : "\n");
fb73857a 133 }
134}
48237dde 135
a6d05634 136# In each of the following lines, there are three required fields:
be3174d2
GS
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#
e24bffee
MB
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<
6f1f3b4a 154# >%.0g< >-0.0< >-0< >No minus skip: MSWin32 VMS hpux:10.20<
e24bffee
MB
155# >%d< >4< >1< >4 != 1 skip: all<
156#
02a4ca6d
DD
157# The following tests are not currently run, for the reasons stated:
158
159=pod
160
161=begin problematic
162
02a4ca6d
DD
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
be3174d2
GS
170# template data result
171__END__
be3174d2 172>%6. 6s< >''< >%6. 6s INVALID< >(See use of $w in code above)<
c2e66d9e 173>%6 .6s< >''< >%6 .6s INVALID<
be3174d2 174>%6.6 s< >''< >%6.6 s INVALID<
c2e66d9e 175>%A< >''< >%A INVALID<
7ff06cc7
NC
176>%B< >2**32-1< >11111111111111111111111111111111<
177>%+B< >2**32-1< >11111111111111111111111111111111<
178>%#B< >2**32-1< >0B11111111111111111111111111111111<
be3174d2
GS
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"<
c2e66d9e
GS
184>%G< >1234567e96< >1.23457E+102<
185>%G< >.1234567e-101< >1.23457E-102<
be3174d2 186>%G< >12345.6789< >12345.7<
e24bffee
MB
187>%G< >1234567e96< >1.23457E+102< >exponent too big skip: os390<
188>%G< >.1234567e-101< >1.23457E-102< >exponent too small skip: os390<
be3174d2
GS
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<
8234e14b 196>%O< >2**32-1< >37777777777< >Synonym for %lo<
be3174d2
GS
197>%P< >''< >%P INVALID<
198>%Q< >''< >%Q INVALID<
199>%R< >''< >%R INVALID<
200>%S< >''< >%S INVALID<
201>%T< >''< >%T INVALID<
8234e14b 202>%U< >2**32-1< >4294967295< >Synonym for %lu<
be3174d2
GS
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 <
9911cee9
TS
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<
e6bb52fd
TS
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<
be3174d2
GS
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<
9911cee9 255>%-d< >0< >0<
be3174d2 256>%+d< >0< >+0<
9911cee9 257>% d< >0< > 0<
be3174d2 258>%0d< >0< >0<
9911cee9
TS
259>%-3d< >1< >1 <
260>%+3d< >1< > +1<
261>% 3d< >1< > 1<
262>%03d< >1< >001<
263>%+ 3d< >1< > +1<
264>% +3d< >1< > +1<
be3174d2
GS
265>%.0d< >0< ><
266>%+.0d< >0< >+<
9911cee9
TS
267>% .0d< >0< > <
268>%-.0d< >0< ><
269>%#.0d< >0< ><
be3174d2
GS
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<
9911cee9 275>%03.2d< >1< > 01< >0 flag with precision: no effect<
be3174d2 276>%-3.2d< >1< >01 <
9911cee9
TS
277>%+3.2d< >1< >+01<
278>% 3.2d< >1< > 01<
be3174d2 279>%-03.2d< >1< >01 < >zero pad + left just.: no effect<
9911cee9
TS
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<
be3174d2 294>%d< >-1< >-1<
9911cee9 295>%-d< >-1< >-1<
be3174d2 296>%+d< >-1< >-1<
9911cee9
TS
297>% d< >-1< >-1<
298>%-3d< >-1< >-1 <
299>%+3d< >-1< > -1<
300>% 3d< >-1< > -1<
301>%03d< >-1< >-01<
be3174d2
GS
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<
18eaf740
GA
309>%vd< >v1.2.3< >1.2.3<
310>%vd< >[version::qv("1.2.3")]< >1.2.3<
8cb289bd
RGS
311>%vd< >[version->new("1.2")]< >1.2<
312>%vd< >[version->new("1.02")]< >1.2<
34ba6322 313>%vd< >[version->new("1.002")]< >1.2<
8cb289bd
RGS
314>%vd< >[version->new("1048576.5")]< >1048576.5<
315>%vd< >[version->new("50")]< >50<
be3174d2 316>%v.3d< >"\01\02\03"< >001.002.003<
211dfcf1 317>%0v3d< >"\01\02\03"< >001.002.003<
96b8f7ce 318>%v.3d< >[version::qv("1.2.3")]< >001.002.003<
211dfcf1
HS
319>%-v3d< >"\01\02\03"< >1 .2 .3 <
320>%+-v3d< >"\01\02\03"< >+1 .2 .3 <
96b8f7ce 321>%+-v3d< >[version::qv("1.2.3")]< >+1 .2 .3 <
be3174d2 322>%v4.3d< >"\01\02\03"< > 001. 002. 003<
9911cee9 323>%0v4.3d< >"\01\02\03"< > 001. 002. 003<
211dfcf1
HS
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<
9911cee9 330>%0v*.*d< >["\01\02\03", 4, 3]< > 001. 002. 003<
211dfcf1 331>%0*v*d< >['-', "\0\7\13", 2]< >00-07-11<
96b8f7ce 332>%0*v*d< >['-', version::qv("0.7.11"), 2]< >00-07-11<
be3174d2 333>%e< >1234.875< >1.234875e+03<
c2e66d9e
GS
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<
be3174d2
GS
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<
02a4ca6d 344>%#.0e< >1234.875< >1.e+03<
20f6aaab
AS
345>%.0e< >1.875< >2e+00<
346>%.0e< >0.875< >9e-01<
be3174d2
GS
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<
e24bffee
MB
355>%e< >1234567E96< >1.234567e+102< >exponent too big skip: os390<
356>%e< >.1234567E-101< >1.234567e-102< >exponent too small skip: os390<
be3174d2
GS
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<
e24bffee 365>%.0f< >-0.1< >-0< >C library bug: no minus skip: VMS<
be3174d2
GS
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<
c2e66d9e
GS
375>%f< >0< >0.000000<
376>%.0f< >0< >0<
377>%.0f< >2**38< >274877906944< >Should have exact int'l rep'n<
d5365ef1 378>%.0f< >0.1< >0<
20f6aaab
AS
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<
02a4ca6d
DD
383>%.0f< >1< >1<
384>%#.0f< >1< >1.<
00e17364
HS
385>%.0lf< >1< >1< >'l' should have no effect<
386>%.0hf< >1< >%.0hf INVALID< >'h' should be rejected<
be3174d2
GS
387>%g< >12345.6789< >12345.7<
388>%+g< >12345.6789< >+12345.7<
389>%#g< >12345.6789< >12345.7<
4c749b6f 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<
be3174d2 391>%.0g< >12345.6789< >1e+04<
02a4ca6d 392>%#.0g< >12345.6789< >1.e+04<
be3174d2
GS
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<
c2e66d9e
GS
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<
be3174d2
GS
414>%13g< >1234567.89< > 1.23457e+06<
415>%+13g< >1234567.89< > +1.23457e+06<
e24bffee
MB
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<
be3174d2
GS
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<
8234e14b
PP
430>%o< >642< >1202< >check smaller octals across platforms<
431>%+o< >642< >1202<
9911cee9 432>% o< >642< >1202<
8234e14b 433>%#o< >642< >01202<
9911cee9
TS
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<
e6bb52fd
TS
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<
9911cee9
TS
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<
be3174d2 492>%d< >$p=sprintf('%p',$p);$p=~/^[0-9a-f]+$/< >1< >Coarse hack: hex from %p?<
0dbb1585 493>%d< >$p=sprintf('%-8p',$p);$p=~/^[0-9a-f]+\s*$/< >1< >Coarse hack: hex from %p?<
d5365ef1 494>%#p< >''< >%#p INVALID<
be3174d2
GS
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<
9911cee9
TS
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<
be3174d2
GS
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 <
9911cee9
TS
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<
be3174d2
GS
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 <
9911cee9
TS
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< ><
e6bb52fd
TS
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<
9911cee9
TS
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<
be3174d2 591>%0*x< >[-10, ,2**32-1]< >ffffffff <
96b8f7ce
JP
592>%vx< >[version::qv("1.2.3")]< >1.2.3<
593>%vx< >[version::qv("1.20.300")]< >1.14.12c<
9911cee9
TS
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<
be3174d2
GS
614>%y< >''< >%y INVALID<
615>%z< >''< >%z INVALID<
eb3fce90
JH
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<
58e33a90 622>%*3$2$d %d< >[12, 34, 3]< >%*3$2$d 12 INVALID<
7baa4690 623>%2$d< >12< >0 MISSING<
eb3fce90
JH
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<
8896765a 629>%*2$1d< >[12, 3]< >%*2$1d INVALID<
211dfcf1 630>%0v2.2d< >''< ><
26372e71
GA
631>%vc,%d< >[63, 64, 65]< >%vc,63 INVALID<
632>%v%,%d< >[63, 64, 65]< >%v%,63 INVALID<
250d67eb 633>%vd,%d< >["\x1", 2, 3]< >1,2<
26372e71
GA
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<
be75b157 640>%vp< >''< >%vp INVALID<
26372e71
GA
641>%vn< >''< >%vn INVALID<
642>%vs,%d< >[1, 2, 3]< >%vs,1 INVALID<
be75b157 643>%v_< >''< >%v_ INVALID<
f3583277 644>%v#x< >''< >%v#x INVALID<
250d67eb 645>%v02x< >"\x66\x6f\x6f\012"< >66.6f.6f.0a<
52e1aa67 646>%#v.8b< >"\141\000\142"< >0b01100001.00000000.0b01100010< >perl #39530<
e6bb52fd
TS
647>%#v.0o< >"\001\000\002\000"< >01.0.02.0<
648>%#v.1o< >"\001\000\002\000"< >01.0.02.0<
52e1aa67
DD
649>%#v.4o< >"\141\000\142"< >0141.0000.0142< >perl #39530<
650>%#v.3i< >"\141\000\142"< >097.000.098< >perl #39530<
e6bb52fd
TS
651>%#v.0x< >"\001\000\002\000"< >0x1..0x2.<
652>%#v.1x< >"\001\000\002\000"< >0x1.0.0x2.0<
52e1aa67
DD
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<
58e33a90
AE
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<
3a7a539e 685>%*v*999\$d %d %d< >[11, 22, 33]< >%*v*999\$d 11 22 INVALID<
ed2b91d2
GA
686>%#b< >0< >0<
687>%#o< >0< >0<
688>%#x< >0< >0<
2fba7546 689>%2147483647$v2d< >''< ><
7baa4690 690>%*2147483647$v2d< >''< > MISSING<