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