Do the $XS_VERSION trick to make XSLoader happy with a dev version
[gitmo/Moose.git] / t / 100_bugs / 012_DEMOLISH_eats_mini.t
index cb390bc..e4b03c4 100644 (file)
@@ -3,7 +3,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 7;
+use Test::More;
 use Test::Exception;
 
 
@@ -51,23 +51,51 @@ use Test::Exception;
     use Moose;
 
     sub DEMOLISH {
-        $@ = 1;
         $? = 0;
-        $! = 0;
     }
 }
 
 {
+    local $@ = 42;
+    local $? = 84;
+
+    {
+        Baz->new;
+    }
+
+    is( $@, 42, '$@ is still 42 after object is demolished without dying' );
+    is( $?, 84, '$? is still 84 after object is demolished without dying' );
+
     local $@ = 0;
-    local $? = 42;
-    local $! = 84;
 
     {
         Baz->new;
     }
 
-    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' );
+    is( $@, 0, '$@ is still 0 after object is demolished without dying' );
+
+    Baz->meta->make_immutable, redo
+        if Baz->meta->is_mutable
+}
+
+{
+    package Quux;
+    use Moose;
+
+    sub DEMOLISH {
+        die "foo\n";
+    }
+}
+
+{
+    local $@ = 42;
+
+    eval { my $obj = Quux->new };
+
+    like( $@, qr/foo/, '$@ contains error from demolish when demolish dies' );
+
+    Quux->meta->make_immutable, redo
+        if Quux->meta->is_mutable
 }
 
+done_testing;