Commit | Line | Data |
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 |
4 | package Role::DemolishAll; |
5 | use Mouse::Role; |
6 | our $ok = 0; |
7 | |
8 | sub BUILD { $ok = 0 }; |
9 | after 'DEMOLISHALL' => sub { $Role::DemolishAll::ok++ }; |
10 | |
11 | package DemolishAll::WithoutDemolish; |
12 | use Mouse; |
13 | with 'Role::DemolishAll'; |
14 | |
15 | package DemolishAll::WithDemolish; |
16 | use Mouse; |
17 | with 'Role::DemolishAll'; |
18 | sub DEMOLISH {}; |
19 | |
20 | |
21 | package main; |
22 | use Test::More tests => 2; |
23 | |
24 | my $m = DemolishAll::WithDemolish->new; |
25 | undef $m; |
26 | is ( $Role::DemolishAll::ok, 1, 'DemolishAll w/ explicit DEMOLISH sub' ); |
27 | |
28 | $m = DemolishAll::WithoutDemolish->new; |
29 | undef $m; |
30 | is ( $Role::DemolishAll::ok, 1, 'DemolishAll wo/ explicit DEMOLISH sub' ); |
31 | |
32 | 1; |