summaryrefslogblamecommitdiffstats
path: root/t/destructor.t
blob: e9a218556a1108b50bda940e0a228cce332174fc (plain) (tree)
1
2
3
4
5
6
7


                   
               
                
 
                             













                              






                                                     

             
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::Moose;

my ($destroyed, $demolished);
package Foo;

sub new { bless {}, shift }

sub DESTROY { $destroyed++ }

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

sub DEMOLISH { $demolished++ }

package main;

with_immutable {
    ($destroyed, $demolished) = (0, 0);
    { Foo::Sub->new }
    is($destroyed, 1, "non-Moose destructor called");
    is($demolished, 1, "Moose destructor called");
} 'Foo::Sub';

done_testing;