warn if we try to overwrite a local function with an accessor
[gitmo/Moose.git] / t / 010_basics / 020-global-destruction.t
index a20ee08..9811319 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 2;
+use Test::More;
 
 {
     package Foo;
@@ -23,6 +23,29 @@ use Test::More tests => 2;
     my $foo = Foo->new;
 }
 
-my $igd = `$^X t/010_basics/020-global-destruction-helper.pl`;
-ok( $igd,
-    'in_global_destruction state is passed to DEMOLISH properly (true)' );
+{
+    package Bar;
+    use Moose;
+
+    sub DEMOLISH {
+        my $self = shift;
+        my ($igd) = @_;
+        ::ok(
+            !$igd,
+            'in_global_destruction state is passed to DEMOLISH properly (false)'
+        );
+    }
+
+    __PACKAGE__->meta->make_immutable;
+}
+
+{
+    my $bar = Bar->new;
+}
+
+ok(
+    $_,
+    'in_global_destruction state is passed to DEMOLISH properly (true)'
+) for split //, `$^X t/010_basics/020-global-destruction-helper.pl`;
+
+done_testing;