Commit | Line | Data |
350bef65 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | BEGIN { |
5 | if ($ENV{DEVEL_GLOBALDESTRUCTION_PP_TEST}) { |
6 | unshift @INC, sub { |
7 | die 'no XS' if $_[1] eq 'Devel/GlobalDestruction/XS.pm'; |
8 | }; |
9 | } |
10 | } |
11 | |
12 | { |
13 | package Test::Scope::Guard; |
14 | sub new { my ($class, $code) = @_; bless [$code], $class; } |
15 | sub DESTROY { my $self = shift; $self->[0]->() } |
16 | } |
17 | |
9d52b29f |
18 | use POSIX qw(_exit); |
19 | |
9d52b29f |
20 | $|++; |
21 | print "1..3\n"; |
350bef65 |
22 | |
23 | our $alive = Test::Scope::Guard->new(sub { |
24 | require Devel::GlobalDestruction; |
25 | my $gd = Devel::GlobalDestruction::in_global_destruction(); |
9d52b29f |
26 | print(($gd ? '' : 'not ') . "ok 3 - global destruct detected when loaded during GD\n"); |
27 | _exit($gd ? 0 : 1); |
350bef65 |
28 | }); |
29 | |
9d52b29f |
30 | print(($alive ? '' : 'not ') . "ok 1 - alive during runtime\n"); |
31 | END { |
32 | print(($alive ? '' : 'not ') . "ok 2 - alive during END\n"); |
33 | } |