Subject: | Class::Inspector->loaded returns true when a class has syntax errors |
Class::Inspector->loaded detects packages with syntax errors as being
loaded. Test case:
# in file Class/Inspector/_ErrorPackage.pm
package Class::Inspector::_ErrorPackage;
my $blah '';
#syntax error
1;
# file t/03_loaded.t
#!/usr/bin/perl
use Test::More tests => 2;
use Class::Inspector;
use lib 't/lib';
my $class = 'Class::Inspector::_ErrorPackage';
ok( ! Class::Inspector->loaded($class), 'ErrorPackage not loaded yet' );
{
# swallow warnings
local $SIG{__WARN__} = sub {
my $warn = shift;
warn $warn unless ($warn =~ /String found where operator expected/ or
$warn =~ /Missing operator before/);
};
eval "require $class";
}
ok( ! Class::Inspector->loaded($class), 'ErrorPackage not loaded after
error' );
#fails