This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #83018] TEST PATCH: commit 95ea86d5 also fixes sprintf("%.2f")
authorZsbán Ambrus <ambrus@math.bme.hu>
Sun, 30 Jan 2011 22:39:33 +0000 (14:39 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 31 Jan 2011 00:28:15 +0000 (16:28 -0800)
This adds some more test cases about the bug that commit
95ea86d5 fixes.

The bug was that in the perl 5.12 branch, sprintf("%.2f") returns ""
whereas it should return "0.00" -- but this only applies in the very
special cases, not eg. when the template has extra characters. The
log message and the tests of that commit only talks about "%.0f", but
I think it would be worth to also test the "%.2f".

t/op/sprintf.t

index 54f3c2b..75f5177 100644 (file)
@@ -379,6 +379,8 @@ __END__
 >%f<        >0<           >0.000000<
 >%.0f<      >[]<          >0 MISSING<
 > %.0f<     >[]<          > 0 MISSING<
+>%.2f<      >[]<          >0.00 MISSING<
+>%.2fC<      >[]<          >0.00C MISSING<
 >%.0f<      >0<           >0<
 >%.0f<      >2**38<       >274877906944<   >Should have exact int'l rep'n<
 >%.0f<      >0.1<         >0<
@@ -395,6 +397,8 @@ __END__
 >%#g<       >12345.6789<  >12345.7<
 >%.0g<      >[]<          >0 MISSING<
 > %.0g<     >[]<          > 0 MISSING<
+>%.2g<      >[]<          >0 MISSING<
+>%.2gC<      >[]<          >0C MISSING<
 >%.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<
 >%.0g<      >12345.6789<  >1e+04<
 >%#.0g<     >12345.6789<  >1.e+04<