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