-#!./perl -wT
+#!./perl -w
# Tests for the coderef-in-@INC feature
BEGIN {
chdir 't' if -d 't';
- @INC = '../lib';
+ @INC = qw(. ../lib);
}
use File::Spec;
-use Test::More tests => 39;
+
+require "test.pl";
+plan(tests => 43);
my @tempfiles = ();
is( $INC{'Quux2.pm'}, $sref, ' key is correct in %INC' );
pop @INC;
+
+push @INC, sub {
+ my ($self, $filename) = @_;
+ if (substr($filename,0,4) eq 'Toto') {
+ $INC{$filename} = 'xyz';
+ return get_temp_fh($filename);
+ }
+ else {
+ return undef;
+ }
+};
+
+ok( eval { require Toto; 1 }, 'require() magic via anonymous code ref' );
+ok( exists $INC{'Toto.pm'}, ' %INC sees it' );
+ok( ! ref $INC{'Toto.pm'}, q/ key isn't a ref in %INC/ );
+is( $INC{'Toto.pm'}, 'xyz', ' key is correct in %INC' );
+
+pop @INC;