summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--t/040-destructor.t33
1 files changed, 33 insertions, 0 deletions
diff --git a/t/040-destructor.t b/t/040-destructor.t
new file mode 100644
index 0000000..2900a15
--- /dev/null
+++ b/t/040-destructor.t
@@ -0,0 +1,33 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 4;
+
+my $destroyed = 0;
+my $demolished = 0;
+package Foo;
+
+sub new { bless {}, shift }
+
+sub DESTROY { $destroyed++ }
+
+package Foo::Sub;
+use Moose;
+use MooseX::NonMoose;
+extends 'Foo';
+
+sub DEMOLISH { $demolished++ }
+
+package main;
+{ Foo::Sub->new }
+is($destroyed, 1, "non-Moose destructor called");
+{ local $TODO = "don't support destructors properly yet";
+is($demolished, 1, "Moose destructor called");
+}
+Foo::Sub->meta->make_immutable;
+($destroyed, $demolished) = (0, 0);
+{ Foo::Sub->new }
+{ local $TODO = "don't support destructors properly yet";
+is($destroyed, 1, "non-Moose destructor called (immutable)");
+}
+is($demolished, 1, "Moose destructor called (immutable)");