Commit | Line | Data |
c3398f5b |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
9acd019a |
4 | use Test::More tests => 5; |
c3398f5b |
5 | |
9acd019a |
6 | my @called; |
c3398f5b |
7 | |
8 | do { |
9 | package Class; |
10 | use Mouse; |
11 | |
12 | sub DEMOLISH { |
9acd019a |
13 | push @called, 'Class::DEMOLISH'; |
c3398f5b |
14 | } |
15 | |
16 | sub DEMOLISHALL { |
17 | my $self = shift; |
9acd019a |
18 | push @called, 'Class::DEMOLISHALL'; |
c3398f5b |
19 | $self->SUPER::DEMOLISHALL(@_); |
20 | } |
21 | |
22 | package Child; |
23 | use Mouse; |
24 | extends 'Class'; |
25 | |
26 | sub DEMOLISH { |
9acd019a |
27 | push @called, 'Child::DEMOLISH'; |
c3398f5b |
28 | } |
29 | |
30 | sub DEMOLISHALL { |
31 | my $self = shift; |
9acd019a |
32 | push @called, 'Child::DEMOLISHALL'; |
c3398f5b |
33 | $self->SUPER::DEMOLISHALL(@_); |
34 | } |
35 | }; |
36 | |
9acd019a |
37 | is_deeply([splice @called], [], "no DEMOLISH calls yet"); |
c3398f5b |
38 | |
39 | do { |
40 | my $object = Class->new; |
41 | |
9acd019a |
42 | is_deeply([splice @called], [], "no DEMOLISH calls yet"); |
c3398f5b |
43 | }; |
44 | |
9acd019a |
45 | is_deeply([splice @called], ['Class::DEMOLISHALL', 'Class::DEMOLISH']); |
c3398f5b |
46 | |
47 | do { |
48 | my $child = Child->new; |
9acd019a |
49 | is_deeply([splice @called], [], "no DEMOLISH calls yet"); |
c3398f5b |
50 | |
c3398f5b |
51 | }; |
52 | |
9acd019a |
53 | is_deeply([splice @called], ['Child::DEMOLISHALL', 'Class::DEMOLISHALL', 'Child::DEMOLISH', 'Class::DEMOLISH']); |