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