From: Gisle Aas Date: Wed, 8 Oct 2003 13:35:28 +0000 (-0700) Subject: Re: Simple @INC hook core dump [PATCH] X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3a5db825226ec557f5580ca4aaeceda282d3af90;p=p5sagit%2Fp5-mst-13.2.git Re: Simple @INC hook core dump [PATCH] Message-Id: p4raw-id: //depot/perl@21426 --- diff --git a/t/op/inccode.t b/t/op/inccode.t index 1a3d3cf..8ce41ab 100644 --- a/t/op/inccode.t +++ b/t/op/inccode.t @@ -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;