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