Debian Codegraph @

ext/XS-APItest/t/lvalue.t

raw
1 # Miscellaneous tests for XS lvalue functions
2
3 use warnings;
4 use strict;
5
6 use Test::More tests => 4;
7
8 use XS::APItest 'lv_temp_object';
9
10
11 {
12 my $w;
13 local $SIG{__WARN__} = sub { $w = shift };
14
15 # [perl #31946]
16 lv_temp_object() = 75;
17 like $w, qr/Useless assignment to a temporary at/,
18 'warning when assigning to temp returned from XS lv sub';
19 undef $w;
20 (lv_temp_object()) = 75;
21 like $w, qr/Useless assignment to a temporary at/,
22 'warning when list-assigning to temp returned from XS lv sub';
23
24 $w = undef;
25 {
26 package XS::APItest::TempObj;
27 use overload '.=' => sub { $::assigned = $_[1] };
28 }
29 lv_temp_object() .= 63;
30 is $::assigned, 63, 'overloaded .= on temp obj returned from lv sub';
31 is $w, undef, 'no warning from overloaded .= on temp obj';
32 }