This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Pure Perl lvalue subs can't return temps, even if they are magical. This holds back...
[perl5.git] / ext / XS-APItest / t / temp_lv_sub.t
CommitLineData
e2fe06dd
EB
1#!perl -w
2
3BEGIN {
4 push @INC, "::lib:$MacPerl::Architecture:" if $^O eq 'MacOS';
5 require Config; import Config;
6 if ($Config{'extensions'} !~ /\bXS\/APItest\b/) {
7 # Look, I'm using this fully-qualified variable more than once!
8 my $arch = $MacPerl::Architecture;
9 print "1..0 # Skip: XS::APItest was not built\n";
10 exit 0;
11 }
12}
13
14use strict;
15use utf8;
16use Test::More tests => 5;
17
18BEGIN {use_ok('XS::APItest')};
19
20sub make_temp_mg_lv :lvalue { XS::APItest::TempLv::make_temp_mg_lv($_[0]); }
21
22{
23 my $x = "[]";
24 eval { XS::APItest::TempLv::make_temp_mg_lv($x) = "a"; };
25 is($@, '', 'temp mg lv from xs exception check');
26 is($x, '[a]', 'temp mg lv from xs success');
27}
28
29{
30 local $TODO = "PP lvalue sub can't return magical temp";
31 my $x = "{}";
32 eval { make_temp_mg_lv($x) = "b"; };
33 is($@, '', 'temp mg lv from pp exception check');
34 is($x, '{b}', 'temp mg lv from pp success');
35}
36
371;