Commit | Line | Data |
101e5667 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | { |
5 | package Test::Scope::Guard; |
6 | sub new { my ($class, $code) = @_; bless [$code], $class; } |
7 | sub DESTROY { my $self = shift; $self->[0]->() } |
8 | } |
9 | |
10 | sub ok ($$) { |
11 | print "not " if !$_[0]; |
12 | print "ok"; |
13 | print " - $_[1]" if defined $_[1]; |
14 | print "\n"; |
15 | !!$_[0] |
16 | } |
17 | |
18 | BEGIN { |
19 | require B; |
20 | B::minus_c(); |
21 | |
22 | print "1..3\n"; |
23 | ok( $^C, "Test properly running under minus-c" ); |
24 | } |
25 | |
26 | use Devel::GlobalDestruction::XS; |
27 | |
28 | BEGIN { |
29 | ok !Devel::GlobalDestruction::XS::in_global_destruction(), "BEGIN is not GD with -c"; |
30 | } |
31 | |
32 | our $foo; |
33 | BEGIN { |
34 | $foo = Test::Scope::Guard->new( sub { |
35 | ok( Devel::GlobalDestruction::XS::in_global_destruction(), "Final cleanup object destruction properly in GD" ) or do { |
36 | require POSIX; |
37 | POSIX::_exit(1); |
38 | }; |
39 | }); |
40 | } |