1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
use strict;
use warnings;
use Test::More;
use Class::MOP;
=pod
This tests a bug which is fixed in 0.22 by
localizing all the $@'s around any evals.
This a real pain to track down.
Moral of the story:
ALWAYS localize your globals :)
=cut
{
package Company;
use strict;
use warnings;
use metaclass;
sub new {
my ($class) = @_;
return bless {} => $class;
}
sub employees {
die "This didnt work";
}
sub DESTROY {
my $self = shift;
foreach
my $method ( $self->meta->find_all_methods_by_name('DEMOLISH') ) {
$method->{code}->($self);
}
}
}
eval {
my $c = Company->new();
$c->employees();
};
ok( $@, '... we die correctly with bad args' );
done_testing;
|