Oops, today is Wednesday
[gitmo/Class-MOP.git] / t / 300_random_eval_bug.t
CommitLineData
0eff2c16 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
efd3d14c 6use Test::More tests => 1;
0eff2c16 7
efd3d14c 8use Class::MOP;
0eff2c16 9
10=pod
11
12This tests a bug which is fixed in 0.22 by
13localizing all the $@'s around any evals.
14This a real pain to track down.
15
16Moral 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
45eval {
46 my $c = Company->new();
47 $c->employees();
48};
49ok($@, '... we die correctly with bad args');