summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/ext/XS-APItest/t/rmagical.t
blob: 8e1a0a01d368bded457a2c6807b80ff6c38389c1 (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
#!perl

# Consider two kinds of magic :
# A : PERL_MAGIC_uvar, with get (but no set) magic
# B : PERL_MAGIC_ext, with a zero vtbl
# If those magic are attached on a sv in such a way that the MAGIC chain
# looks like sv -> B -> A -> NULL (i.e. we first apply A and then B), then
# mg_magical won't turn SvRMAGICAL on. However, if the chain is in the
# opposite order (sv -> A -> B -> NULL), SvRMAGICAL used to be turned on.

use strict;
use warnings;

use Test::More tests => 3;

use_ok('XS::APItest');

my (%h1, %h2);
my @f;

rmagical_cast(\%h1, 0); # A
rmagical_cast(\%h1, 1); # B
@f = rmagical_flags(\%h1);
ok(!$f[2], "For sv -> B -> A -> NULL, SvRMAGICAL(sv) is false");

rmagical_cast(\%h2, 1); # B
rmagical_cast(\%h2, 0); # A
@f = rmagical_flags(\%h2);
ok(!$f[2], "For sv -> A -> B -> NULL, SvRMAGICAL(sv) is false");