summaryrefslogtreecommitdiffstats
path: root/t/040-destructor.t
blob: 2900a15fe3705f65166ea4e03d79c9c4cbe64799 (plain) (blame)
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
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 4;

my $destroyed = 0;
my $demolished = 0;
package Foo;

sub new { bless {}, shift }

sub DESTROY { $destroyed++ }

package Foo::Sub;
use Moose;
use MooseX::NonMoose;
extends 'Foo';

sub DEMOLISH { $demolished++ }

package main;
{ Foo::Sub->new }
is($destroyed, 1, "non-Moose destructor called");
{ local $TODO = "don't support destructors properly yet";
is($demolished, 1, "Moose destructor called");
}
Foo::Sub->meta->make_immutable;
($destroyed, $demolished) = (0, 0);
{ Foo::Sub->new }
{ local $TODO = "don't support destructors properly yet";
is($destroyed, 1, "non-Moose destructor called (immutable)");
}
is($demolished, 1, "Moose destructor called (immutable)");