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