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