Skip BUILDALL in the default constructor, and DEMOLISHALL in the default destructor:
[gitmo/Mouse.git] / t / 100_bugs / 021_DEMOLISHALL_shortcutted.t
CommitLineData
4c98ebb0 1## This test ensures that sub DEMOLISHALL fires even if there is no sub DEMOLISH
2## Currently fails because of a bad optimization in DESTROY
3## Feb 12, 2009 -- Evan Carroll me@evancarroll.com
4package Role::DemolishAll;
5use Mouse::Role;
6our $ok = 0;
7
8sub BUILD { $ok = 0 };
9after 'DEMOLISHALL' => sub { $Role::DemolishAll::ok++ };
10
11package DemolishAll::WithoutDemolish;
12use Mouse;
13with 'Role::DemolishAll';
14
15package DemolishAll::WithDemolish;
16use Mouse;
17with 'Role::DemolishAll';
18sub DEMOLISH {};
19
20
21package main;
22use Test::More tests => 2;
23
24my $m = DemolishAll::WithDemolish->new;
25undef $m;
26is ( $Role::DemolishAll::ok, 1, 'DemolishAll w/ explicit DEMOLISH sub' );
27
28$m = DemolishAll::WithoutDemolish->new;
29undef $m;
30is ( $Role::DemolishAll::ok, 1, 'DemolishAll wo/ explicit DEMOLISH sub' );
31
321;