bump version
[p5sagit/Devel-GlobalDestruction.git] / t / 03_minusc.t
CommitLineData
09b12813 1use strict;
2use warnings;
3
4BEGIN {
5 if ($ENV{DEVEL_GLOBALDESTRUCTION_PP_TEST}) {
b1bee216 6 unshift @INC, sub {
7 die 'no XS' if $_[1] eq 'Devel/GlobalDestruction/XS.pm';
8 };
09b12813 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
18sub ok ($$) {
19 print "not " if !$_[0];
20 print "ok";
21 print " - $_[1]" if defined $_[1];
22 print "\n";
23 !!$_[0]
24}
25
26BEGIN {
27 require B;
28 B::minus_c();
29
5629eb97 30 print "1..3\n";
09b12813 31 ok( $^C, "Test properly running under minus-c" );
32}
33
34use Devel::GlobalDestruction;
35
5629eb97 36BEGIN {
37 ok !in_global_destruction(), "BEGIN is not GD with -c";
38}
39
09b12813 40our $foo;
41BEGIN {
42 $foo = Test::Scope::Guard->new( sub {
43 ok( in_global_destruction(), "Final cleanup object destruction properly in GD" ) or do {
44 require POSIX;
45 POSIX::_exit(1);
46 };
47 });
48}