[TEST PATCH] %^H can now propagate into eval
[p5sagit/p5-mst-13.2.git] / t / comp / require.t
index 5d861d2..1e2c9fb 100755 (executable)
@@ -11,9 +11,8 @@ $i = 1;
 
 my $Is_EBCDIC = (ord('A') == 193) ? 1 : 0;
 my $Is_UTF8   = (${^OPEN} || "") =~ /:utf8/;
-my $total_tests = 43;
-my $ebcdic_utf8_skips = 3;
-if ($Is_EBCDIC || $Is_UTF8) { $total_tests -= $ebcdic_utf8_skips; }
+my $total_tests = 45;
+if ($Is_EBCDIC || $Is_UTF8) { $total_tests = 42; }
 print "1..$total_tests\n";
 
 sub do_require {
@@ -76,7 +75,7 @@ print "ok ",$i++,"\n";
 # check inaccurate fp
 $ver = 10.2;
 eval { require $ver; };
-print "# $@\nnot " unless $@ =~ /^Perl v10\.200 required/;
+print "# $@\nnot " unless $@ =~ /^Perl v10\.200.0 required/;
 print "ok ",$i++,"\n";
 
 $ver = 10.000_02;
@@ -123,6 +122,8 @@ for my $expected_compile (1,0) {
     print "ok ",$i++,"\n";
     print "not " unless -e $flag_file xor $expected_compile;
     print "ok ",$i++,"\n";
+    print "not " unless exists $INC{'bleah.pm'};
+    print "ok ",$i++,"\n";
 }
 
 # compile-time failure in require
@@ -132,6 +133,9 @@ do_require "1)\n";
 print "# $@\nnot " unless $@ =~ /(syntax|parse) error/mi;
 print "ok ",$i++,"\n";
 
+# previous failure cached in %INC
+print "not " unless exists $INC{'bleah.pm'};
+print "ok ",$i++,"\n";
 write_file($flag_file, 1);
 write_file('bleah.pm', "unlink '$flag_file'; 1");
 print "# $@\nnot " if eval { require 'bleah.pm' };
@@ -140,19 +144,13 @@ print "# $@\nnot " unless $@ =~ /Compilation failed/i;
 print "ok ",$i++,"\n";
 print "not " unless -e $flag_file;
 print "ok ",$i++,"\n";
-# [perl #31924]
-eval { $INC{'bleah.pm'} = 'bleah.pm' };
-print "# $@\nnot " if $@;
-print "ok ",$i++,"\n";
-print "not " unless $INC{'bleah.pm'} eq 'bleah.pm';
+print "not " unless exists $INC{'bleah.pm'};
 print "ok ",$i++,"\n";
 
 # successful require
 do_require "1";
 print "# $@\nnot " if $@;
 print "ok ",$i++,"\n";
-print "not " unless $INC{'bleah.pm'} eq 'bleah.pm';
-print "ok ",$i++,"\n";
 
 # do FILE shouldn't see any outside lexicals
 my $x = "ok $i\n";
@@ -181,6 +179,20 @@ $foo = eval  {require bleah}; delete $INC{"bleah.pm"}; ++$::i;
 @foo = eval  {require bleah}; delete $INC{"bleah.pm"}; ++$::i;
        eval  {require bleah};
 
+# Test for fix of RT #24404 : "require $scalar" may load a directory
+my $r = "threads";
+eval { require $r };
+$i++;
+if($@ =~ /Directory .*threads not allowed in require/) {
+    print "ok $i\n";
+} else {
+    print "not ok $i\n";
+}
+
+############################
+#### Add new tests here ####
+############################
+
 # UTF-encoded things - skipped on EBCDIC machines and on UTF-8 input
 
 if ($Is_EBCDIC || $Is_UTF8) { exit; }