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