This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Tests for Perl_get_vtbl()
[perl5.git] / ext / XS-APItest / t / magic.t
CommitLineData
26ab20ee
FR
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
406700cc
NC
30is(test_get_vtbl(), 0, 'get_vtbl(-1) returns NULL');
31
26ab20ee 32done_testing;