#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 3;
+use Test::More tests => 5;
my @called;
push @called, 'Class::BUILD';
}
- sub BUILDALL {
- my $self = shift;
- push @called, 'Class::BUILDALL';
- $self->SUPER::BUILDALL(@_);
- }
+# sub BUILDALL {
+# my $self = shift;
+# push @called, 'Class::BUILDALL';
+# $self->SUPER::BUILDALL(@_);
+# }
package Child;
use Mouse;
push @called, 'Child::BUILD';
}
- sub BUILDALL {
- my $self = shift;
- push @called, 'Child::BUILDALL';
- $self->SUPER::BUILDALL(@_);
- }
+# sub BUILDALL {
+# my $self = shift;
+# push @called, 'Child::BUILDALL';
+# $self->SUPER::BUILDALL(@_);
+# }
};
is_deeply([splice @called], [], "no BUILD calls yet");
my $object = Class->new;
-is_deeply([splice @called], ["Class::BUILDALL", "Class::BUILD"]);
+is_deeply([splice @called], ["Class::BUILD"]);
my $child = Child->new;
-is_deeply([splice @called], ["Child::BUILDALL", "Class::BUILDALL", "Class::BUILD", "Child::BUILD"]);
+is_deeply([splice @called], ["Class::BUILD", "Child::BUILD"]);
+
+Class->meta->make_immutable;
+Child->meta->make_immutable;
+
+$object = Class->new;
+
+is_deeply([splice @called], ["Class::BUILD"], 'after make_immutable');
+
+$child = Child->new;
+
+is_deeply([splice @called], ["Class::BUILD", "Child::BUILD"], 'after make_immutable');
+
#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 5;
+use Test::More tests => 10;
my @called;
push @called, 'Class::DEMOLISH';
}
- sub DEMOLISHALL {
- my $self = shift;
- push @called, 'Class::DEMOLISHALL';
- $self->SUPER::DEMOLISHALL(@_);
- }
+# sub DEMOLISHALL {
+# my $self = shift;
+# push @called, 'Class::DEMOLISHALL';
+# $self->SUPER::DEMOLISHALL(@_);
+# }
package Child;
use Mouse;
push @called, 'Child::DEMOLISH';
}
- sub DEMOLISHALL {
- my $self = shift;
- push @called, 'Child::DEMOLISHALL';
- $self->SUPER::DEMOLISHALL(@_);
- }
+# sub DEMOLISHALL {
+# my $self = shift;
+# push @called, 'Child::DEMOLISHALL';
+# $self->SUPER::DEMOLISHALL(@_);
+# }
+};
+
+is_deeply([splice @called], [], "no DEMOLISH calls yet");
+
+do {
+ my $object = Class->new;
+
+ is_deeply([splice @called], [], "no DEMOLISH calls yet");
};
+is_deeply([splice @called], ['Class::DEMOLISH']);
+
+do {
+ my $child = Child->new;
+ is_deeply([splice @called], [], "no DEMOLISH calls yet");
+
+};
+
+is_deeply([splice @called], ['Child::DEMOLISH', 'Class::DEMOLISH']);
+
+Class->meta->make_immutable();
+Child->meta->make_immutable();
+
is_deeply([splice @called], [], "no DEMOLISH calls yet");
do {
is_deeply([splice @called], [], "no DEMOLISH calls yet");
};
-is_deeply([splice @called], ['Class::DEMOLISHALL', 'Class::DEMOLISH']);
+is_deeply([splice @called], ['Class::DEMOLISH'], 'after make_immutable');
do {
my $child = Child->new;
};
-is_deeply([splice @called], ['Child::DEMOLISHALL', 'Class::DEMOLISHALL', 'Child::DEMOLISH', 'Class::DEMOLISH']);
+is_deeply([splice @called], ['Child::DEMOLISH', 'Class::DEMOLISH'], 'after make_immutable');
+++ /dev/null
-#!/usr/bin/env perl
-use strict;
-use warnings;
-use Test::More tests => 5;
-
-my @called;
-
-do {
- package Class;
- use Mouse;
-
- sub DEMOLISH {
- push @called, 'Class::DEMOLISH';
- }
-
- sub DEMOLISHALL {
- my $self = shift;
- push @called, 'Class::DEMOLISHALL';
- $self->SUPER::DEMOLISHALL(@_);
- }
-
- package Child;
- use Mouse;
- extends 'Class';
-
- sub DEMOLISH {
- push @called, 'Child::DEMOLISH';
- }
-
- sub DEMOLISHALL {
- my $self = shift;
- push @called, 'Child::DEMOLISHALL';
- $self->SUPER::DEMOLISHALL(@_);
- }
-};
-
-is_deeply([splice @called], [], "no DEMOLISH calls yet");
-
-do {
- my $object = Class->new;
-
- is_deeply([splice @called], [], "no DEMOLISH calls yet");
-};
-
-is_deeply([splice @called], ['Class::DEMOLISHALL', 'Class::DEMOLISH']);
-
-do {
- my $child = Child->new;
- is_deeply([splice @called], [], "no DEMOLISH calls yet");
-
-};
-
-is_deeply([splice @called], ['Child::DEMOLISHALL', 'Class::DEMOLISHALL', 'Child::DEMOLISH', 'Class::DEMOLISH']);
-
+++ /dev/null
-## 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;