xref: /openbsd/gnu/usr.bin/perl/t/op/magic-27839.t (revision 09467b48)
1#!./perl -w
2
3BEGIN {
4    $SIG{__WARN__} = sub { die "Dying on warning: ", @_ };
5    chdir 't' if -d 't';
6    require './test.pl';
7    skip_all_if_miniperl(
8	"no dynamic loading on miniperl, no Tie::Hash::NamedCapture"
9    );
10}
11
12plan(tests => 2);
13
14use strict;
15
16# Test for bug [perl #27839]
17{
18    my $x;
19    sub f {
20	"abc" =~ /(.)./;
21	$x = "@+";
22	return @+;
23    };
24    "pqrstuvwxyz" =~ /..(....)../; # prime @+ etc in this scope
25    my @y = f();
26    is $x, "@y", "return a magic array ($x) vs (@y)";
27
28    sub f2 {
29	"abc" =~ /(?<foo>.)./;
30	my @h =  %+;
31	$x = "@h";
32	return %+;
33    };
34    @y = f();
35    is $x, "@y", "return a magic hash ($x) vs (@y)";
36}
37
38