Lots of consting
[p5sagit/p5-mst-13.2.git] / t / op / inccode.t
index 1a3d3cf..8ce41ab 100644 (file)
@@ -10,7 +10,7 @@ BEGIN {
 use File::Spec;
 
 require "test.pl";
-plan(tests => 44);
+plan(tests => 45);
 
 my @tempfiles = ();
 
@@ -19,7 +19,8 @@ sub get_temp_fh {
     1 while -e ++$f;
     push @tempfiles, $f;
     open my $fh, ">$f" or die "Can't create $f: $!";
-    print $fh "package ".substr($_[0],0,-3)."; 1;";
+    print $fh "package ".substr($_[0],0,-3).";\n1;\n";
+    print $fh $_[1] if @_ > 1;
     close $fh or die "Couldn't close: $!";
     open $fh, $f or die "Can't open $f: $!";
     return $fh;
@@ -173,6 +174,22 @@ is( $INC{'Toto.pm'}, 'xyz',           '  val Toto.pm is correct in %INC' );
 
 pop @INC;
 
+push @INC, sub {
+    my ($self, $filename) = @_;
+    if ($filename eq 'abc.pl') {
+       return get_temp_fh($filename, qq(return "abc";\n));
+    }
+    else {
+       return undef;
+    }
+};
+
+$ret = "";
+$ret ||= do 'abc.pl';
+is( $ret, 'abc', 'do "abc.pl" sees return value' );
+
+pop @INC;
+
 my $filename = $^O eq 'MacOS' ? ':Foo:Foo.pm' : './Foo.pm';
 {
     local @INC;