6 package Test::Scope::Guard;
7 sub new { my ($class, $code) = @_; bless [$code], $class; }
8 sub DESTROY { my $self = shift; $self->[0]->() }
16 $had_error++, print "not " if !$_[0];
18 print " - $_[1]" if defined $_[1];
23 ok( ! Devel::GlobalDestruction::XS::in_global_destruction(), 'Not yet in GD while in END block 2' )
26 ok( eval "use Devel::GlobalDestruction::XS; 1", "use Devel::GlobalDestruction::XS" );
28 ok( defined prototype \&Devel::GlobalDestruction::XS::in_global_destruction, "defined prototype" );
30 ok( prototype \&Devel::GlobalDestruction::XS::in_global_destruction eq "", "empty prototype" );
32 ok( ! Devel::GlobalDestruction::XS::in_global_destruction(), "Runtime is not GD" );
34 our $sg1 = Test::Scope::Guard->new(sub { ok( Devel::GlobalDestruction::XS::in_global_destruction(), "Final cleanup object destruction properly in GD" ) });
37 ok( ! Devel::GlobalDestruction::XS::in_global_destruction(), 'Not yet in GD while in END block 1' )
40 our $sg2 = Test::Scope::Guard->new(sub { ok( ! Devel::GlobalDestruction::XS::in_global_destruction(), "Object destruction in END not considered GD" ) });