C++: Solaris CC now compiles "perl"
[p5sagit/p5-mst-13.2.git] / t / comp / fold.t
index f063c20..92a4fbe 100644 (file)
@@ -8,7 +8,7 @@ BEGIN {
 use strict;
 use warnings;
 
-plan (8);
+plan (13);
 
 # Historically constant folding was performed by evaluating the ops, and if
 # they threw an exception compilation failed. This was seen as buggy, because
@@ -17,6 +17,7 @@ plan (8);
 # making constant folding consistent with many other languages, and purely an
 # optimisation rather than a behaviour change.
 
+
 my $a;
 $a = eval '$b = 0/0 if 0; 3';
 is ($a, 3);
@@ -36,3 +37,20 @@ $a = eval q{
 is ($a, 5);
 is ($@, "");
 
+# warn and die hooks should be disabled during constant folding
+
+{
+    my $c = 0;
+    local $SIG{__WARN__} = sub { $c++   };
+    local $SIG{__DIE__}  = sub { $c+= 2 };
+    eval q{
+       is($c, 0, "premature warn/die: $c");
+       my $x = "a"+5;
+       is($c, 1, "missing warn hook");
+       is($x, 5, "a+5");
+       $c = 0;
+       $x = 1/0;
+    };
+    like ($@, qr/division/, "eval caught division");
+    is($c, 2, "missing die hook");
+}