SYN SYN
[p5sagit/p5-mst-13.2.git] / t / op / tie.t
index 105b1d6..afcc4a1 100755 (executable)
@@ -6,13 +6,14 @@
 # Currently it only tests the untie warning 
 
 chdir 't' if -d 't';
-unshift @INC, "../lib";
+@INC = '../lib';
 $ENV{PERL5LIB} = "../lib";
 
 $|=1;
 
 # catch warnings into fatal errors
 $SIG{__WARN__} = sub { die "WARNING: @_" } ;
+$SIG{__DIE__}  = sub { die @_ };
 
 undef $/;
 @prgs = split "\n########\n", <DATA>;
@@ -25,7 +26,7 @@ for (@prgs){
     $results = $@ ;
     $results =~ s/\n+$//;
     $expected =~ s/\n+$//;
-    if ( $status or $results and $results !~ /^WARNING: $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";
@@ -44,6 +45,21 @@ untie %h;
 EXPECT
 ########
 
+# standard behaviour, without any extra references
+use Tie::Hash ;
+{package Tie::HashUntie;
+ use base 'Tie::StdHash';
+ sub UNTIE
+  {
+   warn "Untied\n";
+  }
+}
+tie %h, Tie::HashUntie;
+untie %h;
+EXPECT
+Untied
+########
+
 # standard behaviour, with 1 extra reference
 use Tie::Hash ;
 $a = tie %h, Tie::StdHash;
@@ -78,7 +94,6 @@ EXPECT
 
 # strict behaviour, without any extra references
 use warnings 'untie';
-#local $^W = 1 ;
 use Tie::Hash ;
 tie %h, Tie::StdHash;
 untie %h;
@@ -87,7 +102,6 @@ EXPECT
 
 # strict behaviour, with 1 extra references generating an error
 use warnings 'untie';
-#local $^W = 1 ;
 use Tie::Hash ;
 $a = tie %h, Tie::StdHash;
 untie %h;
@@ -97,7 +111,6 @@ untie attempted while 1 inner references still exist
 
 # strict behaviour, with 1 extra references via tied generating an error
 use warnings 'untie';
-#local $^W = 1 ;
 use Tie::Hash ;
 tie %h, Tie::StdHash;
 $a = tied %h;
@@ -108,7 +121,6 @@ untie attempted while 1 inner references still exist
 
 # strict behaviour, with 1 extra references which are destroyed
 use warnings 'untie';
-#local $^W = 1 ;
 use Tie::Hash ;
 $a = tie %h, Tie::StdHash;
 $a = 0 ;
@@ -118,7 +130,6 @@ EXPECT
 
 # strict behaviour, with extra 1 references via tied which are destroyed
 use warnings 'untie';
-#local $^W = 1 ;
 use Tie::Hash ;
 tie %h, Tie::StdHash;
 $a = tied %h;
@@ -129,7 +140,6 @@ EXPECT
 
 # strict error behaviour, with 2 extra references 
 use warnings 'untie';
-#local $^W = 1 ;
 use Tie::Hash ;
 $a = tie %h, Tie::StdHash;
 $b = tied %h ;
@@ -140,13 +150,11 @@ untie attempted while 2 inner references still exist
 
 # strict behaviour, check scope of strictness.
 no warnings 'untie';
-#local $^W = 0 ;
 use Tie::Hash ;
 $A = tie %H, Tie::StdHash;
 $C = $B = tied %H ;
 {
     use warnings 'untie';
-    #local $^W = 1 ;
     use Tie::Hash ;
     tie %h, Tie::StdHash;
     untie %h;
@@ -166,6 +174,7 @@ sub Self::DESTROY { $b = $_[0] + 0; }
 }
 die unless $a == $b;
 EXPECT
+Self-ties are not supported 
 ########
 # Interaction of tie and vec