summaryrefslogtreecommitdiff
path: root/t/base
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2017-06-29 11:31:14 +0200
committerYves Orton <demerphq@gmail.com>2017-06-29 13:17:19 +0200
commit4f08ed80a1ad3deb06ce5d8d20cc2d176dcbced0 (patch)
treec35357d94167e1cb3d4713dda0a18f804bf6afe1 /t/base
parentb2ac59d1d0fda74d6612701d8316fe8dfb6a1b90 (diff)
downloadperl-4f08ed80a1ad3deb06ce5d8d20cc2d176dcbced0.tar.gz
Parse caret vars with subscripts the same as normal vars inside of ${..} escaping
This behavior is discussed in perl #131664, which complains that "${^CAPTURE}[0]" does not work as expected. Abigail explains the behavior is by design and Eirik Berg Hanssen expands on that explanation pointing out that what /should/ work, "${^CAPTURE[0]}" does not, which Sawyer then ruled was a bug. So this patch makes "${^CAPTURE[0]}" (and "${^CAPTURE [0]}" [hi abigial]) work the same as they would if the var was called @foo.
Diffstat (limited to 't/base')
-rw-r--r--t/base/lex.t28
1 files changed, 27 insertions, 1 deletions
diff --git a/t/base/lex.t b/t/base/lex.t
index e154aca801..89d46dfce0 100644
--- a/t/base/lex.t
+++ b/t/base/lex.t
@@ -1,6 +1,6 @@
#!./perl
-print "1..109\n";
+print "1..116\n";
$x = 'x';
@@ -154,6 +154,32 @@ my $test = 31;
print "not " unless index ($@, 'Can\'t use global $^XYZ in "my"') > -1;
print "ok $test\n"; $test++;
# print "($@)\n" if $@;
+#
+ ${^TEST}= "splat";
+ @{^TEST}= ("foo", "bar");
+ %{^TEST}= ("foo" => "FOO", "bar" => "BAR" );
+
+ print "not " if "${^TEST}" ne "splat";
+ print "ok $test\n"; $test++;
+
+ print "not " if "${^TEST}[0]" ne "splat[0]";
+ print "ok $test\n"; $test++;
+
+ print "not " if "${^TEST[0]}" ne "foo";
+ print "ok $test\n"; $test++;
+
+ print "not " if "${ ^TEST [1] }" ne "bar";
+ print "ok $test\n"; $test++;
+
+ print "not " if "${^TEST}{foo}" ne "splat{foo}";
+ print "ok $test\n"; $test++;
+
+ print "not " if "${^TEST{foo}}" ne "FOO";
+ print "ok $test\n"; $test++;
+
+ print "not " if "${ ^TEST {bar} }" ne "BAR";
+ print "ok $test\n"; $test++;
+
# Now let's make sure that caret variables are all forced into the main package.
package Someother;