Commit | Line | Data |
9a7f2b2d |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
a28e50e4 |
6 | use Test::More; |
9a7f2b2d |
7 | |
8 | our @demolished; |
9 | package Foo; |
10 | use Moose; |
11 | |
12 | sub DEMOLISH { |
13 | my $self = shift; |
14 | push @::demolished, __PACKAGE__; |
15 | } |
16 | |
17 | package Foo::Sub; |
18 | use Moose; |
19 | extends 'Foo'; |
20 | |
21 | sub DEMOLISH { |
22 | my $self = shift; |
23 | push @::demolished, __PACKAGE__; |
24 | } |
25 | |
26 | package Foo::Sub::Sub; |
27 | use Moose; |
28 | extends 'Foo::Sub'; |
29 | |
30 | sub DEMOLISH { |
31 | my $self = shift; |
32 | push @::demolished, __PACKAGE__; |
33 | } |
34 | |
35 | package main; |
36 | { |
37 | my $foo = Foo->new; |
38 | } |
39 | is_deeply(\@demolished, ['Foo'], "Foo demolished properly"); |
40 | @demolished = (); |
41 | { |
42 | my $foo_sub = Foo::Sub->new; |
43 | } |
44 | is_deeply(\@demolished, ['Foo::Sub', 'Foo'], "Foo::Sub demolished properly"); |
45 | @demolished = (); |
46 | { |
47 | my $foo_sub_sub = Foo::Sub::Sub->new; |
48 | } |
49 | is_deeply(\@demolished, ['Foo::Sub::Sub', 'Foo::Sub', 'Foo'], |
50 | "Foo::Sub::Sub demolished properly"); |
51 | @demolished = (); |
a28e50e4 |
52 | |
53 | done_testing; |