Regenerate test files
[gitmo/Mouse.git] / t-failing / 100_bugs / 023_DEMOLISH_fails_without_metaclass.t
CommitLineData
4c98ebb0 1use strict;
fde8e43f 2# This is automatically generated by author/import-moose-test.pl.
3# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4use t::lib::MooseCompat;
4c98ebb0 5use warnings;
6
fde8e43f 7use Test::More;
8$TODO = q{Mouse is not yet completed};
4c98ebb0 9use Test::Exception;
10
11{
12 package MyClass;
13 use Mouse;
14
15 sub DEMOLISH { }
16}
17
18my $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.
fde8e43f 23Mouse::Util::remove_metaclass_by_name('MyClass');
4c98ebb0 24
25# The bug happened when DEMOLISHALL called
fde8e43f 26# Mouse::Util::class_of($object) and did not get a metaclass object
4c98ebb0 27# back.
28lives_ok { $object->DESTROY }
29'can call DESTROY on an object without a metaclass object in the CMOP cache';
30
31
32MyClass->meta->make_immutable;
fde8e43f 33Mouse::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.
37lives_ok { $object->DESTROY }
38'can call DESTROY on an object without a metaclass object in the CMOP cache (immutable version)';
fde8e43f 39
40done_testing;