Re: Regex-Unicode bugs
[p5sagit/p5-mst-13.2.git] / t / op / tie.t
index afcc4a1..9a65155 100755 (executable)
@@ -162,19 +162,28 @@ $C = $B = tied %H ;
 untie %H;
 EXPECT
 ########
-
-# verify no leak when underlying object is selfsame tied variable
-my ($a, $b);
+# Forbidden aggregate self-ties
+my ($a, $b) = (0, 0);
 sub Self::TIEHASH { bless $_[1], $_[0] }
-sub Self::DESTROY { $b = $_[0] + 0; }
+sub Self::DESTROY { $b = $_[0] + 1; }
+{
+    my %c = 42;
+    tie %c, 'Self', \%c;
+}
+EXPECT
+Self-ties of arrays and hashes are not supported 
+########
+# Allowed scalar self-ties
+my ($a, $b) = (0, 0);
+sub Self::TIESCALAR { bless $_[1], $_[0] }
+sub Self::DESTROY   { $b = $_[0] + 1; }
 {
-    my %b5;
-    $a = \%b5 + 0;
-    tie %b5, 'Self', \%b5;
+    my $c = 42;
+    $a = $c + 0;
+    tie $c, 'Self', \$c;
 }
-die unless $a == $b;
+die unless $a == 0 && $b == 43;
 EXPECT
-Self-ties are not supported 
 ########
 # Interaction of tie and vec
 
@@ -187,3 +196,9 @@ vec($a,1,1)=0;
 vec($b,1,1)=0;
 die unless $a eq $b;
 EXPECT
+########
+# An attempt at lvalueable barewords broke this
+
+tie FH, 'main';
+EXPECT
+