summaryrefslogtreecommitdiff
path: root/t/basics/global_destruction.t
blob: 53a4db17014f6e5c63eee77fae4d33de77c0f0d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use strict;
use warnings;

use Test::More;

{
    package Foo;
    use Moose;

    sub DEMOLISH {
        my $self = shift;
        my ($igd) = @_;
        ::ok(
            !$igd,
            'in_global_destruction state is passed to DEMOLISH properly (false)'
        );
    }
}

{
    my $foo = Foo->new;
}

{
    package Bar;
    use Moose;

    sub DEMOLISH {
        my $self = shift;
        my ($igd) = @_;
        ::ok(
            !$igd,
            'in_global_destruction state is passed to DEMOLISH properly (false)'
        );
    }

    __PACKAGE__->meta->make_immutable;
}

{
    my $bar = Bar->new;
}

ok(
    $_,
    'in_global_destruction state is passed to DEMOLISH properly (true)'
) for split //, `$^X t/basics/global-destruction-helper.pl`;

done_testing;