Avoid potentially empty struct.
[p5sagit/p5-mst-13.2.git] / t / op / tiehandle.t
index 7ae3351..257a613 100755 (executable)
@@ -77,7 +77,7 @@ package main;
 
 use Symbol;
 
-print "1..38\n";
+print "1..39\n";
 
 my $fh = gensym;
 
@@ -160,7 +160,7 @@ ok($r == 1);
     use warnings;
     # Special case of aliasing STDERR, which used
     # to dump core when warnings were enabled
-    *STDERR = *$fh;
+    local *STDERR = *$fh;
     @expect = (PRINT => $ob,"some","text");
     $r = print STDERR @expect[2,3];
     ok($r == 1);
@@ -217,3 +217,16 @@ ok($r == 1);
     sub TIEARRAY  {bless {}}
 }
 
+{
+    # warnings should pass to the PRINT method of tied STDERR
+    my @received;
+
+    local *STDERR = *$fh;
+    local *Implement::PRINT = sub { @received = @_ };
+
+    $r = warn("some", "text", "\n");
+    @expect = (PRINT => $ob,"sometext\n");
+
+    Implement::compare(PRINT => @received);
+}
+