Commit | Line | Data |
4c98ebb0 |
1 | use strict; |
c47cf415 |
2 | # This is automatically generated by author/import-moose-test.pl. |
3 | # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! |
4 | use t::lib::MooseCompat; |
4c98ebb0 |
5 | use warnings; |
6 | |
c47cf415 |
7 | use Test::More; |
8 | $TODO = q{Mouse is not yet completed}; |
4c98ebb0 |
9 | use Test::Exception; |
10 | |
11 | { |
12 | package MyClass; |
13 | use Mouse; |
14 | |
15 | sub DEMOLISH { } |
16 | } |
17 | |
18 | my $object = MyClass->new; |
19 | |
20 | # Removing the metaclass simulates the case where the metaclass object |
21 | # goes out of scope _before_ the object itself, which under normal |
22 | # circumstances only happens during global destruction. |
c47cf415 |
23 | Mouse::Util::remove_metaclass_by_name('MyClass'); |
4c98ebb0 |
24 | |
25 | # The bug happened when DEMOLISHALL called |
c47cf415 |
26 | # Mouse::Util::class_of($object) and did not get a metaclass object |
4c98ebb0 |
27 | # back. |
28 | lives_ok { $object->DESTROY } |
29 | 'can call DESTROY on an object without a metaclass object in the CMOP cache'; |
30 | |
31 | |
32 | MyClass->meta->make_immutable; |
c47cf415 |
33 | Mouse::Util::remove_metaclass_by_name('MyClass'); |
4c98ebb0 |
34 | |
35 | # The bug didn't manifest for immutable objects, but this test should |
36 | # help us prevent it happening in the future. |
37 | lives_ok { $object->DESTROY } |
38 | 'can call DESTROY on an object without a metaclass object in the CMOP cache (immutable version)'; |
c47cf415 |
39 | |
40 | done_testing; |