Test hex('x...').
[p5sagit/p5-mst-13.2.git] / t / op / tie.t
index 77e74db..49f07d4 100755 (executable)
@@ -6,7 +6,7 @@
 # Currently it only tests the untie warning 
 
 chdir 't' if -d 't';
-@INC = "../lib";
+unshift @INC, "../lib";
 $ENV{PERL5LIB} = "../lib";
 
 $|=1;
@@ -77,8 +77,8 @@ EXPECT
 ########
 
 # strict behaviour, without any extra references
-#use warning 'untie';
-local $^W = 1 ;
+use warning 'untie';
+#local $^W = 1 ;
 use Tie::Hash ;
 tie %h, Tie::StdHash;
 untie %h;
@@ -86,8 +86,8 @@ EXPECT
 ########
 
 # strict behaviour, with 1 extra references generating an error
-#use warning 'untie';
-local $^W = 1 ;
+use warning 'untie';
+#local $^W = 1 ;
 use Tie::Hash ;
 $a = tie %h, Tie::StdHash;
 untie %h;
@@ -96,8 +96,8 @@ untie attempted while 1 inner references still exist
 ########
 
 # strict behaviour, with 1 extra references via tied generating an error
-#use warning 'untie';
-local $^W = 1 ;
+use warning 'untie';
+#local $^W = 1 ;
 use Tie::Hash ;
 tie %h, Tie::StdHash;
 $a = tied %h;
@@ -107,8 +107,8 @@ untie attempted while 1 inner references still exist
 ########
 
 # strict behaviour, with 1 extra references which are destroyed
-#use warning 'untie';
-local $^W = 1 ;
+use warning 'untie';
+#local $^W = 1 ;
 use Tie::Hash ;
 $a = tie %h, Tie::StdHash;
 $a = 0 ;
@@ -117,8 +117,8 @@ EXPECT
 ########
 
 # strict behaviour, with extra 1 references via tied which are destroyed
-#use warning 'untie';
-local $^W = 1 ;
+use warning 'untie';
+#local $^W = 1 ;
 use Tie::Hash ;
 tie %h, Tie::StdHash;
 $a = tied %h;
@@ -128,8 +128,8 @@ EXPECT
 ########
 
 # strict error behaviour, with 2 extra references 
-#use warning 'untie';
-local $^W = 1 ;
+use warning 'untie';
+#local $^W = 1 ;
 use Tie::Hash ;
 $a = tie %h, Tie::StdHash;
 $b = tied %h ;
@@ -139,17 +139,42 @@ untie attempted while 2 inner references still exist
 ########
 
 # strict behaviour, check scope of strictness.
-#no warning 'untie';
-local $^W = 0 ;
+no warning 'untie';
+#local $^W = 0 ;
 use Tie::Hash ;
 $A = tie %H, Tie::StdHash;
 $C = $B = tied %H ;
 {
-    #use warning 'untie';
-    local $^W = 1 ;
+    use warning 'untie';
+    #local $^W = 1 ;
     use Tie::Hash ;
     tie %h, Tie::StdHash;
     untie %h;
 }
 untie %H;
 EXPECT
+########
+
+# verify no leak when underlying object is selfsame tied variable
+my ($a, $b);
+sub Self::TIEHASH { bless $_[1], $_[0] }
+sub Self::DESTROY { $b = $_[0] + 0; }
+{
+    my %b5;
+    $a = \%b5 + 0;
+    tie %b5, 'Self', \%b5;
+}
+die unless $a == $b;
+EXPECT
+########
+# Interaction of tie and vec
+
+my ($a, $b);
+use Tie::Scalar;
+tie $a,Tie::StdScalar or die;
+vec($b,1,1)=1;
+$a = $b;
+vec($a,1,1)=0;
+vec($b,1,1)=0;
+die unless $a eq $b;
+EXPECT