Commit | Line | Data |
106bf37c |
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 Moose::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 Moose; |
13 | with 'Role::DemolishAll'; |
14 | |
15 | package DemolishAll::WithDemolish; |
16 | use Moose; |
17 | with 'Role::DemolishAll'; |
18 | sub DEMOLISH {}; |
19 | |
20 | |
21 | package main; |
a28e50e4 |
22 | use Test::More; |
106bf37c |
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 | |
a28e50e4 |
32 | done_testing; |