5 package Test::Scope::Guard;
6 sub new { my ($class, $code) = @_; bless [$code], $class; }
7 sub DESTROY { my $self = shift; $self->[0]->() }
11 END { $? = $had_error }
13 $had_error++, print "not " if !$_[0];
15 print " - $_[1]" if defined $_[1];
20 use Devel::GlobalDestruction::XS;
22 sub check_not_global {
24 ok !Devel::GlobalDestruction::XS::in_global_destruction(), "$phase is not GD";
25 Test::Scope::Guard->new( sub {
26 ok( !Devel::GlobalDestruction::XS::in_global_destruction(), "DESTROY in $phase still not GD" );
34 BEGIN { check_not_global('BEGIN') }
37 if (eval 'UNITCHECK {}; 1') {
38 eval q[ UNITCHECK { check_not_global('UNITCHECK') }; 1 ]
42 print "ok # UNITCHECK not supported in perl < 5.10\n" x 2;
46 CHECK { check_not_global('CHECK') }
47 sub CLONE { check_not_global('CLONE') };
48 INIT { check_not_global('INIT') }
49 END { check_not_global('END') }