summaryrefslogtreecommitdiff
path: root/t/op/tie.t
diff options
context:
space:
mode:
Diffstat (limited to 't/op/tie.t')
-rwxr-xr-xt/op/tie.t37
1 files changed, 24 insertions, 13 deletions
diff --git a/t/op/tie.t b/t/op/tie.t
index cf116519e6..77e74db4e2 100755
--- a/t/op/tie.t
+++ b/t/op/tie.t
@@ -3,7 +3,7 @@
# This test harness will (eventually) test the "tie" functionality
# without the need for a *DBM* implementation.
-# Currently it only tests use strict "untie".
+# Currently it only tests the untie warning
chdir 't' if -d 't';
@INC = "../lib";
@@ -11,6 +11,9 @@ $ENV{PERL5LIB} = "../lib";
$|=1;
+# catch warnings into fatal errors
+$SIG{__WARN__} = sub { die "WARNING: @_" } ;
+
undef $/;
@prgs = split "\n########\n", <DATA>;
print "1..", scalar @prgs, "\n";
@@ -22,7 +25,7 @@ for (@prgs){
$results = $@ ;
$results =~ s/\n+$//;
$expected =~ s/\n+$//;
- if ( $status or $results !~ /^$expected/){
+ if ( $status or $results and $results !~ /^WARNING: $expected/){
print STDERR "STATUS: $status\n";
print STDERR "PROG: $prog\n";
print STDERR "EXPECTED:\n$expected\n";
@@ -74,7 +77,8 @@ EXPECT
########
# strict behaviour, without any extra references
-use strict 'untie';
+#use warning 'untie';
+local $^W = 1 ;
use Tie::Hash ;
tie %h, Tie::StdHash;
untie %h;
@@ -82,26 +86,29 @@ EXPECT
########
# strict behaviour, with 1 extra references generating an error
-use strict 'untie';
+#use warning 'untie';
+local $^W = 1 ;
use Tie::Hash ;
$a = tie %h, Tie::StdHash;
untie %h;
EXPECT
-Can't untie: 1 inner references still exist at
+untie attempted while 1 inner references still exist
########
# strict behaviour, with 1 extra references via tied generating an error
-use strict 'untie';
+#use warning 'untie';
+local $^W = 1 ;
use Tie::Hash ;
tie %h, Tie::StdHash;
$a = tied %h;
untie %h;
EXPECT
-Can't untie: 1 inner references still exist at
+untie attempted while 1 inner references still exist
########
# strict behaviour, with 1 extra references which are destroyed
-use strict 'untie';
+#use warning 'untie';
+local $^W = 1 ;
use Tie::Hash ;
$a = tie %h, Tie::StdHash;
$a = 0 ;
@@ -110,7 +117,8 @@ EXPECT
########
# strict behaviour, with extra 1 references via tied which are destroyed
-use strict 'untie';
+#use warning 'untie';
+local $^W = 1 ;
use Tie::Hash ;
tie %h, Tie::StdHash;
$a = tied %h;
@@ -120,22 +128,25 @@ EXPECT
########
# strict error behaviour, with 2 extra references
-use strict 'untie';
+#use warning 'untie';
+local $^W = 1 ;
use Tie::Hash ;
$a = tie %h, Tie::StdHash;
$b = tied %h ;
untie %h;
EXPECT
-Can't untie: 2 inner references still exist at
+untie attempted while 2 inner references still exist
########
# strict behaviour, check scope of strictness.
-no strict 'untie';
+#no warning 'untie';
+local $^W = 0 ;
use Tie::Hash ;
$A = tie %H, Tie::StdHash;
$C = $B = tied %H ;
{
- use strict 'untie';
+ #use warning 'untie';
+ local $^W = 1 ;
use Tie::Hash ;
tie %h, Tie::StdHash;
untie %h;