Heray-Was-Here
Server : Apache
System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : calvet ( 273824)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /usr/share/doc/perl-Moose/t/bugs/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/doc/perl-Moose/t/bugs/DEMOLISHALL_shortcutted.t
use strict;
use warnings;

## 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 Moose::Role;
our $ok = 0;

sub BUILD { $ok = 0 };
after 'DEMOLISHALL' => sub { $Role::DemolishAll::ok++ };

package DemolishAll::WithoutDemolish;
use Moose;
with 'Role::DemolishAll';

package DemolishAll::WithDemolish;
use Moose;
with 'Role::DemolishAll';
sub DEMOLISH {};


package main;
use Test::More;

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' );

done_testing;

Hry