Commit | Line | Data |
a469423b |
1 | use strict; |
2 | use Test::More; |
3 | |
4 | BEGIN |
5 | { |
6 | if ($] < 5.009_005) { |
7 | plan(skip_all => "This test is only applicable for perl >= 5.9.5"); |
8 | } elsif ( ! eval { require MRO::Compat } || $@) { |
9 | plan(skip_all => "MRO::Compat not available"); |
10 | } elsif ( ! eval { require Class::C3 } || $@) { |
11 | plan(skip_all => "Class::C3 not available"); |
12 | } else { |
13 | plan(tests => 2); |
14 | } |
15 | } |
16 | |
17 | { |
18 | # If the bug still exists, I should get a few warnings |
19 | my @warnings; |
20 | local $SIG{__WARN__} = sub { |
21 | push @warnings, $_[0]; |
22 | }; |
23 | |
24 | # Remove symbols from respective tables, and |
25 | # remove from INC, so we force re-evaluation |
e861fe16 |
26 | foreach my $class (qw(Class::C3 MRO::Compat)) { |
a469423b |
27 | my $file = $class; |
28 | $file =~ s/::/\//g; |
29 | $file .= '.pm'; |
30 | |
31 | delete $INC{$file}; |
32 | |
33 | { # Don't do this at home, kids! |
34 | no strict 'refs'; |
35 | foreach my $key (keys %{ "${class}::" }) { |
36 | delete ${"${class}::"}{$key}; |
37 | } |
38 | } |
39 | } |
40 | |
41 | eval { |
42 | require MRO::Compat; |
43 | require Class::C3; |
44 | }; |
45 | ok( ! $@, "Class::C3 loaded ok"); |
46 | if (! ok( ! @warnings, "loading Class::C3 did not generate warnings" )) { |
47 | diag("Generated warnings are (expecting 'subroutine redefined...')"); |
48 | diag(" $_") for @warnings; |
49 | } |
50 | } |