5 if ($ENV{DEVEL_GLOBALDESTRUCTION_PP_TEST}) {
7 die 'no XS' if $_[1] eq 'Devel/GlobalDestruction/XS.pm';
13 package Test::Scope::Guard;
14 sub new { my ($class, $code) = @_; bless [$code], $class; }
15 sub DESTROY { my $self = shift; $self->[0]->() }
19 END { $? = $had_error }
21 $had_error++, print "not " if !$_[0];
23 print " - $_[1]" if defined $_[1];
28 use Devel::GlobalDestruction;
30 sub check_not_global {
32 ok !in_global_destruction(), "$phase is not GD";
33 Test::Scope::Guard->new( sub {
34 ok( !in_global_destruction(), "DESTROY in $phase still not GD" );
42 BEGIN { check_not_global('BEGIN') }
45 if (eval 'UNITCHECK {}; 1') {
46 eval q[ UNITCHECK { check_not_global('UNITCHECK') }; 1 ]
50 print "ok # UNITCHECK not supported in perl < 5.10\n" x 2;
54 CHECK { check_not_global('CHECK') }
55 sub CLONE { check_not_global('CLONE') };
56 INIT { check_not_global('INIT') }
57 END { check_not_global('END') }