14 my $object = MyClass->new;
16 # Removing the metaclass simulates the case where the metaclass object
17 # goes out of scope _before_ the object itself, which under normal
18 # circumstances only happens during global destruction.
19 Class::MOP::remove_metaclass_by_name('MyClass');
21 # The bug happened when DEMOLISHALL called
22 # Class::MOP::class_of($object) and did not get a metaclass object
24 lives_ok { $object->DESTROY }
25 'can call DESTROY on an object without a metaclass object in the CMOP cache';
28 MyClass->meta->make_immutable;
29 Class::MOP::remove_metaclass_by_name('MyClass');
31 # The bug didn't manifest for immutable objects, but this test should
32 # help us prevent it happening in the future.
33 lives_ok { $object->DESTROY }
34 'can call DESTROY on an object without a metaclass object in the CMOP cache (immutable version)';