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