rmagical.t revision 1.1.1.1
1#!perl 2 3# Consider two kinds of magic : 4# A : PERL_MAGIC_uvar, with get (but no set) magic 5# B : PERL_MAGIC_ext, with a zero vtbl 6# If those magic are attached on a sv in such a way that the MAGIC chain 7# looks like sv -> B -> A -> NULL (i.e. we first apply A and then B), then 8# mg_magical won't turn SvRMAGICAL on. However, if the chain is in the 9# opposite order (sv -> A -> B -> NULL), SvRMAGICAL used to be turned on. 10 11use strict; 12use warnings; 13 14use Test::More tests => 3; 15 16use_ok('XS::APItest'); 17 18my (%h1, %h2); 19my @f; 20 21rmagical_cast(\%h1, 0); # A 22rmagical_cast(\%h1, 1); # B 23@f = rmagical_flags(\%h1); 24ok(!$f[2], "For sv -> B -> A -> NULL, SvRMAGICAL(sv) is false"); 25 26rmagical_cast(\%h2, 1); # B 27rmagical_cast(\%h2, 0); # A 28@f = rmagical_flags(\%h2); 29ok(!$f[2], "For sv -> A -> B -> NULL, SvRMAGICAL(sv) is false"); 30