This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Check that %v$foo does not crash.
authorNicholas Clark <nick@ccl4.org>
Mon, 12 Dec 2005 15:24:06 +0000 (15:24 +0000)
committerNicholas Clark <nick@ccl4.org>
Mon, 12 Dec 2005 15:24:06 +0000 (15:24 +0000)
p4raw-id: //depot/perl@26332

t/op/sprintf2.t

index d668e60..6527a13 100644 (file)
@@ -6,7 +6,7 @@ BEGIN {
     require './test.pl';
 }   
 
-plan tests => 7;
+plan tests => 7 + 256;
 
 is(
     sprintf("%.40g ",0.01),
@@ -54,3 +54,16 @@ fresh_perl_is(
     is($bad,   0, "unexpected warnings");
 }
 
+{
+    foreach my $ord (0 .. 255) {
+       my $bad = 0;
+       local $SIG{__WARN__} = sub {
+           if ($_[0] !~ /^Invalid conversion in sprintf/) {
+               warn $_[0];
+               $bad++;
+           }
+       };
+       my $r = eval {sprintf '%v' . chr $ord};
+       is ($bad, 0, "pattern '%v' . chr $ord");
+    }
+}