+sub X::foo { 'X::foo' }
+
+{
+ {
+ {
+ localize_delete '&X::foo', undef => UP;
+ is(X->foo(), 'X::foo', 'localize_delete "&X::foo", undef => UP [not yet X]');
+ }
+ ok(!X->can('foo'), 'localize_delete "&X::foo", undef => UP [ok X]');
+ }
+ is(X->foo(), 'X::foo', 'localize_delete "&X::foo", undef => UP [end X]');
+}
+
+@Y::ISA = 'X';
+
+{
+ {
+ {
+ localize_delete '&X::foo', undef => UP;
+ is(Y->foo(), 'X::foo', 'localize_delete "&X::foo", undef => UP [not yet Y]');
+ }
+ ok(!Y->can('foo'), 'localize_delete "&X::foo", undef => UP [ok Y]');
+ }
+ is(Y->foo(), 'X::foo', 'localize_delete "&X::foo", undef => UP [end Y]');
+}
+
+
+{
+ local *Y::foo = sub { 'Y::foo' };
+ {
+ {
+ localize_delete '&Y::foo', undef => UP;
+ is(Y->foo(), 'Y::foo', 'localize_delete "&Y::foo", undef => UP [not yet]');
+ }
+ is(Y->foo(), 'X::foo', 'localize_delete "&Y::foo", undef => UP [ok]');
+ }
+ is(Y->foo(), 'Y::foo', 'localize_delete "&Y::foo", undef => UP [end]');
+}
+
+{
+ # Prevent 'only once' warnings
+ local *Y::foo = *Y::foo;
+}
+