Commit | Line | Data |
c3398f5b |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
289e5430 |
4 | use Test::More tests => 15; |
5 | use Test::Mouse; |
c3398f5b |
6 | |
9acd019a |
7 | my @called; |
c3398f5b |
8 | |
9 | do { |
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 | |
38 | is_deeply([splice @called], [], "no DEMOLISH calls yet"); |
39 | |
289e5430 |
40 | with_immutable { |
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'); |
67 | } qw(Class Child); |