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