From: Dave Rolsky <autarch@urth.org>
Date: Fri, 11 Sep 2009 16:28:07 +0000 (-0500)
Subject: make sure status variable localization happens for immutable classes too
X-Git-Tag: 0.90~48
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=671dc85a6a11d897e1d81345e0a8e68e829b371b;p=gitmo%2FMoose.git

make sure status variable localization happens for immutable classes too
---

diff --git a/lib/Moose/Meta/Method/Destructor.pm b/lib/Moose/Meta/Method/Destructor.pm
index d3e10f3..627634a 100644
--- a/lib/Moose/Meta/Method/Destructor.pm
+++ b/lib/Moose/Meta/Method/Destructor.pm
@@ -81,6 +81,7 @@ sub _initialize_body {
     my $source;
     if ( @DEMOLISH_methods ) {
         $source = 'sub {';
+        $source .= 'local ( $., $@, $!, $^E, $? );' . "\n";
 
         my @DEMOLISH_calls;
         foreach my $method (@DEMOLISH_methods) {
diff --git a/t/100_bugs/012_DEMOLISH_eats_mini.t b/t/100_bugs/012_DEMOLISH_eats_mini.t
index cb390bc..1ba9f47 100644
--- a/t/100_bugs/012_DEMOLISH_eats_mini.t
+++ b/t/100_bugs/012_DEMOLISH_eats_mini.t
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 7;
+use Test::More tests => 10;
 use Test::Exception;
 
 
@@ -69,5 +69,8 @@ use Test::Exception;
     is( $@, 0, '$@ is still 0 after object is demolished' );
     is( $?, 42, '$? is still 42 after object is demolished' );
     is( $! + 0, 84, '$! is still 84 after object is demolished' );
+
+    Baz->meta->make_immutable, redo
+        if Baz->meta->is_mutable
 }