Fix a possible segv on DESTROY
[gitmo/Mouse.git] / t / 010_basics / 020-global-destruction.t
CommitLineData
60ad2cb7 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6475f69d 6use Test::More;
60ad2cb7 7
8{
9 package Foo;
10 use Mouse;
11
12 sub DEMOLISH {
13 my $self = shift;
14 my ($igd) = @_;
15 ::ok(
16 !$igd,
17 'in_global_destruction state is passed to DEMOLISH properly (false)'
18 );
19 }
20}
21
22{
23 my $foo = Foo->new;
24}
25
26{
27 package Bar;
28 use Mouse;
29
30 sub DEMOLISH {
31 my $self = shift;
32 my ($igd) = @_;
33 ::ok(
34 !$igd,
35 'in_global_destruction state is passed to DEMOLISH properly (false)'
36 );
37 }
38
39 __PACKAGE__->meta->make_immutable;
40}
41
42{
43 my $bar = Bar->new;
44}
45
70425827 46$? = 0;
47
48my $blib = $INC{'blib.pm'} ? ' -Mblib ' : '';
49my @status = `$^X $blib t/010_basics/020-global-destruction-helper.pl`;
50
51ok $status[0], 'in_global_destruction state is passed to DEMOLISH properly (true)';
52ok $status[1], 'in_global_destruction state is passed to DEMOLISH properly (true)';
53
54is $?, 0, 'exited successfully';
60ad2cb7 55
6475f69d 56done_testing;