summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/ext/XS-APItest/t/lvalue.t
blob: d348ea6bbc6538f7f4308e335abefed52816747f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Miscellaneous tests for XS lvalue functions

use warnings;
use strict;

use Test::More tests => 4;

use XS::APItest 'lv_temp_object';


{
    my $w;
    local $SIG{__WARN__} = sub { $w = shift };

    # [perl #31946]
    lv_temp_object() = 75;
    like $w, qr/Useless assignment to a temporary at/,
	'warning when assigning to temp returned from XS lv sub';
    undef $w;
    (lv_temp_object()) = 75;
    like $w, qr/Useless assignment to a temporary at/,
	'warning when list-assigning to temp returned from XS lv sub';

    $w = undef;
    {
	package XS::APItest::TempObj;
	use overload '.=' => sub { $::assigned = $_[1] };
    }
    lv_temp_object() .= 63;
    is $::assigned, 63, 'overloaded .= on temp obj returned from lv sub';
    is $w, undef, 'no warning from overloaded .= on temp obj';
}