Commit | Line | Data |
a91e8a78 |
1 | use strict; |
2 | use warnings; |
3 | |
9aaf3646 |
4 | BEGIN { |
5 | if ($ENV{DEVEL_GLOBALDESTRUCTION_PP_TEST}) { |
6 | require DynaLoader; |
7 | no warnings 'redefine'; |
8 | my $orig = \&DynaLoader::bootstrap; |
9 | *DynaLoader::bootstrap = sub { |
10 | die 'no XS' if $_[0] eq 'Devel::GlobalDestruction'; |
11 | goto $orig; |
12 | }; |
13 | } |
14 | } |
a91e8a78 |
15 | |
38d57e49 |
16 | BEGIN { |
17 | package Test::Scope::Guard; |
18 | sub new { my ($class, $code) = @_; bless [$code], $class; } |
19 | sub DESTROY { my $self = shift; $self->[0]->() } |
20 | } |
a91e8a78 |
21 | |
41ec1eaf |
22 | print "1..6\n"; |
a91e8a78 |
23 | |
6d3e0a6f |
24 | my $had_error = 0; |
25 | END { $? = $had_error }; |
a91e8a78 |
26 | sub ok ($$) { |
6d3e0a6f |
27 | $had_error++, print "not " if !$_[0]; |
f832e240 |
28 | print "ok"; |
29 | print " - $_[1]" if defined $_[1]; |
30 | print "\n"; |
a91e8a78 |
31 | } |
32 | |
33 | ok( eval "use Devel::GlobalDestruction; 1", "use Devel::GlobalDestruction" ); |
34 | |
35 | ok( defined &in_global_destruction, "exported" ); |
36 | |
41ec1eaf |
37 | ok( defined prototype \&in_global_destruction, "defined prototype" ); |
38 | |
39 | ok( prototype \&in_global_destruction eq "", "empty prototype" ); |
40 | |
a91e8a78 |
41 | ok( !in_global_destruction(), "not in GD" ); |
42 | |
38d57e49 |
43 | our $sg = Test::Scope::Guard->new(sub { ok( in_global_destruction(), "in GD" ) }); |