[TEST PATCH] %^H can now propagate into eval
[p5sagit/p5-mst-13.2.git] / t / comp / use.t
index 1099547..eec6fe0 100755 (executable)
@@ -2,12 +2,18 @@
 
 BEGIN {
     chdir 't' if -d 't';
-    unshift @INC, '../lib';
+    @INC = '../lib';
 }
 
-print "1..14\n";
+print "1..31\n";
 
 my $i = 1;
+eval "use 5.000";      # implicit semicolon
+if ($@) {
+    print STDERR $@,"\n";
+    print "not ";
+}
+print "ok ",$i++,"\n";
 
 eval "use 5.000;";
 if ($@) {
@@ -16,37 +22,54 @@ if ($@) {
 }
 print "ok ",$i++,"\n";
 
-eval sprintf "use %.5f;", $];
+eval "use 6.000;";
+unless ($@ =~ /Perl v6\.0\.0 required--this is only \Q$^V\E, stopped/) {
+    print "not ";
+}
+print "ok ",$i++,"\n";
+
+eval "no 6.000;";
 if ($@) {
     print STDERR $@,"\n";
     print "not ";
 }
 print "ok ",$i++,"\n";
 
+eval "no 5.000;";
+unless ($@ =~ /Perls since v5\.0\.0 too modern--this is \Q$^V\E, stopped/) {
+    print "not ";
+}
+print "ok ",$i++,"\n";
 
-eval sprintf "use %.5f;", $] - 0.000001;
+eval sprintf "use %.6f;", $];
 if ($@) {
     print STDERR $@,"\n";
     print "not ";
 }
 print "ok ",$i++,"\n";
 
-eval sprintf("use %.5f;", $] + 1);
-unless ($@) {
+
+eval sprintf "use %.6f;", $] - 0.000001;
+if ($@) {
+    print STDERR $@,"\n";
     print "not ";
 }
 print "ok ",$i++,"\n";
 
-eval sprintf "use %.5f;", $] + 0.00001;
+eval sprintf("use %.6f;", $] + 1);
 unless ($@) {
     print "not ";
 }
 print "ok ",$i++,"\n";
 
+eval sprintf "use %.6f;", $] + 0.00001;
+unless ($@) {
+    print "not ";
+}
+print "ok ",$i++,"\n";
 
 
-use lib; # I know that this module will be there.
-
+{ use lib }    # check that subparse saves pending tokens
 
 local $lib::VERSION = 1.0;
 
@@ -78,7 +101,7 @@ if ($@) {
 }
 print "ok ",$i++,"\n";
 
-print "not " unless $INC[0] eq "fred";
+print "not " unless ($INC[0] eq "fred" || ($^O eq 'MacOS' && $INC[0] eq ":fred:"));
 print "ok ",$i++,"\n";
 
 eval "use lib 1.0 qw(joe)";
@@ -88,7 +111,7 @@ if ($@) {
 }
 print "ok ",$i++,"\n";
 
-print "not " unless $INC[0] eq "joe";
+print "not " unless ($INC[0] eq "joe" || ($^O eq 'MacOS' && $INC[0] eq ":joe:"));
 print "ok ",$i++,"\n";
 
 eval "use lib 1.01 qw(freda)";
@@ -97,5 +120,85 @@ unless ($@) {
 }
 print "ok ",$i++,"\n";
 
-print "not " if $INC[0] eq "freda";
+print "not " if ($INC[0] eq "freda" || ($^O eq 'MacOS' && $INC[0] eq ":freda:"));
 print "ok ",$i++,"\n";
+
+{
+    local $lib::VERSION = 35.36;
+    eval "use lib v33.55";
+    print "not " if $@;
+    print "ok ",$i++,"\n";
+
+    eval "use lib v100.105";
+    unless ($@ =~ /lib version 100.105 \(v100\.105\.0\) required--this is only version 35.360 \(v35\.360\.0\)/) {
+       print "not ";
+    }
+    print "ok ",$i++,"\n";
+
+    eval "use lib 33.55";
+    print "not " if $@;
+    print "ok ",$i++,"\n";
+
+    eval "use lib 100.105";
+    unless ($@ =~ /lib version 100.105 \(v100\.105\.0\) required--this is only version 35.360 \(v35\.360\.0\)/) {
+       print "not ";
+    }
+    print "ok ",$i++,"\n";
+
+    local $lib::VERSION = '35.36';
+    eval "use lib v33.55";
+    print "not " if $@;
+    print "ok ",$i++,"\n";
+
+    eval "use lib v100.105";
+    unless ($@ =~ /lib version 100.105 \(v100\.105\.0\) required--this is only version 35.360 \(v35\.360\.0\)/) {
+       print "not ";
+    }
+    print "ok ",$i++,"\n";
+
+    eval "use lib 33.55";
+    print "not " if $@;
+    print "ok ",$i++,"\n";
+
+    eval "use lib 100.105";
+    unless ($@ =~ /lib version 100.105 \(v100\.105\.0\) required--this is only version 35.360 \(v35\.360\.0\)/) {
+       print "not ";
+    }
+    print "ok ",$i++,"\n";
+
+    local $lib::VERSION = v35.36;
+    eval "use lib v33.55";
+    print "not " if $@;
+    print "ok ",$i++,"\n";
+
+    eval "use lib v100.105";
+    unless ($@ =~ /lib version 100.105 \(v100\.105\.0\) required--this is only version 35.036000 \(v35\.36\.0\)/) {
+       print "not ";
+    }
+    print "ok ",$i++,"\n";
+
+    eval "use lib 33.55";
+    print "not " if $@;
+    print "ok ",$i++,"\n";
+
+    eval "use lib 100.105";
+    unless ($@ =~ /lib version 100.105 \(v100\.105\.0\) required--this is only version 35.036000 \(v35\.36\.0\)/) {
+       print "not ";
+    }
+    print "ok ",$i++,"\n";
+}
+
+
+{
+    # Regression test for patch 14937: 
+    #   Check that a .pm file with no package or VERSION doesn't core.
+    open F, ">xxx.pm" or die "Cannot open xxx.pm: $!\n";
+    print F "1;\n";
+    close F;
+    eval "use lib '.'; use xxx 3;";
+    unless ($@ =~ /^xxx defines neither package nor VERSION--version check failed at/) {
+       print "not ";
+    }
+    print "ok ",$i++,"\n";
+    unlink 'xxx.pm';
+}