fixing test suite to address RT ticket 47119
[gitmo/Class-MOP.git] / t / 310_immutable_destroy.t
1 use strict;
2 use warnings;
3 use Test::More tests => 2;
4 use Class::MOP;
5
6 SKIP: {
7     unless (eval { require Moose; Moose->VERSION(0.72); 1 }) {
8         diag( $@ );
9         skip 'This test requires Moose 0.72', 2;
10         exit 0;
11     }
12
13     {
14         local $SIG{__WARN__} = sub {};
15         eval <<'EOF';
16     package FooBar;
17     use Moose 0.72;
18
19     has 'name' => ( is => 'ro' );
20
21     sub DESTROY { shift->name }
22
23     __PACKAGE__->meta->make_immutable;
24 EOF
25     }
26
27     ok( ! $@, 'evaled FooBar package' )
28       or diag( $@ );
29     my $f = FooBar->new( name => 'SUSAN' );
30
31     is( $f->DESTROY, 'SUSAN',
32         'Class::MOP::Class should not override an existing DESTROY method' );
33 }