X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F100_bugs%2F021_DEMOLISHALL_shortcutted.t;fp=t%2F100_bugs%2F021_DEMOLISHALL_shortcutted.t;h=ba1833e51282423e178852bb61efbe35e0cfefa1;hb=4c98ebb0cca8d5d49d3a91eaf735f9861d00ccb0;hp=0000000000000000000000000000000000000000;hpb=ad20156284763b7d6019af2279f24e1af097f3be;p=gitmo%2FMouse.git diff --git a/t/100_bugs/021_DEMOLISHALL_shortcutted.t b/t/100_bugs/021_DEMOLISHALL_shortcutted.t new file mode 100644 index 0000000..ba1833e --- /dev/null +++ b/t/100_bugs/021_DEMOLISHALL_shortcutted.t @@ -0,0 +1,32 @@ +## This test ensures that sub DEMOLISHALL fires even if there is no sub DEMOLISH +## Currently fails because of a bad optimization in DESTROY +## Feb 12, 2009 -- Evan Carroll me@evancarroll.com +package Role::DemolishAll; +use Mouse::Role; +our $ok = 0; + +sub BUILD { $ok = 0 }; +after 'DEMOLISHALL' => sub { $Role::DemolishAll::ok++ }; + +package DemolishAll::WithoutDemolish; +use Mouse; +with 'Role::DemolishAll'; + +package DemolishAll::WithDemolish; +use Mouse; +with 'Role::DemolishAll'; +sub DEMOLISH {}; + + +package main; +use Test::More tests => 2; + +my $m = DemolishAll::WithDemolish->new; +undef $m; +is ( $Role::DemolishAll::ok, 1, 'DemolishAll w/ explicit DEMOLISH sub' ); + +$m = DemolishAll::WithoutDemolish->new; +undef $m; +is ( $Role::DemolishAll::ok, 1, 'DemolishAll wo/ explicit DEMOLISH sub' ); + +1;