I think that "merge Perl_sv_2[inpu]v" and "reduce duplication in
[p5sagit/p5-mst-13.2.git] / t / op / local.t
index ca6f63d..a186a70 100755 (executable)
@@ -4,7 +4,13 @@ BEGIN {
     chdir 't' if -d 't';
     require './test.pl';
 }
-plan tests => 85;
+plan tests => 87;
+
+my $list_assignment_supported = 1;
+
+#mg.c says list assignment not supported on VMS, EPOC, and SYMBIAN.
+$list_assignment_supported = 0 if ($^O eq 'VMS');
+
 
 sub foo {
     local($a, $b) = @_;
@@ -253,7 +259,10 @@ is($ENV{_Z_}, 'c');
 # local() should preserve the existenceness of %ENV elements
 ok(! exists $ENV{_A_});
 ok(! exists $ENV{_B_});
-{
+
+SKIP: {
+    skip("Can't make list assignment to \%ENV on this system")
+       unless $list_assignment_supported;
     my $d = join("\n", map { "$_=>$ENV{$_}" } sort keys %ENV);
     local %ENV = %ENV;
     is(join("\n", map { "$_=>$ENV{$_}" } sort keys %ENV), $d);
@@ -320,3 +329,16 @@ like($@, qr/Modification of a read-only value attempted/);
 # The s/// adds 'g' magic to $_, but it should remain non-readonly
 eval { for("a") { for $x (1,2) { local $_="b"; s/(.*)/+$1/ } } };
 is($@, "");
+
+# Special local() behavior for $[
+# (see RT #38207 - Useless localization of constant ($[) in getopts.pl}
+{
+    local $[ = 1;
+    local $TODO = "local() not currently working correctly with \$[";
+    ok(1 == $[);
+    undef $TODO;
+    f();
+}
+
+sub f { ok(0 == $[); }
+