Revert autogenerated tests. Tests should not changed radically.
[gitmo/Mouse.git] / Moose-t-failing / 100_bugs / 023_DEMOLISH_fails_without_metaclass.t
1 use strict;
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;
5 use warnings;
6
7 use Test::More;
8 $TODO = q{Mouse is not yet completed};
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.
23 Mouse::Util::remove_metaclass_by_name('MyClass');
24
25 # The bug happened when DEMOLISHALL called
26 # Mouse::Util::class_of($object) and did not get a metaclass object
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;
33 Mouse::Util::remove_metaclass_by_name('MyClass');
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)';
39
40 done_testing;