Fast enabling of strictures when version 5.11.0 is required
[p5sagit/p5-mst-13.2.git] / t / comp / use.t
index a43bbeb..8546123 100755 (executable)
@@ -6,7 +6,7 @@ BEGIN {
     $INC{"feature.pm"} = 1; # so we don't attempt to load feature.pm
 }
 
-print "1..63\n";
+print "1..68\n";
 
 # Can't require test.pl, as we're testing the use/require mechanism here.
 
@@ -89,6 +89,9 @@ like ($@, qr/Perl v5\.900\.0 required \(did you mean v5\.9\.0\?\)--this is only
 eval "use 5.10;";
 like ($@, qr/Perl v5\.100\.0 required \(did you mean v5\.10\.0\?\)--this is only \Q$^V\E, stopped/);
 
+eval "use 5.11;";
+like ($@, qr/Perl v5\.110\.0 required \(did you mean v5\.11\.0\?\)--this is only \Q$^V\E, stopped/);
+
 eval sprintf "use %.6f;", $];
 is ($@, '');
 
@@ -102,6 +105,19 @@ like ($@, qr/Perl v6.\d+.\d+ required--this is only \Q$^V\E, stopped/);
 eval sprintf "use %.6f;", $] + 0.00001;
 like ($@, qr/Perl v5.\d+.\d+ required--this is only \Q$^V\E, stopped/);
 
+# check that "use 5.11.0" (and higher) loads strictures
+eval 'use 5.11.0; ${"foo"} = "bar";';
+like ($@, qr/Can't use string \("foo"\) as a SCALAR ref while "strict refs" in use/);
+# but that they can be disabled
+eval 'use 5.11.0; no strict "refs"; ${"foo"} = "bar";';
+is ($@, "");
+# and they are properly scoped
+eval '{use 5.11.0;} ${"foo"} = "bar";';
+is ($@, "");
+# and this doesn't happen with require
+eval 'require 5.11.0; ${"foo"} = "bar";';
+is ($@, "");
+
 { use lib }    # check that subparse saves pending tokens
 
 local $lib::VERSION = 1.0;
@@ -190,12 +206,12 @@ if ($^O eq 'MacOS') {
 {
     # 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";
+    open F, ">xxx$$.pm" or die "Cannot open xxx$$.pm: $!\n";
     print F "1;\n";
     close F;
-    eval "use lib '.'; use xxx 3;";
-    like ($@, qr/^xxx defines neither package nor VERSION--version check failed at/);
-    unlink 'xxx.pm';
+    eval "use lib '.'; use xxx$$ 3;";
+    like ($@, qr/^xxx$$ defines neither package nor VERSION--version check failed at/);
+    unlink "xxx$$.pm";
 }
 
 my @ver = split /\./, sprintf "%vd", $^V;