xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/t/op/sprintf.t (revision 1277:fbc63bc995ee)
10Sstevel@tonic-gate#!./perl
20Sstevel@tonic-gate
30Sstevel@tonic-gate# Tests sprintf, excluding handling of 64-bit integers or long
40Sstevel@tonic-gate# doubles (if supported), of machine-specific short and long
50Sstevel@tonic-gate# integers, machine-specific floating point exceptions (infinity,
60Sstevel@tonic-gate# not-a-number ...), of the effects of locale, and of features
70Sstevel@tonic-gate# specific to multi-byte characters (under the utf8 pragma and such).
80Sstevel@tonic-gate
90Sstevel@tonic-gateBEGIN {
100Sstevel@tonic-gate    chdir 't' if -d 't';
110Sstevel@tonic-gate    @INC = '../lib';
120Sstevel@tonic-gate}
130Sstevel@tonic-gateuse warnings;
140Sstevel@tonic-gate# we do not load %Config since this test resides in op and needs
150Sstevel@tonic-gate# to run under the minitest target even without Config.pm working.
160Sstevel@tonic-gate
170Sstevel@tonic-gate# strictness
180Sstevel@tonic-gatemy @tests = ();
190Sstevel@tonic-gatemy ($i, $template, $data, $result, $comment, $w, $x, $evalData, $n, $p);
200Sstevel@tonic-gate
210Sstevel@tonic-gatewhile (<DATA>) {
220Sstevel@tonic-gate    s/^\s*>//; s/<\s*$//;
230Sstevel@tonic-gate    push @tests, [split(/<\s*>/, $_, 4)];
240Sstevel@tonic-gate}
250Sstevel@tonic-gate
260Sstevel@tonic-gateprint '1..', scalar @tests, "\n";
270Sstevel@tonic-gate
280Sstevel@tonic-gate$SIG{__WARN__} = sub {
290Sstevel@tonic-gate    if ($_[0] =~ /^Invalid conversion/) {
300Sstevel@tonic-gate	$w = ' INVALID';
310Sstevel@tonic-gate    } elsif ($_[0] =~ /^Use of uninitialized value/) {
320Sstevel@tonic-gate	$w = ' UNINIT';
330Sstevel@tonic-gate    } else {
340Sstevel@tonic-gate	warn @_;
350Sstevel@tonic-gate    }
360Sstevel@tonic-gate};
370Sstevel@tonic-gate
380Sstevel@tonic-gatemy $Is_VMS_VAX = 0;
390Sstevel@tonic-gate# We use HW_MODEL since ARCH_NAME was not in VMS V5.*
400Sstevel@tonic-gateif ($^O eq 'VMS') {
410Sstevel@tonic-gate    my $hw_model;
420Sstevel@tonic-gate    chomp($hw_model = `write sys\$output f\$getsyi("HW_MODEL")`);
430Sstevel@tonic-gate    $Is_VMS_VAX = $hw_model < 1024 ? 1 : 0;
440Sstevel@tonic-gate}
450Sstevel@tonic-gate
460Sstevel@tonic-gate# No %Config.
470Sstevel@tonic-gatemy $Is_Ultrix_VAX = $^O eq 'ultrix' && `uname -m` =~ /^VAX$/;
480Sstevel@tonic-gate
490Sstevel@tonic-gatefor ($i = 1; @tests; $i++) {
500Sstevel@tonic-gate    ($template, $data, $result, $comment) = @{shift @tests};
510Sstevel@tonic-gate    if ($^O eq 'os390' || $^O eq 's390') { # non-IEEE (s390 is UTS)
520Sstevel@tonic-gate        $data   =~ s/([eE])96$/${1}63/;      # smaller exponents
530Sstevel@tonic-gate        $result =~ s/([eE]\+)102$/${1}69/;   #  "       "
540Sstevel@tonic-gate        $data   =~ s/([eE])\-101$/${1}-56/;  # larger exponents
550Sstevel@tonic-gate        $result =~ s/([eE])\-102$/${1}-57/;  #  "       "
560Sstevel@tonic-gate    }
570Sstevel@tonic-gate    if ($Is_VMS_VAX || $Is_Ultrix_VAX) {
580Sstevel@tonic-gate	# VAX DEC C 5.3 at least since there is no
590Sstevel@tonic-gate	# ccflags =~ /float=ieee/ on VAX.
600Sstevel@tonic-gate	# AXP is unaffected whether or not it's using ieee.
610Sstevel@tonic-gate        $data   =~ s/([eE])96$/${1}26/;      # smaller exponents
620Sstevel@tonic-gate        $result =~ s/([eE]\+)102$/${1}32/;   #  "       "
630Sstevel@tonic-gate        $data   =~ s/([eE])\-101$/${1}-24/;  # larger exponents
640Sstevel@tonic-gate        $result =~ s/([eE])\-102$/${1}-25/;  #  "       "
650Sstevel@tonic-gate    }
660Sstevel@tonic-gate    $evalData = eval $data;
670Sstevel@tonic-gate    $w = undef;
680Sstevel@tonic-gate    $x = sprintf(">$template<",
690Sstevel@tonic-gate                 defined @$evalData ? @$evalData : $evalData);
700Sstevel@tonic-gate    substr($x, -1, 0) = $w if $w;
710Sstevel@tonic-gate    # $x may have 3 exponent digits, not 2
720Sstevel@tonic-gate    my $y = $x;
730Sstevel@tonic-gate    if ($y =~ s/([Ee][-+])0(\d)/$1$2/) {
740Sstevel@tonic-gate        # if result is left-adjusted, append extra space
750Sstevel@tonic-gate        if ($template =~ /%\+?\-/ and $result =~ / $/) {
760Sstevel@tonic-gate	    $y =~ s/<$/ </;
770Sstevel@tonic-gate	}
780Sstevel@tonic-gate        # if result is zero-filled, add extra zero
790Sstevel@tonic-gate	elsif ($template =~ /%\+?0/ and $result =~ /^0/) {
800Sstevel@tonic-gate	    $y =~ s/^>0/>00/;
810Sstevel@tonic-gate	}
820Sstevel@tonic-gate        # if result is right-adjusted, prepend extra space
830Sstevel@tonic-gate	elsif ($result =~ /^ /) {
840Sstevel@tonic-gate	    $y =~ s/^>/> /;
850Sstevel@tonic-gate	}
860Sstevel@tonic-gate    }
870Sstevel@tonic-gate
880Sstevel@tonic-gate    if ($x eq ">$result<") {
890Sstevel@tonic-gate        print "ok $i\n";
900Sstevel@tonic-gate    }
910Sstevel@tonic-gate    elsif ($y eq ">$result<")	# Some C libraries always give
920Sstevel@tonic-gate    {				# three-digit exponent
930Sstevel@tonic-gate		print("ok $i # >$result< $x three-digit exponent accepted\n");
940Sstevel@tonic-gate    }
950Sstevel@tonic-gate	elsif ($result =~ /[-+]\d{3}$/ &&
960Sstevel@tonic-gate		   # Suppress tests with modulo of exponent >= 100 on platforms
970Sstevel@tonic-gate		   # which can't handle such magnitudes (or where we can't tell).
980Sstevel@tonic-gate		   ((!eval {require POSIX}) || # Costly: only do this if we must!
990Sstevel@tonic-gate			(length(&POSIX::DBL_MAX) - rindex(&POSIX::DBL_MAX, '+')) == 3))
1000Sstevel@tonic-gate	{
1010Sstevel@tonic-gate		print("ok $i # >$template< >$data< >$result<",
1020Sstevel@tonic-gate			  " Suppressed: exponent out of range?\n")
1030Sstevel@tonic-gate	}
1040Sstevel@tonic-gate    else {
1050Sstevel@tonic-gate	$y = ($x eq $y ? "" : " => $y");
1060Sstevel@tonic-gate	print("not ok $i >$template< >$data< >$result< $x$y",
1070Sstevel@tonic-gate	    $comment ? " # $comment\n" : "\n");
1080Sstevel@tonic-gate    }
1090Sstevel@tonic-gate}
1100Sstevel@tonic-gate
1110Sstevel@tonic-gate# In each of the following lines, there are three required fields:
1120Sstevel@tonic-gate# printf template, data to be formatted (as a Perl expression), and
1130Sstevel@tonic-gate# expected result of formatting.  An optional fourth field can contain
1140Sstevel@tonic-gate# a comment.  Each field is delimited by a starting '>' and a
1150Sstevel@tonic-gate# finishing '<'; any whitespace outside these start and end marks is
1160Sstevel@tonic-gate# not part of the field.  If formatting requires more than one data
1170Sstevel@tonic-gate# item (for example, if variable field widths are used), the Perl data
1180Sstevel@tonic-gate# expression should return a reference to an array having the requisite
1190Sstevel@tonic-gate# number of elements.  Even so, subterfuge is sometimes required: see
1200Sstevel@tonic-gate# tests for %n and %p.
1210Sstevel@tonic-gate#
1220Sstevel@tonic-gate# The following tests are not currently run, for the reasons stated:
1230Sstevel@tonic-gate
1240Sstevel@tonic-gate=pod
1250Sstevel@tonic-gate
1260Sstevel@tonic-gate=begin problematic
1270Sstevel@tonic-gate
1280Sstevel@tonic-gate>%.0f<      >-0.1<        >-0<  >C library bug: no minus on VMS, HP-UX<
1290Sstevel@tonic-gate>%.0f<      >1.5<         >2<   >Standard vague: no rounding rules<
1300Sstevel@tonic-gate>%.0f<      >2.5<         >2<   >Standard vague: no rounding rules<
1310Sstevel@tonic-gate>%G<        >1234567e96<  >1.23457E+102<	>exponent too big for OS/390<
1320Sstevel@tonic-gate>%G<        >.1234567e-101< >1.23457E-102<	>exponent too small for OS/390<
1330Sstevel@tonic-gate>%e<        >1234567E96<  >1.234567e+102<	>exponent too big for OS/390<
1340Sstevel@tonic-gate>%e<        >.1234567E-101< >1.234567e-102<	>exponent too small for OS/390<
1350Sstevel@tonic-gate>%g<        >.1234567E-101< >1.23457e-102<	>exponent too small for OS/390<
1360Sstevel@tonic-gate>%g<        >1234567E96<  >1.23457e+102<	>exponent too big for OS/390<
1370Sstevel@tonic-gate
1380Sstevel@tonic-gate=end problematic
1390Sstevel@tonic-gate
1400Sstevel@tonic-gate=cut
1410Sstevel@tonic-gate
1420Sstevel@tonic-gate# template    data          result
1430Sstevel@tonic-gate__END__
1440Sstevel@tonic-gate>%6. 6s<    >''<          >%6. 6s INVALID< >(See use of $w in code above)<
1450Sstevel@tonic-gate>%6 .6s<    >''<          >%6 .6s INVALID<
1460Sstevel@tonic-gate>%6.6 s<    >''<          >%6.6 s INVALID<
1470Sstevel@tonic-gate>%A<        >''<          >%A INVALID<
1480Sstevel@tonic-gate>%B<        >''<          >%B INVALID<
1490Sstevel@tonic-gate>%C<        >''<          >%C INVALID<
1500Sstevel@tonic-gate>%D<        >0x7fffffff<  >2147483647<     >Synonym for %ld<
1510Sstevel@tonic-gate>%E<        >123456.789<  >1.234568E+05<   >Like %e, but using upper-case "E"<
1520Sstevel@tonic-gate>%F<        >123456.789<  >123456.789000<  >Synonym for %f<
1530Sstevel@tonic-gate>%G<        >1234567.89<  >1.23457E+06<    >Like %g, but using upper-case "E"<
1540Sstevel@tonic-gate>%G<        >1234567e96<  >1.23457E+102<
1550Sstevel@tonic-gate>%G<        >.1234567e-101< >1.23457E-102<
1560Sstevel@tonic-gate>%G<        >12345.6789<  >12345.7<
1570Sstevel@tonic-gate>%H<        >''<          >%H INVALID<
1580Sstevel@tonic-gate>%I<        >''<          >%I INVALID<
1590Sstevel@tonic-gate>%J<        >''<          >%J INVALID<
1600Sstevel@tonic-gate>%K<        >''<          >%K INVALID<
1610Sstevel@tonic-gate>%L<        >''<          >%L INVALID<
1620Sstevel@tonic-gate>%M<        >''<          >%M INVALID<
1630Sstevel@tonic-gate>%N<        >''<          >%N INVALID<
1640Sstevel@tonic-gate>%O<        >2**32-1<     >37777777777<    >Synonym for %lo<
1650Sstevel@tonic-gate>%P<        >''<          >%P INVALID<
1660Sstevel@tonic-gate>%Q<        >''<          >%Q INVALID<
1670Sstevel@tonic-gate>%R<        >''<          >%R INVALID<
1680Sstevel@tonic-gate>%S<        >''<          >%S INVALID<
1690Sstevel@tonic-gate>%T<        >''<          >%T INVALID<
1700Sstevel@tonic-gate>%U<        >2**32-1<     >4294967295<     >Synonym for %lu<
1710Sstevel@tonic-gate>%V<        >''<          >%V INVALID<
1720Sstevel@tonic-gate>%W<        >''<          >%W INVALID<
1730Sstevel@tonic-gate>%X<        >2**32-1<     >FFFFFFFF<       >Like %x, but with u/c letters<
1740Sstevel@tonic-gate>%#X<       >2**32-1<     >0XFFFFFFFF<
1750Sstevel@tonic-gate>%Y<        >''<          >%Y INVALID<
1760Sstevel@tonic-gate>%Z<        >''<          >%Z INVALID<
1770Sstevel@tonic-gate>%a<        >''<          >%a INVALID<
1780Sstevel@tonic-gate>%b<        >2**32-1<     >11111111111111111111111111111111<
1790Sstevel@tonic-gate>%+b<       >2**32-1<     >11111111111111111111111111111111<
1800Sstevel@tonic-gate>%#b<       >2**32-1<     >0b11111111111111111111111111111111<
1810Sstevel@tonic-gate>%34b<      >2**32-1<     >  11111111111111111111111111111111<
1820Sstevel@tonic-gate>%034b<     >2**32-1<     >0011111111111111111111111111111111<
1830Sstevel@tonic-gate>%-34b<     >2**32-1<     >11111111111111111111111111111111  <
1840Sstevel@tonic-gate>%-034b<    >2**32-1<     >11111111111111111111111111111111  <
1850Sstevel@tonic-gate>%c<        >ord('A')<    >A<
1860Sstevel@tonic-gate>%10c<      >ord('A')<    >         A<
1870Sstevel@tonic-gate>%#10c<     >ord('A')<    >         A<     ># modifier: no effect<
1880Sstevel@tonic-gate>%010c<     >ord('A')<    >000000000A<
1890Sstevel@tonic-gate>%10lc<     >ord('A')<    >         A<     >l modifier: no effect<
1900Sstevel@tonic-gate>%10hc<     >ord('A')<    >         A<     >h modifier: no effect<
1910Sstevel@tonic-gate>%10.5c<    >ord('A')<    >         A<     >precision: no effect<
1920Sstevel@tonic-gate>%-10c<     >ord('A')<    >A         <
1930Sstevel@tonic-gate>%d<        >123456.789<  >123456<
1940Sstevel@tonic-gate>%d<        >-123456.789< >-123456<
1950Sstevel@tonic-gate>%d<        >0<           >0<
1960Sstevel@tonic-gate>%+d<       >0<           >+0<
1970Sstevel@tonic-gate>%0d<       >0<           >0<
1980Sstevel@tonic-gate>%.0d<      >0<           ><
1990Sstevel@tonic-gate>%+.0d<     >0<           >+<
2000Sstevel@tonic-gate>%.0d<      >1<           >1<
2010Sstevel@tonic-gate>%d<        >1<           >1<
2020Sstevel@tonic-gate>%+d<       >1<           >+1<
2030Sstevel@tonic-gate>%#3.2d<    >1<           > 01<            ># modifier: no effect<
2040Sstevel@tonic-gate>%3.2d<     >1<           > 01<
2050Sstevel@tonic-gate>%03.2d<    >1<           >001<
2060Sstevel@tonic-gate>%-3.2d<    >1<           >01 <
2070Sstevel@tonic-gate>%-03.2d<   >1<           >01 <            >zero pad + left just.: no effect<
2080Sstevel@tonic-gate>%d<        >-1<          >-1<
2090Sstevel@tonic-gate>%+d<       >-1<          >-1<
2100Sstevel@tonic-gate>%hd<       >1<           >1<              >More extensive testing of<
2110Sstevel@tonic-gate>%ld<       >1<           >1<              >length modifiers would be<
2120Sstevel@tonic-gate>%Vd<       >1<           >1<              >platform-specific<
2130Sstevel@tonic-gate>%vd<       >chr(1)<      >1<
2140Sstevel@tonic-gate>%+vd<      >chr(1)<      >+1<
2150Sstevel@tonic-gate>%#vd<      >chr(1)<      >1<
2160Sstevel@tonic-gate>%vd<       >"\01\02\03"< >1.2.3<
2170Sstevel@tonic-gate>%v.3d<     >"\01\02\03"< >001.002.003<
2180Sstevel@tonic-gate>%0v3d<     >"\01\02\03"< >001.002.003<
2190Sstevel@tonic-gate>%-v3d<     >"\01\02\03"< >1  .2  .3  <
2200Sstevel@tonic-gate>%+-v3d<    >"\01\02\03"< >+1 .2  .3  <
2210Sstevel@tonic-gate>%v4.3d<    >"\01\02\03"< > 001. 002. 003<
2220Sstevel@tonic-gate>%0v4.3d<   >"\01\02\03"< >0001.0002.0003<
2230Sstevel@tonic-gate>%0*v2d<    >['-', "\0\7\14"]< >00-07-12<
2240Sstevel@tonic-gate>%v.*d<     >["\01\02\03", 3]< >001.002.003<
2250Sstevel@tonic-gate>%0v*d<     >["\01\02\03", 3]< >001.002.003<
2260Sstevel@tonic-gate>%-v*d<     >["\01\02\03", 3]< >1  .2  .3  <
2270Sstevel@tonic-gate>%+-v*d<    >["\01\02\03", 3]< >+1 .2  .3  <
2280Sstevel@tonic-gate>%v*.*d<    >["\01\02\03", 4, 3]< > 001. 002. 003<
2290Sstevel@tonic-gate>%0v*.*d<   >["\01\02\03", 4, 3]< >0001.0002.0003<
2300Sstevel@tonic-gate>%0*v*d<    >['-', "\0\7\13", 2]< >00-07-11<
2310Sstevel@tonic-gate>%e<        >1234.875<    >1.234875e+03<
2320Sstevel@tonic-gate>%e<        >0.000012345< >1.234500e-05<
2330Sstevel@tonic-gate>%e<        >1234567E96<  >1.234567e+102<
2340Sstevel@tonic-gate>%e<        >0<           >0.000000e+00<
2350Sstevel@tonic-gate>%e<        >.1234567E-101< >1.234567e-102<
2360Sstevel@tonic-gate>%+e<       >1234.875<    >+1.234875e+03<
2370Sstevel@tonic-gate>%#e<       >1234.875<    >1.234875e+03<
2380Sstevel@tonic-gate>%e<        >-1234.875<   >-1.234875e+03<
2390Sstevel@tonic-gate>%+e<       >-1234.875<   >-1.234875e+03<
2400Sstevel@tonic-gate>%#e<       >-1234.875<   >-1.234875e+03<
2410Sstevel@tonic-gate>%.0e<      >1234.875<    >1e+03<
2420Sstevel@tonic-gate>%#.0e<     >1234.875<    >1.e+03<
2430Sstevel@tonic-gate>%.0e<      >1.875<       >2e+00<
2440Sstevel@tonic-gate>%.0e<      >0.875<       >9e-01<
2450Sstevel@tonic-gate>%.*e<      >[0, 1234.875]< >1e+03<
2460Sstevel@tonic-gate>%.1e<      >1234.875<    >1.2e+03<
2470Sstevel@tonic-gate>%-12.4e<   >1234.875<    >1.2349e+03  <
2480Sstevel@tonic-gate>%12.4e<    >1234.875<    >  1.2349e+03<
2490Sstevel@tonic-gate>%+-12.4e<  >1234.875<    >+1.2349e+03 <
2500Sstevel@tonic-gate>%+12.4e<   >1234.875<    > +1.2349e+03<
2510Sstevel@tonic-gate>%+-12.4e<  >-1234.875<   >-1.2349e+03 <
2520Sstevel@tonic-gate>%+12.4e<   >-1234.875<   > -1.2349e+03<
2530Sstevel@tonic-gate>%f<        >1234.875<    >1234.875000<
2540Sstevel@tonic-gate>%+f<       >1234.875<    >+1234.875000<
2550Sstevel@tonic-gate>%#f<       >1234.875<    >1234.875000<
2560Sstevel@tonic-gate>%f<        >-1234.875<   >-1234.875000<
2570Sstevel@tonic-gate>%+f<       >-1234.875<   >-1234.875000<
2580Sstevel@tonic-gate>%#f<       >-1234.875<   >-1234.875000<
2590Sstevel@tonic-gate>%6f<       >1234.875<    >1234.875000<
2600Sstevel@tonic-gate>%*f<       >[6, 1234.875]< >1234.875000<
2610Sstevel@tonic-gate>%.0f<      >1234.875<    >1235<
2620Sstevel@tonic-gate>%.1f<      >1234.875<    >1234.9<
2630Sstevel@tonic-gate>%-8.1f<    >1234.875<    >1234.9  <
2640Sstevel@tonic-gate>%8.1f<     >1234.875<    >  1234.9<
2650Sstevel@tonic-gate>%+-8.1f<   >1234.875<    >+1234.9 <
2660Sstevel@tonic-gate>%+8.1f<    >1234.875<    > +1234.9<
2670Sstevel@tonic-gate>%+-8.1f<   >-1234.875<   >-1234.9 <
2680Sstevel@tonic-gate>%+8.1f<    >-1234.875<   > -1234.9<
2690Sstevel@tonic-gate>%*.*f<     >[5, 2, 12.3456]< >12.35<
2700Sstevel@tonic-gate>%f<        >0<           >0.000000<
2710Sstevel@tonic-gate>%.0f<      >0<           >0<
2720Sstevel@tonic-gate>%.0f<      >2**38<       >274877906944<   >Should have exact int'l rep'n<
2730Sstevel@tonic-gate>%.0f<      >0.1<         >0<
2740Sstevel@tonic-gate>%.0f<      >0.6<         >1<              >Known to fail with sfio, (irix|nonstop-ux|powerux); -DHAS_LDBL_SPRINTF_BUG may fix<
2750Sstevel@tonic-gate>%.0f<      >-0.6<        >-1<             >Known to fail with sfio, (irix|nonstop-ux|powerux); -DHAS_LDBL_SPRINTF_BUG may fix<
2760Sstevel@tonic-gate>%.0f<      >1.6<         >2<
2770Sstevel@tonic-gate>%.0f<      >-1.6<        >-2<
2780Sstevel@tonic-gate>%.0f<      >1<           >1<
2790Sstevel@tonic-gate>%#.0f<     >1<           >1.<
2800Sstevel@tonic-gate>%.0lf<     >1<           >1<              >'l' should have no effect<
2810Sstevel@tonic-gate>%.0hf<     >1<           >%.0hf INVALID<  >'h' should be rejected<
2820Sstevel@tonic-gate>%g<        >12345.6789<  >12345.7<
2830Sstevel@tonic-gate>%+g<       >12345.6789<  >+12345.7<
2840Sstevel@tonic-gate>%#g<       >12345.6789<  >12345.7<
2850Sstevel@tonic-gate>%.0g<      >12345.6789<  >1e+04<
2860Sstevel@tonic-gate>%#.0g<     >12345.6789<  >1.e+04<
2870Sstevel@tonic-gate>%.2g<      >12345.6789<  >1.2e+04<
2880Sstevel@tonic-gate>%.*g<      >[2, 12345.6789]< >1.2e+04<
2890Sstevel@tonic-gate>%.9g<      >12345.6789<  >12345.6789<
2900Sstevel@tonic-gate>%12.9g<    >12345.6789<  >  12345.6789<
2910Sstevel@tonic-gate>%012.9g<   >12345.6789<  >0012345.6789<
2920Sstevel@tonic-gate>%-12.9g<   >12345.6789<  >12345.6789  <
2930Sstevel@tonic-gate>%*.*g<     >[-12, 9, 12345.6789]< >12345.6789  <
2940Sstevel@tonic-gate>%-012.9g<  >12345.6789<  >12345.6789  <
2950Sstevel@tonic-gate>%g<        >-12345.6789< >-12345.7<
2960Sstevel@tonic-gate>%+g<       >-12345.6789< >-12345.7<
2970Sstevel@tonic-gate>%g<        >1234567.89<  >1.23457e+06<
2980Sstevel@tonic-gate>%+g<       >1234567.89<  >+1.23457e+06<
2990Sstevel@tonic-gate>%#g<       >1234567.89<  >1.23457e+06<
3000Sstevel@tonic-gate>%g<        >-1234567.89< >-1.23457e+06<
3010Sstevel@tonic-gate>%+g<       >-1234567.89< >-1.23457e+06<
3020Sstevel@tonic-gate>%#g<       >-1234567.89< >-1.23457e+06<
3030Sstevel@tonic-gate>%g<        >0.00012345<  >0.00012345<
3040Sstevel@tonic-gate>%g<        >0.000012345< >1.2345e-05<
3050Sstevel@tonic-gate>%g<        >1234567E96<  >1.23457e+102<
3060Sstevel@tonic-gate>%g<        >.1234567E-101< >1.23457e-102<
3070Sstevel@tonic-gate>%g<        >0<           >0<
3080Sstevel@tonic-gate>%13g<      >1234567.89<  >  1.23457e+06<
3090Sstevel@tonic-gate>%+13g<     >1234567.89<  > +1.23457e+06<
3100Sstevel@tonic-gate>%013g<      >1234567.89< >001.23457e+06<
3110Sstevel@tonic-gate>%-13g<      >1234567.89< >1.23457e+06  <
3120Sstevel@tonic-gate>%h<        >''<          >%h INVALID<
3130Sstevel@tonic-gate>%i<        >123456.789<  >123456<         >Synonym for %d<
3140Sstevel@tonic-gate>%j<        >''<          >%j INVALID<
3150Sstevel@tonic-gate>%k<        >''<          >%k INVALID<
3160Sstevel@tonic-gate>%l<        >''<          >%l INVALID<
3170Sstevel@tonic-gate>%m<        >''<          >%m INVALID<
3180Sstevel@tonic-gate>%s< >sprintf('%%n%n %d', $n, $n)< >%n 2< >Slight sneakiness to test %n<
3190Sstevel@tonic-gate>%o<        >2**32-1<     >37777777777<
3200Sstevel@tonic-gate>%+o<       >2**32-1<     >37777777777<
3210Sstevel@tonic-gate>%#o<       >2**32-1<     >037777777777<
3220Sstevel@tonic-gate>%o<        >642<         >1202<          >check smaller octals across platforms<
3230Sstevel@tonic-gate>%+o<       >642<         >1202<
3240Sstevel@tonic-gate>%#o<       >642<         >01202<
3250Sstevel@tonic-gate>%d< >$p=sprintf('%p',$p);$p=~/^[0-9a-f]+$/< >1< >Coarse hack: hex from %p?<
3260Sstevel@tonic-gate>%#p<       >''<          >%#p INVALID<
3270Sstevel@tonic-gate>%q<        >''<          >%q INVALID<
3280Sstevel@tonic-gate>%r<        >''<          >%r INVALID<
3290Sstevel@tonic-gate>%s<        >'string'<    >string<
3300Sstevel@tonic-gate>%10s<      >'string'<    >    string<
3310Sstevel@tonic-gate>%+10s<     >'string'<    >    string<
3320Sstevel@tonic-gate>%#10s<     >'string'<    >    string<
3330Sstevel@tonic-gate>%010s<     >'string'<    >0000string<
3340Sstevel@tonic-gate>%0*s<      >[10, 'string']< >0000string<
3350Sstevel@tonic-gate>%-10s<     >'string'<    >string    <
3360Sstevel@tonic-gate>%3s<       >'string'<    >string<
3370Sstevel@tonic-gate>%.3s<      >'string'<    >str<
3380Sstevel@tonic-gate>%.*s<      >[3, 'string']< >str<
3390Sstevel@tonic-gate>%t<        >''<          >%t INVALID<
3400Sstevel@tonic-gate>%u<        >2**32-1<     >4294967295<
3410Sstevel@tonic-gate>%+u<       >2**32-1<     >4294967295<
3420Sstevel@tonic-gate>%#u<       >2**32-1<     >4294967295<
3430Sstevel@tonic-gate>%12u<      >2**32-1<     >  4294967295<
3440Sstevel@tonic-gate>%012u<     >2**32-1<     >004294967295<
3450Sstevel@tonic-gate>%-12u<     >2**32-1<     >4294967295  <
3460Sstevel@tonic-gate>%-012u<    >2**32-1<     >4294967295  <
3470Sstevel@tonic-gate>%v<        >''<          >%v INVALID<
3480Sstevel@tonic-gate>%w<        >''<          >%w INVALID<
3490Sstevel@tonic-gate>%x<        >2**32-1<     >ffffffff<
3500Sstevel@tonic-gate>%+x<       >2**32-1<     >ffffffff<
3510Sstevel@tonic-gate>%#x<       >2**32-1<     >0xffffffff<
3520Sstevel@tonic-gate>%10x<      >2**32-1<     >  ffffffff<
3530Sstevel@tonic-gate>%010x<     >2**32-1<     >00ffffffff<
3540Sstevel@tonic-gate>%-10x<     >2**32-1<     >ffffffff  <
3550Sstevel@tonic-gate>%-010x<    >2**32-1<     >ffffffff  <
3560Sstevel@tonic-gate>%0-10x<    >2**32-1<     >ffffffff  <
3570Sstevel@tonic-gate>%0*x<      >[-10, ,2**32-1]< >ffffffff  <
3580Sstevel@tonic-gate>%y<        >''<          >%y INVALID<
3590Sstevel@tonic-gate>%z<        >''<          >%z INVALID<
3600Sstevel@tonic-gate>%2$d %1$d<	>[12, 34]<	>34 12<
3610Sstevel@tonic-gate>%*2$d<		>[12, 3]<	> 12<
3620Sstevel@tonic-gate>%2$d %d<	>[12, 34]<	>34 12<
3630Sstevel@tonic-gate>%2$d %d %d<	>[12, 34]<	>34 12 34<
3640Sstevel@tonic-gate>%3$d %d %d<	>[12, 34, 56]<	>56 12 34<
3650Sstevel@tonic-gate>%2$*3$d %d<	>[12, 34, 3]<	> 34 12<
3660Sstevel@tonic-gate>%*3$2$d %d<	>[12, 34, 3]<	>%*3$2$d 12 INVALID<
3670Sstevel@tonic-gate>%2$d<		>12<	>0 UNINIT<
3680Sstevel@tonic-gate>%0$d<		>12<	>%0$d INVALID<
3690Sstevel@tonic-gate>%1$$d<		>12<	>%1$$d INVALID<
3700Sstevel@tonic-gate>%1$1$d<	>12<	>%1$1$d INVALID<
3710Sstevel@tonic-gate>%*2$*2$d<	>[12, 3]<	>%*2$*2$d INVALID<
3720Sstevel@tonic-gate>%*2*2$d<	>[12, 3]<	>%*2*2$d INVALID<
3730Sstevel@tonic-gate>%0v2.2d<	>''<	><
3740Sstevel@tonic-gate>%vc,%d<	>[63, 64, 65]<	>?,64<
3750Sstevel@tonic-gate>%vd,%d<	>[1, 2, 3]<	>49,2<
3760Sstevel@tonic-gate>%vf,%d<	>[1, 2, 3]<	>1.000000,2<
3770Sstevel@tonic-gate>%vp<	>''<	>%vp INVALID<
3780Sstevel@tonic-gate>%vs,%d<	>[1, 2, 3]<	>1,2<
3790Sstevel@tonic-gate>%v_<	>''<	>%v_ INVALID<
3800Sstevel@tonic-gate>%v#x<	>''<	>%v#x INVALID<
3810Sstevel@tonic-gate>%v02x<	>"foo\012"<	>66.6f.6f.0a<
3820Sstevel@tonic-gate>%V-%s<		>["Hello"]<	>%V-Hello INVALID<
3830Sstevel@tonic-gate>%K %d %d<	>[13, 29]<	>%K 13 29 INVALID<
3840Sstevel@tonic-gate>%*.*K %d<	>[13, 29, 76]<	>%*.*K 13 INVALID<
3850Sstevel@tonic-gate>%4$K %d<	>[45, 67]<	>%4$K 45 INVALID<
3860Sstevel@tonic-gate>%d %K %d<	>[23, 45]<	>23 %K 45 INVALID<
3870Sstevel@tonic-gate>%*v*999\$d %d %d<	>[11, 22, 33]<	>%*v*999\$d 11 22 INVALID<
388*1277Salanbur>%#b<		>0<	>0<
389*1277Salanbur>%#o<		>0<	>0<
390*1277Salanbur>%#x<		>0<	>0<
391*1277Salanbur>%2918905856$v2d<	>''<	><
392*1277Salanbur>%*2918905856$v2d<	>''<	> UNINIT<
393