7 my $sv = bless {}, 'Moo';
11 ok !mg_find_foo($sv), 'no foo magic yet';
12 ok !mg_find_bar($sv), 'no bar magic yet';
14 sv_magic_foo($sv, $foo);
15 is mg_find_foo($sv), $foo, 'foo magic attached';
16 ok !mg_find_bar($sv), '... but still no bar magic';
18 sv_magic_bar($sv, $bar);
19 is mg_find_foo($sv), $foo, 'foo magic still attached';
20 is mg_find_bar($sv), $bar, '... and bar magic is there too';
23 ok !mg_find_foo($sv), 'foo magic removed';
24 is mg_find_bar($sv), $bar, '... but bar magic is still there';
27 ok !mg_find_foo($sv), 'foo magic still removed';
28 ok !mg_find_bar($sv), '... and bar magic is removed too';
30 is(test_get_vtbl(), 0, 'get_vtbl(-1) returns NULL');
32 use Scalar::Util 'weaken';
33 eval { sv_magic(\!0, $foo) };
34 is $@, "", 'PERL_MAGIC_ext is permitted on read-only things';
36 # assigning to an array/hash with only set magic should call that magic
41 sv_magic_myset(\@a, $i);
42 sv_magic_myset(\%h, $i);
46 is($i, 2, "array with set magic");
50 is($i, 0, "array () with set magic");
53 local $TODO = "HVs don't call set magic - not sure if should";
57 is($i, 4, "hash with set magic");
62 is($i, 0, "hash () with set magic");