[perl #68108] : also fix if/else constant folding
[p5sagit/p5-mst-13.2.git] / t / op / sprintf.t
old mode 100755 (executable)
new mode 100644 (file)
index 11eeee4..ba77e64
@@ -49,8 +49,8 @@ while (<DATA>) {
     }
 
     $evalData = eval $data;
-    $data = ref $evalData ? $evalData : [$evalData];
-    push @tests, [$template, $data, $result, $comment];
+    $evalData = ref $evalData ? $evalData : [$evalData];
+    push @tests, [$template, $evalData, $result, $comment, $data];
 }
 
 print '1..', scalar @tests, "\n";
@@ -66,9 +66,9 @@ $SIG{__WARN__} = sub {
 };
 
 for ($i = 1; @tests; $i++) {
-    ($template, $data, $result, $comment) = @{shift @tests};
+    ($template, $evalData, $result, $comment, $data) = @{shift @tests};
     $w = undef;
-    $x = sprintf(">$template<", @$data);
+    $x = sprintf(">$template<", @$evalData);
     substr($x, -1, 0) = $w if $w;
     # $x may have 3 exponent digits, not 2
     my $y = $x;
@@ -171,7 +171,9 @@ __END__
 >%6 .6s<    >''<          >%6 .6s INVALID<
 >%6.6 s<    >''<          >%6.6 s INVALID<
 >%A<        >''<          >%A INVALID<
->%B<        >''<          >%B INVALID<
+>%B<        >2**32-1<     >11111111111111111111111111111111<
+>%+B<       >2**32-1<     >11111111111111111111111111111111<
+>%#B<       >2**32-1<     >0B11111111111111111111111111111111<
 >%C<        >''<          >%C INVALID<
 >%D<        >0x7fffffff<  >2147483647<     >Synonym for %ld<
 >%E<        >123456.789<  >1.234568E+05<   >Like %e, but using upper-case "E"<
@@ -217,6 +219,26 @@ __END__
 >% 6.5b<    >12<          > 01100<
 >%06.5b<    >12<          > 01100<         >0 flag with precision: no effect<
 >%.5b<      >12<          >01100<
+>%.0b<      >0<           ><
+>%+.0b<     >0<           ><
+>% .0b<     >0<           ><
+>%-.0b<     >0<           ><
+>%#.0b<     >0<           ><
+>%#3.0b<    >0<           >   <
+>%#3.1b<    >0<           >  0<
+>%#3.2b<    >0<           > 00<
+>%#3.3b<    >0<           >000<
+>%#3.4b<    >0<           >0000<
+>%.0b<      >1<           >1<
+>%+.0b<     >1<           >1<
+>% .0b<     >1<           >1<
+>%-.0b<     >1<           >1<
+>%#.0b<     >1<           >0b1<
+>%#3.0b<    >1<           >0b1<
+>%#3.1b<    >1<           >0b1<
+>%#3.2b<    >1<           >0b01<
+>%#3.3b<    >1<           >0b001<
+>%#3.4b<    >1<           >0b0001<
 >%c<        >ord('A')<    >A<
 >%10c<      >ord('A')<    >         A<
 >%#10c<     >ord('A')<    >         A<     ># modifier: no effect<
@@ -284,11 +306,11 @@ __END__
 >%vd<       >"\01\02\03"< >1.2.3<
 >%vd<       >v1.2.3<      >1.2.3<
 >%vd<       >[version::qv("1.2.3")]< >1.2.3<
->%vd<       >[version->new("1.2")]< >1.200<
->%vd<       >[version->new("1.02")]< >1.20<
+>%vd<       >[version->new("1.2")]< >1.2<
+>%vd<       >[version->new("1.02")]< >1.2<
 >%vd<       >[version->new("1.002")]< >1.2<
->%vd<       >[version->new("1048576.5")]< >1048576.500<
->%vd<       >[version->new("50")]< >50.0<
+>%vd<       >[version->new("1048576.5")]< >1048576.5<
+>%vd<       >[version->new("50")]< >50<
 >%v.3d<     >"\01\02\03"< >001.002.003<
 >%0v3d<     >"\01\02\03"< >001.002.003<
 >%v.3d<     >[version::qv("1.2.3")]< >001.002.003<
@@ -419,6 +441,28 @@ __END__
 >% 4.o<     >36<          >  44<
 >%04.o<     >36<          >  44<          >0 flag with precision: no effect<
 >%.3o<      >18<          >022<
+>%.0o<      >0<           ><
+>%+.0o<     >0<           ><
+>% .0o<     >0<           ><
+>%-.0o<     >0<           ><
+>%#.0o<     >0<           >0<
+>%#3.0o<    >0<           >  0<
+>%#3.1o<    >0<           >  0<
+>%#3.2o<    >0<           > 00<
+>%#3.3o<    >0<           >000<
+>%#3.4o<    >0<           >0000<
+>%.0o<      >1<           >1<
+>%+.0o<     >1<           >1<
+>% .0o<     >1<           >1<
+>%-.0o<     >1<           >1<
+>%#.0o<     >1<           >01<
+>%#3.0o<    >1<           > 01<
+>%#3.1o<    >1<           > 01<
+>%#3.2o<    >1<           > 01<
+>%#3.3o<    >1<           >001<
+>%#3.4o<    >1<           >0001<
+>%#.5o<     >012345<      >012345<
+>%#.5o<     >012<         >00012<
 >%#4o<      >17<          > 021<
 >%#-4o<     >17<          >021 <
 >%-#4o<     >17<          >021 <
@@ -511,6 +555,23 @@ __END__
 >% .0x<     >0<           ><
 >%-.0x<     >0<           ><
 >%#.0x<     >0<           ><
+>%#3.0x<    >0<           >   <
+>%#3.1x<    >0<           >  0<
+>%#3.2x<    >0<           > 00<
+>%#3.3x<    >0<           >000<
+>%#3.4x<    >0<           >0000<
+>%.0x<      >1<           >1<
+>%+.0x<     >1<           >1<
+>% .0x<     >1<           >1<
+>%-.0x<     >1<           >1<
+>%#.0x<     >1<           >0x1<
+>%#3.0x<    >1<           >0x1<
+>%#3.1x<    >1<           >0x1<
+>%#3.2x<    >1<           >0x01<
+>%#3.3x<    >1<           >0x001<
+>%#3.4x<    >1<           >0x0001<
+>%#.5x<     >0x12345<     >0x12345<
+>%#.5x<     >0x12<        >0x00012<
 >%#4x<      >28<          >0x1c<
 >%#4.3x<    >28<          >0x01c<
 >%#-4.3x<   >28<          >0x01c<
@@ -581,8 +642,12 @@ __END__
 >%v#x< >''<    >%v#x INVALID<
 >%v02x<        >"\x66\x6f\x6f\012"<    >66.6f.6f.0a<
 >%#v.8b<       >"\141\000\142"<        >0b01100001.00000000.0b01100010<        >perl #39530<
+>%#v.0o<       >"\001\000\002\000"<    >01.0.02.0<
+>%#v.1o<       >"\001\000\002\000"<    >01.0.02.0<
 >%#v.4o<       >"\141\000\142"<        >0141.0000.0142<        >perl #39530<
 >%#v.3i<       >"\141\000\142"<        >097.000.098<   >perl #39530<
+>%#v.0x<       >"\001\000\002\000"<    >0x1..0x2.<
+>%#v.1x<       >"\001\000\002\000"<    >0x1.0.0x2.0<
 >%#v.2x<       >"\141\000\142"<        >0x61.00.0x62<  >perl #39530<
 >%#v.2X<       >"\141\000\142"<        >0X61.00.0X62<  >perl #39530<
 >%#v.8b<       >"\141\017\142"<        >0b01100001.0b00001111.0b01100010<      >perl #39530<