X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F15-self.t;h=cfca7080faaabace5c1b0732dd9b6a96494654e6;hb=e5e39f5e8bec67b3a08f861da63c5eb4cafed09f;hp=cff8429b24ede8a1b1a9a7913b18dec8d2b83b17;hpb=a86e3e47a167afadf7de1231d6401a1139330ad0;p=perl%2Fmodules%2FVariable-Magic.git diff --git a/t/15-self.t b/t/15-self.t index cff8429..cfca708 100644 --- a/t/15-self.t +++ b/t/15-self.t @@ -3,9 +3,9 @@ use strict; use warnings; -use Test::More tests => 16; +use Test::More tests => 17; -use Variable::Magic qw/wizard cast dispell getdata getsig/; +use Variable::Magic qw/wizard cast dispell getdata/; my $c = 0; @@ -15,39 +15,47 @@ my $c = 0; get => sub { ++$c }, free => sub { --$c } }; - ok(!$@, "wizard creation error ($@)"); - ok(defined $wiz, 'wizard is defined'); + is($@, '', 'wizard creation error doesn\'t croak'); + ok(defined $wiz, 'wizard is defined'); is(ref $wiz, 'SCALAR', 'wizard is a scalar ref'); my $res = eval { cast $wiz, $wiz }; - ok(!$@, "cast on self doesn't croak ($@)"); - ok($res, 'cast on self is valid'); + is($@, '', 'cast on self doesn\'t croak'); + ok($res, 'cast on self is valid'); my $w = $wiz; is($c, 1, 'magic works correctly on self'); $res = eval { dispell $wiz, $wiz }; - ok(!$@, "dispell on self doesn't croak ($@)"); - ok($res, 'dispell on self is valid'); + is($@, '', 'dispell on self doesn\'t croak'); + ok($res, 'dispell on self is valid'); $w = $wiz; is($c, 1, 'magic is no longer invoked on self when dispelled'); $res = eval { cast $wiz, $wiz, $wiz }; - ok(!$@, "re-cast on self doesn't croak ($@)"); - ok($res, 're-cast on self is valid'); + is($@, '', 're-cast on self doesn\'t croak'); + ok($res, 're-cast on self is valid'); $w = getdata $wiz, $wiz; is($c, 1, 'getdata on magical self doesn\'t trigger callbacks'); - # is(getsig($w), getsig($wiz), 'getdata returns the correct wizard'); $res = eval { dispell $wiz, $wiz }; - ok(!$@, "re-dispell on self doesn't croak ($@)"); - ok($res, 're-dispell on self is valid'); + is($@, '', 're-dispell on self doesn\'t croak'); + ok($res, 're-dispell on self is valid'); $res = eval { cast $wiz, $wiz }; - ok(!$@, "re-re-cast on self doesn't croak ($@)"); - ok($res, 're-re-cast on self is valid'); + is($@, '', 're-re-cast on self doesn\'t croak'); + ok($res, 're-re-cast on self is valid'); } -# is($c, 0, 'magic destructor is called'); +eval q[ + use lib 't/lib'; + BEGIN { require Variable::Magic::TestDestroyRequired; } +]; +is $@, '', 'wizard destruction at the end of BEGIN-time require doesn\'t panic'; + +if ((defined $ENV{PERL_DESTRUCT_LEVEL} and $ENV{PERL_DESTRUCT_LEVEL} >= 3) + or eval "use Perl::Destruct::Level level => 3; 1") { + diag 'Test global destruction'; +}