Remove all magic in untie()
[p5sagit/p5-mst-13.2.git] / t / op / tie.t
index d643b78..dfbf44b 100755 (executable)
@@ -326,3 +326,20 @@ print $f4{'foo'}[0],"\n";
 EXPECT
 2
 3
+########
+# test untie() from within FETCH
+package Foo;
+sub TIESCALAR { my $pkg = shift; return bless [@_], $pkg; }
+sub FETCH {
+  my $self = shift;
+  my ($obj, $field) = @$self;
+  untie $obj->{$field};
+  $obj->{$field} = "Bar";
+}
+package main;
+tie $a->{foo}, "Foo", $a, "foo";
+$a->{foo}; # access once
+# the hash element should not be tied anymore
+print defined tied $a->{foo} ? "not ok" : "ok";
+EXPECT
+ok