Commit | Line | Data |
---|---|---|
0eff2c16 | 1 | use strict; |
2 | use warnings; | |
3 | ||
86a4d873 | 4 | use Test::More; |
0eff2c16 | 5 | |
efd3d14c | 6 | use Class::MOP; |
0eff2c16 | 7 | |
8 | =pod | |
9 | ||
10 | This tests a bug which is fixed in 0.22 by | |
11 | localizing all the $@'s around any evals. | |
12 | This a real pain to track down. | |
13 | ||
14 | Moral 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; | |
49ca2e97 | 25 | |
0eff2c16 | 26 | sub new { |
27 | my ($class) = @_; | |
28 | return bless {} => $class; | |
49ca2e97 | 29 | } |
30 | ||
0eff2c16 | 31 | sub employees { |
32 | die "This didnt work"; | |
33 | } | |
49ca2e97 | 34 | |
0eff2c16 | 35 | sub DESTROY { |
49ca2e97 | 36 | my $self = shift; |
37 | foreach | |
38 | my $method ( $self->meta->find_all_methods_by_name('DEMOLISH') ) { | |
39 | $method->{code}->($self); | |
40 | } | |
0eff2c16 | 41 | } |
42 | } | |
43 | ||
49ca2e97 | 44 | eval { |
45 | my $c = Company->new(); | |
0eff2c16 | 46 | $c->employees(); |
49ca2e97 | 47 | }; |
48 | ok( $@, '... we die correctly with bad args' ); | |
86a4d873 | 49 | |
50 | done_testing; |