Skip tests for strict constructor on Moose
[gitmo/Mouse.git] / t / 001_mouse / 015-demolish.t
CommitLineData
c3398f5b 1#!/usr/bin/env perl
2use strict;
3use warnings;
289e5430 4use Test::More tests => 15;
5use Test::Mouse;
c3398f5b 6
9acd019a 7my @called;
c3398f5b 8
9do {
10 package Class;
11 use Mouse;
12
13 sub DEMOLISH {
9acd019a 14 push @called, 'Class::DEMOLISH';
c3398f5b 15 }
16
224bfdd8 17# sub DEMOLISHALL {
18# my $self = shift;
19# push @called, 'Class::DEMOLISHALL';
20# $self->SUPER::DEMOLISHALL(@_);
21# }
c3398f5b 22
23 package Child;
24 use Mouse;
25 extends 'Class';
26
27 sub DEMOLISH {
9acd019a 28 push @called, 'Child::DEMOLISH';
c3398f5b 29 }
30
224bfdd8 31# sub DEMOLISHALL {
32# my $self = shift;
33# push @called, 'Child::DEMOLISHALL';
34# $self->SUPER::DEMOLISHALL(@_);
35# }
36};
37
38is_deeply([splice @called], [], "no DEMOLISH calls yet");
39
029463f4 40with_immutable sub {
289e5430 41 ok(Class->meta, Class->meta->is_immutable ? 'mutable' : 'immutable');
224bfdd8 42
289e5430 43 {
44 my $object = Class->new;
224bfdd8 45
289e5430 46 is_deeply([splice @called], [], "no DEMOLISH calls yet");
47 }
224bfdd8 48
289e5430 49 is_deeply([splice @called], ['Class::DEMOLISH']);
c3398f5b 50
289e5430 51 {
52 my $child = Child->new;
53 is_deeply([splice @called], [], "no DEMOLISH calls yet");
c3398f5b 54
289e5430 55 }
c3398f5b 56
289e5430 57 is_deeply([splice @called], ['Child::DEMOLISH', 'Class::DEMOLISH']);
c3398f5b 58
289e5430 59 {
60 my $child = Child->new;
61 $child->DEMOLISHALL();
c3398f5b 62
289e5430 63 is_deeply([splice @called], ['Child::DEMOLISH', 'Class::DEMOLISH'], 'DEMOLISHALL');
64 }
c3398f5b 65
289e5430 66 is_deeply([splice @called], ['Child::DEMOLISH', 'Class::DEMOLISH'], 'DEMOLISHALL');
029463f4 67}, qw(Class Child);