stop using excludes within moose, since it's no longer necessary
[gitmo/Moose.git] / t / cmop / random_eval_bug.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5
6 use Class::MOP;
7
8 =pod
9
10 This tests a bug which is fixed in 0.22 by localizing all the $@'s around any
11 evals.
12
13 This a real pain to track down.
14
15 Moral of the story:
16
17   ALWAYS localize your globals :)
18
19 =cut
20
21 {
22     package Company;
23     use strict;
24     use warnings;
25     use metaclass;
26
27     sub new {
28         my ($class) = @_;
29         return bless {} => $class;
30     }
31
32     sub employees {
33         die "This didnt work";
34     }
35
36     sub DESTROY {
37         my $self = shift;
38         foreach
39             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' );
50
51 done_testing;