This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Extract format parameter later when vectorizing.
[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/) {
c1425322 60 $w .= ' INVALID';
0a52d15b 61 } elsif ($_[0] =~ /^Use of uninitialized value/) {
c1425322 62 $w .= ' UNINIT';
7baa4690 63 } elsif ($_[0] =~ /^Missing argument/) {
c1425322 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;
1795af27
VP
73 $x = sprintf($template, @$evalData);
74 $x = ">$x<" if defined $x;
be3174d2 75 substr($x, -1, 0) = $w if $w;
48237dde
GS
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 }
65c97e0f
GS
91 }
92
e24bffee
MB
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;
6f1f3b4a 106 $skip = $vsn ? ($osv <= $vsn ? 1 : 0) : 1;
e24bffee
MB
107 }
108 $skip and $comment =~ s/$/, failure expected on $^O $osv/;
109 }
110
be3174d2
GS
111 if ($x eq ">$result<") {
112 print "ok $i\n";
113 }
e24bffee
MB
114 elsif ($skip) {
115 print "ok $i # skip $comment\n";
116 }
48237dde 117 elsif ($y eq ">$result<") # Some C libraries always give
65c97e0f 118 { # three-digit exponent
00b6c67e 119 print("ok $i # >$result< $x three-digit exponent accepted\n");
65c97e0f 120 }
f7137e37
DD
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 {
00b6c67e 127 print("ok $i # >$template< >$data< >$result<",
e24bffee 128 " Suppressed: exponent out of range?\n");
f7137e37 129 }
be3174d2 130 else {
48237dde
GS
131 $y = ($x eq $y ? "" : " => $y");
132 print("not ok $i >$template< >$data< >$result< $x$y",
65c97e0f 133 $comment ? " # $comment\n" : "\n");
fb73857a
PP
134 }
135}
48237dde 136
a6d05634 137# In each of the following lines, there are three required fields:
be3174d2
GS
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#
e24bffee
MB
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<
6f1f3b4a 155# >%.0g< >-0.0< >-0< >No minus skip: MSWin32 VMS hpux:10.20<
e24bffee
MB
156# >%d< >4< >1< >4 != 1 skip: all<
157#
02a4ca6d
DD
158# The following tests are not currently run, for the reasons stated:
159
160=pod
161
162=begin problematic
163
02a4ca6d
DD
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
be3174d2
GS
171# template data result
172__END__
be3174d2 173>%6. 6s< >''< >%6. 6s INVALID< >(See use of $w in code above)<
c2e66d9e 174>%6 .6s< >''< >%6 .6s INVALID<
be3174d2 175>%6.6 s< >''< >%6.6 s INVALID<
c2e66d9e 176>%A< >''< >%A INVALID<
7ff06cc7
NC
177>%B< >2**32-1< >11111111111111111111111111111111<
178>%+B< >2**32-1< >11111111111111111111111111111111<
179>%#B< >2**32-1< >0B11111111111111111111111111111111<
be3174d2
GS
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"<
c2e66d9e
GS
185>%G< >1234567e96< >1.23457E+102<
186>%G< >.1234567e-101< >1.23457E-102<
be3174d2 187>%G< >12345.6789< >12345.7<
e24bffee
MB
188>%G< >1234567e96< >1.23457E+102< >exponent too big skip: os390<
189>%G< >.1234567e-101< >1.23457E-102< >exponent too small skip: os390<
be3174d2
GS
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<
8234e14b 197>%O< >2**32-1< >37777777777< >Synonym for %lo<
be3174d2
GS
198>%P< >''< >%P INVALID<
199>%Q< >''< >%Q INVALID<
200>%R< >''< >%R INVALID<
201>%S< >''< >%S INVALID<
202>%T< >''< >%T INVALID<
8234e14b 203>%U< >2**32-1< >4294967295< >Synonym for %lu<
be3174d2
GS
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 <
9911cee9
ST
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<
e6bb52fd
ST
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<
be3174d2
GS
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<
9911cee9 256>%-d< >0< >0<
be3174d2 257>%+d< >0< >+0<
9911cee9 258>% d< >0< > 0<
be3174d2 259>%0d< >0< >0<
9911cee9
ST
260>%-3d< >1< >1 <
261>%+3d< >1< > +1<
262>% 3d< >1< > 1<
263>%03d< >1< >001<
264>%+ 3d< >1< > +1<
265>% +3d< >1< > +1<
be3174d2
GS
266>%.0d< >0< ><
267>%+.0d< >0< >+<
9911cee9
ST
268>% .0d< >0< > <
269>%-.0d< >0< ><
270>%#.0d< >0< ><
be3174d2
GS
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<
9911cee9 276>%03.2d< >1< > 01< >0 flag with precision: no effect<
be3174d2 277>%-3.2d< >1< >01 <
9911cee9
ST
278>%+3.2d< >1< >+01<
279>% 3.2d< >1< > 01<
be3174d2 280>%-03.2d< >1< >01 < >zero pad + left just.: no effect<
9911cee9
ST
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<
be3174d2 295>%d< >-1< >-1<
9911cee9 296>%-d< >-1< >-1<
be3174d2 297>%+d< >-1< >-1<
9911cee9
ST
298>% d< >-1< >-1<
299>%-3d< >-1< >-1 <
300>%+3d< >-1< > -1<
301>% 3d< >-1< > -1<
302>%03d< >-1< >-01<
be3174d2 303>%hd< >1< >1< >More extensive testing of<
673c2ba8
CS
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<
be3174d2
GS
309>%vd< >chr(1)< >1<
310>%+vd< >chr(1)< >+1<
311>%#vd< >chr(1)< >1<
312>%vd< >"\01\02\03"< >1.2.3<
18eaf740
GA
313>%vd< >v1.2.3< >1.2.3<
314>%vd< >[version::qv("1.2.3")]< >1.2.3<
8cb289bd
RGS
315>%vd< >[version->new("1.2")]< >1.2<
316>%vd< >[version->new("1.02")]< >1.2<
34ba6322 317>%vd< >[version->new("1.002")]< >1.2<
8cb289bd
RGS
318>%vd< >[version->new("1048576.5")]< >1048576.5<
319>%vd< >[version->new("50")]< >50<
be3174d2 320>%v.3d< >"\01\02\03"< >001.002.003<
211dfcf1 321>%0v3d< >"\01\02\03"< >001.002.003<
96b8f7ce 322>%v.3d< >[version::qv("1.2.3")]< >001.002.003<
211dfcf1
HS
323>%-v3d< >"\01\02\03"< >1 .2 .3 <
324>%+-v3d< >"\01\02\03"< >+1 .2 .3 <
96b8f7ce 325>%+-v3d< >[version::qv("1.2.3")]< >+1 .2 .3 <
be3174d2 326>%v4.3d< >"\01\02\03"< > 001. 002. 003<
9911cee9 327>%0v4.3d< >"\01\02\03"< > 001. 002. 003<
211dfcf1
HS
328>%0*v2d< >['-', "\0\7\14"]< >00-07-12<
329>%v.*d< >["\01\02\03", 3]< >001.002.003<
330>%0v*d< >["\01\02\03", 3]< >001.002.003<
331>%-v*d< >["\01\02\03", 3]< >1 .2 .3 <
332>%+-v*d< >["\01\02\03", 3]< >+1 .2 .3 <
333>%v*.*d< >["\01\02\03", 4, 3]< > 001. 002. 003<
9911cee9 334>%0v*.*d< >["\01\02\03", 4, 3]< > 001. 002. 003<
211dfcf1 335>%0*v*d< >['-', "\0\7\13", 2]< >00-07-11<
96b8f7ce 336>%0*v*d< >['-', version::qv("0.7.11"), 2]< >00-07-11<
be3174d2 337>%e< >1234.875< >1.234875e+03<
c2e66d9e
GS
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<
be3174d2
GS
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<
02a4ca6d 348>%#.0e< >1234.875< >1.e+03<
20f6aaab
AS
349>%.0e< >1.875< >2e+00<
350>%.0e< >0.875< >9e-01<
be3174d2
GS
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<
e24bffee
MB
359>%e< >1234567E96< >1.234567e+102< >exponent too big skip: os390<
360>%e< >.1234567E-101< >1.234567e-102< >exponent too small skip: os390<
be3174d2
GS
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<
e24bffee 369>%.0f< >-0.1< >-0< >C library bug: no minus skip: VMS<
be3174d2
GS
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<
c2e66d9e 379>%f< >0< >0.000000<
95ea86d5 380>%.0f< >[]< >0 MISSING<
5b98cd54 381> %.0f< >[]< > 0 MISSING<
8bdb331d
ZA
382>%.2f< >[]< >0.00 MISSING<
383>%.2fC< >[]< >0.00C MISSING<
c2e66d9e
GS
384>%.0f< >0< >0<
385>%.0f< >2**38< >274877906944< >Should have exact int'l rep'n<
d5365ef1 386>%.0f< >0.1< >0<
20f6aaab
AS
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<
02a4ca6d
DD
391>%.0f< >1< >1<
392>%#.0f< >1< >1.<
00e17364
HS
393>%.0lf< >1< >1< >'l' should have no effect<
394>%.0hf< >1< >%.0hf INVALID< >'h' should be rejected<
be3174d2
GS
395>%g< >12345.6789< >12345.7<
396>%+g< >12345.6789< >+12345.7<
397>%#g< >12345.6789< >12345.7<
95ea86d5 398>%.0g< >[]< >0 MISSING<
d347ad18 399> %.0g< >[]< > 0 MISSING<
8bdb331d
ZA
400>%.2g< >[]< >0 MISSING<
401>%.2gC< >[]< >0C MISSING<
d347ad18 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<
be3174d2 403>%.0g< >12345.6789< >1e+04<
02a4ca6d 404>%#.0g< >12345.6789< >1.e+04<
be3174d2
GS
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<
c2e66d9e
GS
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<
be3174d2
GS
426>%13g< >1234567.89< > 1.23457e+06<
427>%+13g< >1234567.89< > +1.23457e+06<
e24bffee
MB
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<
be3174d2
GS
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>%o< >2**32-1< >37777777777<
440>%+o< >2**32-1< >37777777777<
441>%#o< >2**32-1< >037777777777<
8234e14b
PP
442>%o< >642< >1202< >check smaller octals across platforms<
443>%+o< >642< >1202<
9911cee9 444>% o< >642< >1202<
8234e14b 445>%#o< >642< >01202<
9911cee9
ST
446>%4o< >18< > 22<
447>%4.3o< >18< > 022<
448>%-4.3o< >18< >022 <
449>%+4.3o< >18< > 022<
450>% 4.3o< >18< > 022<
451>%04.3o< >18< > 022< >0 flag with precision: no effect<
452>%4.o< >36< > 44<
453>%-4.o< >36< >44 <
454>%+4.o< >36< > 44<
455>% 4.o< >36< > 44<
456>%04.o< >36< > 44< >0 flag with precision: no effect<
457>%.3o< >18< >022<
e6bb52fd
ST
458>%.0o< >0< ><
459>%+.0o< >0< ><
460>% .0o< >0< ><
461>%-.0o< >0< ><
462>%#.0o< >0< >0<
463>%#3.0o< >0< > 0<
464>%#3.1o< >0< > 0<
465>%#3.2o< >0< > 00<
466>%#3.3o< >0< >000<
467>%#3.4o< >0< >0000<
468>%.0o< >1< >1<
469>%+.0o< >1< >1<
470>% .0o< >1< >1<
471>%-.0o< >1< >1<
472>%#.0o< >1< >01<
473>%#3.0o< >1< > 01<
474>%#3.1o< >1< > 01<
475>%#3.2o< >1< > 01<
476>%#3.3o< >1< >001<
477>%#3.4o< >1< >0001<
478>%#.5o< >012345< >012345<
479>%#.5o< >012< >00012<
9911cee9
ST
480>%#4o< >17< > 021<
481>%#-4o< >17< >021 <
482>%-#4o< >17< >021 <
483>%#+4o< >17< > 021<
484>%# 4o< >17< > 021<
485>%#04o< >17< >0021<
486>%#4.o< >16< > 020<
487>%#-4.o< >16< >020 <
488>%-#4.o< >16< >020 <
489>%#+4.o< >16< > 020<
490>%# 4.o< >16< > 020<
491>%#04.o< >16< > 020< >0 flag with precision: no effect<
492>%#4.3o< >18< > 022<
493>%#-4.3o< >18< >022 <
494>%-#4.3o< >18< >022 <
495>%#+4.3o< >18< > 022<
496>%# 4.3o< >18< > 022<
497>%#04.3o< >18< > 022< >0 flag with precision: no effect<
498>%#6.4o< >18< > 0022<
499>%#-6.4o< >18< >0022 <
500>%-#6.4o< >18< >0022 <
501>%#+6.4o< >18< > 0022<
502>%# 6.4o< >18< > 0022<
503>%#06.4o< >18< > 0022< >0 flag with precision: no effect<
be3174d2 504>%d< >$p=sprintf('%p',$p);$p=~/^[0-9a-f]+$/< >1< >Coarse hack: hex from %p?<
0dbb1585 505>%d< >$p=sprintf('%-8p',$p);$p=~/^[0-9a-f]+\s*$/< >1< >Coarse hack: hex from %p?<
d5365ef1 506>%#p< >''< >%#p INVALID<
be3174d2
GS
507>%q< >''< >%q INVALID<
508>%r< >''< >%r INVALID<
5b98cd54
VP
509>%s< >[]< > MISSING<
510> %s< >[]< > MISSING<
be3174d2
GS
511>%s< >'string'< >string<
512>%10s< >'string'< > string<
513>%+10s< >'string'< > string<
514>%#10s< >'string'< > string<
515>%010s< >'string'< >0000string<
516>%0*s< >[10, 'string']< >0000string<
517>%-10s< >'string'< >string <
518>%3s< >'string'< >string<
519>%.3s< >'string'< >str<
520>%.*s< >[3, 'string']< >str<
9911cee9
ST
521>%.*s< >[2, 'string']< >st<
522>%.*s< >[1, 'string']< >s<
523>%.*s< >[0, 'string']< ><
524>%.*s< >[-1,'string']< >string< >negative precision to be ignored<
525>%3.*s< >[3, 'string']< >str<
526>%3.*s< >[2, 'string']< > st<
527>%3.*s< >[1, 'string']< > s<
528>%3.*s< >[0, 'string']< > <
529>%3.*s< >[-1,'string']< >string< >negative precision to be ignored<
be3174d2
GS
530>%t< >''< >%t INVALID<
531>%u< >2**32-1< >4294967295<
532>%+u< >2**32-1< >4294967295<
533>%#u< >2**32-1< >4294967295<
534>%12u< >2**32-1< > 4294967295<
535>%012u< >2**32-1< >004294967295<
536>%-12u< >2**32-1< >4294967295 <
537>%-012u< >2**32-1< >4294967295 <
9911cee9
ST
538>%4u< >18< > 18<
539>%4.3u< >18< > 018<
540>%-4.3u< >18< >018 <
541>%+4.3u< >18< > 018<
542>% 4.3u< >18< > 018<
543>%04.3u< >18< > 018< >0 flag with precision: no effect<
544>%.3u< >18< >018<
be3174d2
GS
545>%v< >''< >%v INVALID<
546>%w< >''< >%w INVALID<
547>%x< >2**32-1< >ffffffff<
548>%+x< >2**32-1< >ffffffff<
549>%#x< >2**32-1< >0xffffffff<
550>%10x< >2**32-1< > ffffffff<
551>%010x< >2**32-1< >00ffffffff<
552>%-10x< >2**32-1< >ffffffff <
553>%-010x< >2**32-1< >ffffffff <
554>%0-10x< >2**32-1< >ffffffff <
9911cee9
ST
555>%4x< >18< > 12<
556>%4.3x< >18< > 012<
557>%-4.3x< >18< >012 <
558>%+4.3x< >18< > 012<
559>% 4.3x< >18< > 012<
560>%04.3x< >18< > 012< >0 flag with precision: no effect<
561>%.3x< >18< >012<
562>%4X< >28< > 1C<
563>%4.3X< >28< > 01C<
564>%-4.3X< >28< >01C <
565>%+4.3X< >28< > 01C<
566>% 4.3X< >28< > 01C<
567>%04.3X< >28< > 01C< >0 flag with precision: no effect<
568>%.3X< >28< >01C<
569>%.0x< >0< ><
570>%+.0x< >0< ><
571>% .0x< >0< ><
572>%-.0x< >0< ><
573>%#.0x< >0< ><
e6bb52fd
ST
574>%#3.0x< >0< > <
575>%#3.1x< >0< > 0<
576>%#3.2x< >0< > 00<
577>%#3.3x< >0< >000<
578>%#3.4x< >0< >0000<
579>%.0x< >1< >1<
580>%+.0x< >1< >1<
581>% .0x< >1< >1<
582>%-.0x< >1< >1<
583>%#.0x< >1< >0x1<
584>%#3.0x< >1< >0x1<
585>%#3.1x< >1< >0x1<
586>%#3.2x< >1< >0x01<
587>%#3.3x< >1< >0x001<
588>%#3.4x< >1< >0x0001<
589>%#.5x< >0x12345< >0x12345<
590>%#.5x< >0x12< >0x00012<
9911cee9
ST
591>%#4x< >28< >0x1c<
592>%#4.3x< >28< >0x01c<
593>%#-4.3x< >28< >0x01c<
594>%#+4.3x< >28< >0x01c<
595>%# 4.3x< >28< >0x01c<
596>%#04.3x< >28< >0x01c< >0 flag with precision: no effect<
597>%#.3x< >28< >0x01c<
598>%#6.3x< >28< > 0x01c<
599>%#-6.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<
be3174d2 605>%0*x< >[-10, ,2**32-1]< >ffffffff <
96b8f7ce
JP
606>%vx< >[version::qv("1.2.3")]< >1.2.3<
607>%vx< >[version::qv("1.20.300")]< >1.14.12c<
9911cee9
ST
608>%.*x< >[0,0]< ><
609>%-.*x< >[0,0]< ><
610>%+.*x< >[0,0]< ><
611>% .*x< >[0,0]< ><
612>%0.*x< >[0,0]< ><
613>%.*x< >[-3,0]< >0<
614>%-.*x< >[-3,0]< >0<
615>%+.*x< >[-3,0]< >0<
616>% .*x< >[-3,0]< >0<
617>%0.*x< >[-3,0]< >0<
618>%#.*x< >[0,0]< ><
619>%#-.*x< >[0,0]< ><
620>%#+.*x< >[0,0]< ><
621>%# .*x< >[0,0]< ><
622>%#0.*x< >[0,0]< ><
623>%#.*x< >[-1,0]< >0<
624>%#-.*x< >[-1,0]< >0<
625>%#+.*x< >[-1,0]< >0<
626>%# .*x< >[-1,0]< >0<
627>%#0.*x< >[-1,0]< >0<
be3174d2
GS
628>%y< >''< >%y INVALID<
629>%z< >''< >%z INVALID<
eb3fce90
JH
630>%2$d %1$d< >[12, 34]< >34 12<
631>%*2$d< >[12, 3]< > 12<
632>%2$d %d< >[12, 34]< >34 12<
633>%2$d %d %d< >[12, 34]< >34 12 34<
634>%3$d %d %d< >[12, 34, 56]< >56 12 34<
635>%2$*3$d %d< >[12, 34, 3]< > 34 12<
58e33a90 636>%*3$2$d %d< >[12, 34, 3]< >%*3$2$d 12 INVALID<
7baa4690 637>%2$d< >12< >0 MISSING<
eb3fce90
JH
638>%0$d< >12< >%0$d INVALID<
639>%1$$d< >12< >%1$$d INVALID<
640>%1$1$d< >12< >%1$1$d INVALID<
641>%*2$*2$d< >[12, 3]< >%*2$*2$d INVALID<
642>%*2*2$d< >[12, 3]< >%*2*2$d INVALID<
8896765a 643>%*2$1d< >[12, 3]< >%*2$1d INVALID<
211dfcf1 644>%0v2.2d< >''< ><
26372e71
GA
645>%vc,%d< >[63, 64, 65]< >%vc,63 INVALID<
646>%v%,%d< >[63, 64, 65]< >%v%,63 INVALID<
250d67eb 647>%vd,%d< >["\x1", 2, 3]< >1,2<
26372e71
GA
648>%vf,%d< >[1, 2, 3]< >%vf,1 INVALID<
649>%vF,%d< >[1, 2, 3]< >%vF,1 INVALID<
650>%ve,%d< >[1, 2, 3]< >%ve,1 INVALID<
651>%vE,%d< >[1, 2, 3]< >%vE,1 INVALID<
652>%vg,%d< >[1, 2, 3]< >%vg,1 INVALID<
653>%vG,%d< >[1, 2, 3]< >%vG,1 INVALID<
be75b157 654>%vp< >''< >%vp INVALID<
26372e71
GA
655>%vn< >''< >%vn INVALID<
656>%vs,%d< >[1, 2, 3]< >%vs,1 INVALID<
be75b157 657>%v_< >''< >%v_ INVALID<
f3583277 658>%v#x< >''< >%v#x INVALID<
250d67eb 659>%v02x< >"\x66\x6f\x6f\012"< >66.6f.6f.0a<
52e1aa67 660>%#v.8b< >"\141\000\142"< >0b01100001.00000000.0b01100010< >perl #39530<
e6bb52fd
ST
661>%#v.0o< >"\001\000\002\000"< >01.0.02.0<
662>%#v.1o< >"\001\000\002\000"< >01.0.02.0<
52e1aa67
DD
663>%#v.4o< >"\141\000\142"< >0141.0000.0142< >perl #39530<
664>%#v.3i< >"\141\000\142"< >097.000.098< >perl #39530<
e6bb52fd
ST
665>%#v.0x< >"\001\000\002\000"< >0x1..0x2.<
666>%#v.1x< >"\001\000\002\000"< >0x1.0.0x2.0<
52e1aa67
DD
667>%#v.2x< >"\141\000\142"< >0x61.00.0x62< >perl #39530<
668>%#v.2X< >"\141\000\142"< >0X61.00.0X62< >perl #39530<
669>%#v.8b< >"\141\017\142"< >0b01100001.0b00001111.0b01100010< >perl #39530<
670>%#v.4o< >"\141\017\142"< >0141.0017.0142< >perl #39530<
671>%#v.3i< >"\141\017\142"< >097.015.098< >perl #39530<
672>%#v.2x< >"\141\017\142"< >0x61.0x0f.0x62< >perl #39530<
673>%#v.2X< >"\141\017\142"< >0X61.0X0F.0X62< >perl #39530<
674>%#*v.8b< >["][", "\141\000\142"]< >0b01100001][00000000][0b01100010< >perl #39530<
675>%#*v.4o< >["][", "\141\000\142"]< >0141][0000][0142< >perl #39530<
676>%#*v.3i< >["][", "\141\000\142"]< >097][000][098< >perl #39530<
677>%#*v.2x< >["][", "\141\000\142"]< >0x61][00][0x62< >perl #39530<
678>%#*v.2X< >["][", "\141\000\142"]< >0X61][00][0X62< >perl #39530<
679>%#*v.8b< >["][", "\141\017\142"]< >0b01100001][0b00001111][0b01100010< >perl #39530<
680>%#*v.4o< >["][", "\141\017\142"]< >0141][0017][0142< >perl #39530<
681>%#*v.3i< >["][", "\141\017\142"]< >097][015][098< >perl #39530<
682>%#*v.2x< >["][", "\141\017\142"]< >0x61][0x0f][0x62< >perl #39530<
683>%#*v.2X< >["][", "\141\017\142"]< >0X61][0X0F][0X62< >perl #39530<
684>%#v.8b< >"\141\x{1e01}\000\142\x{1e03}"< >0b01100001.0b1111000000001.00000000.0b01100010.0b1111000000011< >perl #39530<
685>%#v.4o< >"\141\x{1e01}\000\142\x{1e03}"< >0141.017001.0000.0142.017003< >perl #39530<
686>%#v.3i< >"\141\x{1e01}\000\142\x{1e03}"< >097.7681.000.098.7683< >perl #39530<
687>%#v.2x< >"\141\x{1e01}\000\142\x{1e03}"< >0x61.0x1e01.00.0x62.0x1e03< >perl #39530<
688>%#v.2X< >"\141\x{1e01}\000\142\x{1e03}"< >0X61.0X1E01.00.0X62.0X1E03< >perl #39530<
689>%#v.8b< >"\141\x{1e01}\017\142\x{1e03}"< >0b01100001.0b1111000000001.0b00001111.0b01100010.0b1111000000011< >perl #39530<
690>%#v.4o< >"\141\x{1e01}\017\142\x{1e03}"< >0141.017001.0017.0142.017003< >perl #39530<
691>%#v.3i< >"\141\x{1e01}\017\142\x{1e03}"< >097.7681.015.098.7683< >perl #39530<
692>%#v.2x< >"\141\x{1e01}\017\142\x{1e03}"< >0x61.0x1e01.0x0f.0x62.0x1e03< >perl #39530<
693>%#v.2X< >"\141\x{1e01}\017\142\x{1e03}"< >0X61.0X1E01.0X0F.0X62.0X1E03< >perl #39530<
58e33a90
AE
694>%V-%s< >["Hello"]< >%V-Hello INVALID<
695>%K %d %d< >[13, 29]< >%K 13 29 INVALID<
696>%*.*K %d< >[13, 29, 76]< >%*.*K 13 INVALID<
c1425322 697>%4$K %d< >[45, 67]< >%4$K 45 MISSING INVALID<
58e33a90 698>%d %K %d< >[23, 45]< >23 %K 45 INVALID<
3a7a539e 699>%*v*999\$d %d %d< >[11, 22, 33]< >%*v*999\$d 11 22 INVALID<
ed2b91d2
GA
700>%#b< >0< >0<
701>%#o< >0< >0<
702>%#x< >0< >0<
2fba7546 703>%2147483647$v2d< >''< ><
7baa4690 704>%*2147483647$v2d< >''< > MISSING<
d1de25c9
HS
705>%.3X< >[11]< >00B< >perl #83194: hex, zero-padded to 3 places<
706>%.*X< >[3, 11]< >00B< >perl #83194: dynamic precision<
707>%vX< >['012']< >30.31.32< >perl #83194: vector flag<
708>%*vX< >[':', '012']< >30:31:32< >perl #83194: vector flag + custom separator<
709>%v.3X< >['012']< >030.031.032< >perl #83194: vector flag + static precision<
710>%v.*X< >[3, '012']< >030.031.032< >perl #83194: vector flag + dynamic precision<
711>%*v.3X< >[':', '012']< >030:031:032< >perl #83194: vector flag + custom separator + static precision<
712>%*v.*X< >[':', 3, '012']< >030:031:032< >perl #83194: vector flag + custom separator + dynamic precision<