summaryrefslogtreecommitdiffstats
path: root/t/40-destructor.t
diff options
context:
space:
mode:
Diffstat (limited to 't/40-destructor.t')
-rw-r--r--t/40-destructor.t19
1 files changed, 9 insertions, 10 deletions
diff --git a/t/40-destructor.t b/t/40-destructor.t
index f2c88be..741db60 100644
--- a/t/40-destructor.t
+++ b/t/40-destructor.t
@@ -2,9 +2,9 @@
use strict;
use warnings;
use Test::More tests => 4;
+use Test::Moose;
-my $destroyed = 0;
-my $demolished = 0;
+my ($destroyed, $demolished);
package Foo;
sub new { bless {}, shift }
@@ -19,11 +19,10 @@ extends 'Foo';
sub DEMOLISH { $demolished++ }
package main;
-{ Foo::Sub->new }
-is($destroyed, 1, "non-Moose destructor called");
-is($demolished, 1, "Moose destructor called");
-Foo::Sub->meta->make_immutable;
-($destroyed, $demolished) = (0, 0);
-{ Foo::Sub->new }
-is($destroyed, 1, "non-Moose destructor called (immutable)");
-is($demolished, 1, "Moose destructor called (immutable)");
+
+with_immutable {
+ ($destroyed, $demolished) = (0, 0);
+ { Foo::Sub->new }
+ is($destroyed, 1, "non-Moose destructor called");
+ is($demolished, 1, "Moose destructor called");
+} 'Foo::Sub';