1N/A# Tests sprintf, excluding handling of 64-bit integers or long 1N/A# doubles (if supported), of machine-specific short and long 1N/A# integers, machine-specific floating point exceptions (infinity, 1N/A# not-a-number ...), of the effects of locale, and of features 1N/A# specific to multi-byte characters (under the utf8 pragma and such). 1N/A chdir 't' if -d 't'; 1N/A# we do not load %Config since this test resides in op and needs 1N/A# to run under the minitest target even without Config.pm working. 1N/A s/^\s*>//; s/<\s*$//; 1N/A# We use HW_MODEL since ARCH_NAME was not in VMS V5.* 1N/A if ($^O eq 'os390' || $^O eq 's390') { # non-IEEE (s390 is UTS) 1N/A $data =~ s/([eE])\-101$/${1}-56/; # larger exponents 1N/A # VAX DEC C 5.3 at least since there is no 1N/A # ccflags =~ /float=ieee/ on VAX. 1N/A # AXP is unaffected whether or not it's using ieee. 1N/A $data =~ s/([eE])\-101$/${1}-24/; # larger exponents 1N/A # $x may have 3 exponent digits, not 2 1N/A if ($y =~ s/([Ee][-+])0(\d)/$1$2/) { 1N/A # if result is left-adjusted, append extra space 1N/A # if result is zero-filled, add extra zero 1N/A # if result is right-adjusted, prepend extra space 1N/A { # three-digit exponent 1N/A print("ok $i # >$result< $x three-digit exponent accepted\n"); 1N/A # Suppress tests with modulo of exponent >= 100 on platforms 1N/A # which can't handle such magnitudes (or where we can't tell). 1N/A ((!eval {require POSIX}) || # Costly: only do this if we must! 1N/A " Suppressed: exponent out of range?\n") 1N/A $y = ($x eq $y ? "" : " => $y"); 1N/A# In each of the following lines, there are three required fields: 1N/A# printf template, data to be formatted (as a Perl expression), and 1N/A# expected result of formatting. An optional fourth field can contain 1N/A# a comment. Each field is delimited by a starting '>' and a 1N/A# finishing '<'; any whitespace outside these start and end marks is 1N/A# not part of the field. If formatting requires more than one data 1N/A# item (for example, if variable field widths are used), the Perl data 1N/A# expression should return a reference to an array having the requisite 1N/A# number of elements. Even so, subterfuge is sometimes required: see 1N/A# tests for %n and %p. 1N/A# The following tests are not currently run, for the reasons stated: 1N/A# template data result 1N/A>%G< >
1234567e96< >
1.23457E+
102<
1N/A>%G< >.
1234567e-
101< >
1.23457E-
102<
1N/A>%G< >
12345.6789< >
12345.7<
1N/A>%
#X< >2**32-1< >0XFFFFFFFF< 1N/A>%b< >
2**
32-
1< >
11111111111111111111111111111111<
1N/A>%+b< >
2**
32-
1< >
11111111111111111111111111111111<
1N/A>%
#b< >2**32-1< >0b11111111111111111111111111111111< 1N/A>%
34b< >
2**
32-
1< >
11111111111111111111111111111111<
1N/A>%
034b< >
2**
32-
1< >
0011111111111111111111111111111111<
1N/A>%-
34b< >
2**
32-
1< >
11111111111111111111111111111111 <
1N/A>%-
034b< >
2**
32-
1< >
11111111111111111111111111111111 <
1N/A>%
#10c< >ord('A')< > A< ># modifier: no effect< 1N/A>%
010c< >
ord('A')< >
000000000A<
1N/A>%d< >
123456.789< >
123456<
1N/A>%d< >-
123456.789< >-
123456<
1N/A>%
#3.2d< >1< > 01< ># modifier: no effect< 1N/A>%
vd< >
"\01\02\03"< >
1.2.
3<
1N/A>%v.
3d< >
"\01\02\03"< >
001.002.
003<
1N/A>%
0v3d< >
"\01\02\03"< >
001.002.
003<
1N/A>%-
v3d< >
"\01\02\03"< >
1 .
2 .
3 <
1N/A>%+-
v3d< >
"\01\02\03"< >+
1 .
2 .
3 <
1N/A>%
v4.
3d< >
"\01\02\03"< >
001.
002.
003<
1N/A>%
0v4.
3d< >
"\01\02\03"< >
0001.0002.
0003<
1N/A>%
0*
v2d< >[
'-',
"\0\7\14"]< >
00-
07-
12<
1N/A>%v.*d< >[
"\01\02\03",
3]< >
001.002.
003<
1N/A>%
0v*d< >[
"\01\02\03",
3]< >
001.002.
003<
1N/A>%-v*d< >[
"\01\02\03",
3]< >
1 .
2 .
3 <
1N/A>%+-v*d< >[
"\01\02\03",
3]< >+
1 .
2 .
3 <
1N/A>%v*.*d< >[
"\01\02\03",
4,
3]< >
001.
002.
003<
1N/A>%
0v*.*d< >[
"\01\02\03",
4,
3]< >
0001.0002.
0003<
1N/A>%
0*v*d< >[
'-',
"\0\7\13",
2]< >
00-
07-
11<
1N/A>%e< >
1234.875< >
1.234875e+
03<
1N/A>%e< >
0.000012345< >
1.234500e-
05<
1N/A>%e< >
1234567E96< >
1.234567e+
102<
1N/A>%e< >
0< >
0.000000e+
00<
1N/A>%e< >.
1234567E-
101< >
1.234567e-
102<
1N/A>%+e< >
1234.875< >+
1.234875e+
03<
1N/A>%
#e< >1234.875< >1.234875e+03< 1N/A>%e< >-
1234.875< >-
1.234875e+
03<
1N/A>%+e< >-
1234.875< >-
1.234875e+
03<
1N/A>%
#e< >-1234.875< >-1.234875e+03< 1N/A>%.
0e< >
1234.875< >
1e+
03<
1N/A>%.
0e< >
1.875< >
2e+
00<
1N/A>%.
0e< >
0.875< >
9e-
01<
1N/A>%.*e< >[
0,
1234.875]< >
1e+
03<
1N/A>%.
1e< >
1234.875< >
1.2e+
03<
1N/A>%-
12.4e< >
1234.875< >
1.2349e+
03 <
1N/A>%
12.4e< >
1234.875< >
1.2349e+
03<
1N/A>%+-
12.4e< >
1234.875< >+
1.2349e+
03 <
1N/A>%+
12.4e< >
1234.875< > +
1.2349e+
03<
1N/A>%+-
12.4e< >-
1234.875< >-
1.2349e+
03 <
1N/A>%+
12.4e< >-
1234.875< > -
1.2349e+
03<
1N/A>%f< >
1234.875< >
1234.875000<
1N/A>%+f< >
1234.875< >+
1234.875000<
1N/A>%
#f< >1234.875< >1234.875000< 1N/A>%f< >-
1234.875< >-
1234.875000<
1N/A>%+f< >-
1234.875< >-
1234.875000<
1N/A>%
#f< >-1234.875< >-1234.875000< 1N/A>%
6f< >
1234.875< >
1234.875000<
1N/A>%*f< >[
6,
1234.875]< >
1234.875000<
1N/A>%.
0f< >
1234.875< >
1235<
1N/A>%.
1f< >
1234.875< >
1234.9<
1N/A>%-
8.1f< >
1234.875< >
1234.9 <
1N/A>%
8.1f< >
1234.875< >
1234.9<
1N/A>%+-
8.1f< >
1234.875< >+
1234.9 <
1N/A>%+
8.1f< >
1234.875< > +
1234.9<
1N/A>%+-
8.1f< >-
1234.875< >-
1234.9 <
1N/A>%+
8.1f< >-
1234.875< > -
1234.9<
1N/A>%*.*f< >[
5,
2,
12.3456]< >
12.35<
1N/A>%g< >
12345.6789< >
12345.7<
1N/A>%+g< >
12345.6789< >+
12345.7<
1N/A>%
#g< >12345.6789< >12345.7< 1N/A>%.
0g< >
12345.6789< >
1e+
04<
1N/A>%.
2g< >
12345.6789< >
1.2e+
04<
1N/A>%.*g< >[
2,
12345.6789]< >
1.2e+
04<
1N/A>%.
9g< >
12345.6789< >
12345.6789<
1N/A>%
12.9g< >
12345.6789< >
12345.6789<
1N/A>%
012.9g< >
12345.6789< >
0012345.6789<
1N/A>%-
12.9g< >
12345.6789< >
12345.6789 <
1N/A>%*.*g< >[-
12,
9,
12345.6789]< >
12345.6789 <
1N/A>%-
012.9g< >
12345.6789< >
12345.6789 <
1N/A>%g< >-
12345.6789< >-
12345.7<
1N/A>%+g< >-
12345.6789< >-
12345.7<
1N/A>%g< >
1234567.89< >
1.23457e+
06<
1N/A>%+g< >
1234567.89< >+
1.23457e+
06<
1N/A>%
#g< >1234567.89< >1.23457e+06< 1N/A>%g< >-
1234567.89< >-
1.23457e+
06<
1N/A>%+g< >-
1234567.89< >-
1.23457e+
06<
1N/A>%
#g< >-1234567.89< >-1.23457e+06< 1N/A>%g< >
0.00012345< >
0.00012345<
1N/A>%g< >
0.000012345< >
1.2345e-
05<
1N/A>%g< >
1234567E96< >
1.23457e+
102<
1N/A>%g< >.
1234567E-
101< >
1.23457e-
102<
1N/A>%
13g< >
1234567.89< >
1.23457e+
06<
1N/A>%+
13g< >
1234567.89< > +
1.23457e+
06<
1N/A>%
013g< >
1234567.89< >
001.23457e+
06<
1N/A>%-
13g< >
1234567.89< >
1.23457e+
06 <
1N/A>%o< >
2**
32-
1< >
37777777777<
1N/A>%+o< >
2**
32-
1< >
37777777777<
1N/A>%
#o< >2**32-1< >037777777777< 1N/A>%
#p< >''< >%#p INVALID< 1N/A>%
#10s< >'string'< > string< 1N/A>%u< >
2**
32-
1< >
4294967295<
1N/A>%+u< >
2**
32-
1< >
4294967295<
1N/A>%
#u< >2**32-1< >4294967295< 1N/A>%
12u< >
2**
32-
1< >
4294967295<
1N/A>%
012u< >
2**
32-
1< >
004294967295<
1N/A>%-
12u< >
2**
32-
1< >
4294967295 <
1N/A>%-
012u< >
2**
32-
1< >
4294967295 <
1N/A>%
#x< >2**32-1< >0xffffffff< 1N/A>%
2$d %
1$d< >[
12,
34]< >
34 12<
1N/A>%*
2$d< >[
12,
3]< >
12<
1N/A>%
2$d %d< >[
12,
34]< >
34 12<
1N/A>%
2$d %d %d< >[
12,
34]< >
34 12 34<
1N/A>%
3$d %d %d< >[
12,
34,
56]< >
56 12 34<
1N/A>%
2$*
3$d %d< >[
12,
34,
3]< >
34 12<
1N/A>%
vc,%d< >[
63,
64,
65]< >?,
64<
1N/A>%
vd,%d< >[
1,
2,
3]< >
49,
2<
1N/A>%
vf,%d< >[
1,
2,
3]< >
1.000000,
2<
1N/A>%
vs,%d< >[
1,
2,
3]< >
1,
2<
1N/A>%v
#x< >''< >%v#x INVALID< 1N/A>%*v*
999\$d %d %d< >[
11,
22,
33]< >%*v*
999\$d
11 22 INVALID<