summaryrefslogtreecommitdiff
path: root/t/basics/global_destruction.t
diff options
context:
space:
mode:
Diffstat (limited to 't/basics/global_destruction.t')
-rw-r--r--t/basics/global_destruction.t49
1 files changed, 49 insertions, 0 deletions
diff --git a/t/basics/global_destruction.t b/t/basics/global_destruction.t
new file mode 100644
index 0000000..53a4db1
--- /dev/null
+++ b/t/basics/global_destruction.t
@@ -0,0 +1,49 @@
+use strict;
+use warnings;
+
+use Test::More;
+
+{
+ package Foo;
+ use Moose;
+
+ sub DEMOLISH {
+ my $self = shift;
+ my ($igd) = @_;
+ ::ok(
+ !$igd,
+ 'in_global_destruction state is passed to DEMOLISH properly (false)'
+ );
+ }
+}
+
+{
+ my $foo = Foo->new;
+}
+
+{
+ 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/basics/global-destruction-helper.pl`;
+
+done_testing;