Non-VMS-fixed and Win32-skipped version of
[p5sagit/p5-mst-13.2.git] / t / op / inccode.t
index 71beb3e..bd66628 100644 (file)
@@ -1,14 +1,16 @@
-#!./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 = ();
 
@@ -132,3 +134,21 @@ is( ref $INC{'Quux2.pm'}, 'FooLoader',
 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;