This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Skip over state declarations at run time
[perl5.git] / t / op / magic-27839.t
CommitLineData
c4a9334d
NC
1#!./perl -w
2
3BEGIN {
4 $SIG{__WARN__} = sub { die "Dying on warning: ", @_ };
b5efbd1f 5 chdir 't' if -d 't';
c4a9334d
NC
6 require './test.pl';
7 skip_all_if_miniperl("no dynamic loading on miniperl, no Tie::Hash::NamedCapture");
8 plan(tests => 2);
9}
10
11use 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