From: Daisuke Maki Date: Mon, 9 Jun 2008 08:34:33 +0000 (+0000) Subject: a test that checks no warnings are generated when MRO::Compat is loaded before Class::C3 X-Git-Tag: 0.21~12 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a469423b9004294f7c9fc7db1e36372b23f8b5c8;p=gitmo%2FClass-C3.git a test that checks no warnings are generated when MRO::Compat is loaded before Class::C3 --- diff --git a/t/37_mro_warn.t b/t/37_mro_warn.t new file mode 100644 index 0000000..f6a8966 --- /dev/null +++ b/t/37_mro_warn.t @@ -0,0 +1,50 @@ +use strict; +use Test::More; + +BEGIN +{ + if ($] < 5.009_005) { + plan(skip_all => "This test is only applicable for perl >= 5.9.5"); + } elsif ( ! eval { require MRO::Compat } || $@) { + plan(skip_all => "MRO::Compat not available"); + } elsif ( ! eval { require Class::C3 } || $@) { + plan(skip_all => "Class::C3 not available"); + } else { + plan(tests => 2); + } +} + +{ + # If the bug still exists, I should get a few warnings + my @warnings; + local $SIG{__WARN__} = sub { + push @warnings, $_[0]; + }; + + # Remove symbols from respective tables, and + # remove from INC, so we force re-evaluation + foreach my $class qw(Class::C3 MRO::Compat) { + my $file = $class; + $file =~ s/::/\//g; + $file .= '.pm'; + + delete $INC{$file}; + + { # Don't do this at home, kids! + no strict 'refs'; + foreach my $key (keys %{ "${class}::" }) { + delete ${"${class}::"}{$key}; + } + } + } + + eval { + require MRO::Compat; + require Class::C3; + }; + ok( ! $@, "Class::C3 loaded ok"); + if (! ok( ! @warnings, "loading Class::C3 did not generate warnings" )) { + diag("Generated warnings are (expecting 'subroutine redefined...')"); + diag(" $_") for @warnings; + } +}