Copy two test files from Moose
[gitmo/Mouse.git] / t / 300_immutable / 005_multiple_demolish_inline.t
diff --git a/t/300_immutable/005_multiple_demolish_inline.t b/t/300_immutable/005_multiple_demolish_inline.t
new file mode 100755 (executable)
index 0000000..7b70107
--- /dev/null
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 5;
+use Test::Exception;
+
+
+
+{
+    package Foo;
+    use Mouse;
+
+    has 'foo' => (is => 'rw', isa => 'Int');
+
+    sub DEMOLISH { }
+}
+
+{
+    package Bar;
+    use Mouse;
+
+    extends qw(Foo);
+    has 'bar' => (is => 'rw', isa => 'Int');
+
+    sub DEMOLISH { }
+}
+
+lives_ok {
+    Bar->new();
+} 'Bar->new()';
+
+lives_ok {
+    Bar->meta->make_immutable;
+} 'Bar->meta->make_immutable';
+
+is( Bar->meta->get_method('DESTROY')->package_name, 'Bar',
+    'Bar has a DESTROY method in the Bar class (not inherited)' );
+
+lives_ok {
+    Foo->meta->make_immutable;
+} 'Foo->meta->make_immutable';
+
+is( Foo->meta->get_method('DESTROY')->package_name, 'Foo',
+    'Foo has a DESTROY method in the Bar class (not inherited)' );