xref: /openbsd-src/gnu/usr.bin/perl/ext/XS-APItest/t/magic.t (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1use strict;
2use warnings;
3use Test::More;
4
5use XS::APItest;
6
7my $sv = bless {}, 'Moo';
8my $foo = 'affe';
9my $bar = 'tiger';
10
11ok !mg_find_foo($sv), 'no foo magic yet';
12ok !mg_find_bar($sv), 'no bar magic yet';
13
14sv_magic_foo($sv, $foo);
15is mg_find_foo($sv), $foo, 'foo magic attached';
16ok !mg_find_bar($sv), '... but still no bar magic';
17
18sv_magic_bar($sv, $bar);
19is mg_find_foo($sv), $foo, 'foo magic still attached';
20is mg_find_bar($sv), $bar, '... and bar magic is there too';
21
22sv_unmagic_foo($sv);
23ok !mg_find_foo($sv), 'foo magic removed';
24is mg_find_bar($sv), $bar, '... but bar magic is still there';
25
26sv_unmagic_bar($sv);
27ok !mg_find_foo($sv), 'foo magic still removed';
28ok !mg_find_bar($sv), '... and bar magic is removed too';
29
30is(test_get_vtbl(), 0, 'get_vtbl(-1) returns NULL');
31
32done_testing;
33