This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
re-implement OPpASSIGN_COMMON mechanism
[perl5.git] / t / op / magic-27839.t
1 #!./perl -w
2
3 BEGIN {
4     $SIG{__WARN__} = sub { die "Dying on warning: ", @_ };
5     chdir 't' if -d 't';
6     require './test.pl';
7     skip_all_if_miniperl("no dynamic loading on miniperl, no Tie::Hash::NamedCapture");
8     plan(tests => 2);
9 }
10
11 use strict;
12
13 # Test for bug [perl #27839]
14 {
15     my $x;
16     sub f {
17         "abc" =~ /(.)./;
18         $x = "@+";
19         return @+;
20     };
21     "pqrstuvwxyz" =~ /..(....)../; # prime @+ etc in this scope
22     my @y = f();
23     is $x, "@y", "return a magic array ($x) vs (@y)";
24
25     sub f2 {
26         "abc" =~ /(?<foo>.)./;
27         my @h =  %+;
28         $x = "@h";
29         return %+;
30     };
31     @y = f();
32     is $x, "@y", "return a magic hash ($x) vs (@y)";
33 }
34