Commit | Line | Data |
9a7f2b2d |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More tests => 2; |
7 | |
8 | our $expected_igd = 0; |
9 | package Foo; |
10 | use Moose; |
11 | |
12 | sub DEMOLISH { |
13 | my $self = shift; |
14 | my ($igd) = @_; |
15 | ::is($igd, $::expected_igd, |
16 | "in_global_destruction state is passed to DEMOLISH properly"); |
17 | } |
18 | |
19 | package main; |
20 | { |
21 | my $foo = Foo->new; |
22 | } |
23 | $expected_igd = 1; |
24 | # Test::Builder checks for a valid plan at END time, which is before global |
25 | # destruction, so need to test that in a subprocess |
26 | unless (fork) { |
27 | our $foo = Foo->new; |
28 | exit; |
29 | } |
30 | wait; |
31 | # but stuff that happens in a subprocess doesn't update Test::Builder's state |
32 | # in this process, so do that manually here |
33 | my $builder = Test::More->builder; |
34 | $builder->current_test($builder->current_test + 1); |