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