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