Explicitly check that our $_; is special, and forced to main::
[p5sagit/p5-mst-13.2.git] / t / op / alarm.t
index 907c385..118ee9d 100644 (file)
@@ -13,7 +13,7 @@ BEGIN {
     }
 }
 
-plan tests => 4;
+plan tests => 5;
 my $Perl = which_perl();
 
 my $start_time = time;
@@ -44,4 +44,16 @@ $diff = time - $start_time;
 # alarm time might be one second less than you said.
 is( $@, "ALARM!\n",             'alarm w/$SIG{ALRM} vs system()' );
 
-ok( abs($diff - 3) <= 1,   '   right time' );
+{
+    local $TODO = "Why does system() block alarm() on $^O?"
+               if $^O eq 'VMS' || $^O eq 'dos';
+    ok( abs($diff - 3) <= 1,   "   right time (waited $diff secs for 3-sec alarm)" );
+}
+
+
+{
+    local $SIG{"ALRM"} = sub { die };
+    eval { alarm(1); my $x = qx($Perl -e "sleep 3") };
+    chomp (my $foo = "foo\n");
+    ok($foo eq "foo", '[perl #33928] chomp() fails after alarm(), `sleep`');
+}