add some more tests (including some TODOs)
[gitmo/Moose.git] / t / 100_bugs / 012_DEMOLISH_eats_mini.t
index 130e2c0..953e019 100644 (file)
@@ -3,12 +3,9 @@
 use strict;
 use warnings;
 
-use Test::More tests => 5;
+use Test::More;
 use Test::Exception;
 
-BEGIN {
-     use_ok('Moose');
-}
 
 {
     package Foo;
@@ -23,19 +20,19 @@ BEGIN {
     # if no call to ANY Moose::Object->new was done before.
     sub DEMOLISH {
         my ( $self ) = @_;
-        # ... Moose (kinda) eats exceptions in DESTROY/DEMOLISH";    
+        # ... Moose (kinda) eats exceptions in DESTROY/DEMOLISH";
     }
 }
 
 {
     my $obj = eval { Foo->new; };
-    ::like( $@, qr/is required/, "... Foo plain" );
-    ::is( $obj, undef, "... the object is undef" );
+    like( $@, qr/is required/, "... Foo plain" );
+    is( $obj, undef, "... the object is undef" );
 }
 
 {
     package Bar;
-    
+
     sub new { die "Bar died"; }
 
     sub DESTROY {
@@ -45,9 +42,40 @@ BEGIN {
 
 {
     my $obj = eval { Bar->new; };
-    ::like( $@, qr/Bar died/, "... Bar plain" );
-    ::is( $obj, undef, "... the object is undef" );
+    like( $@, qr/Bar died/, "... Bar plain" );
+    is( $obj, undef, "... the object is undef" );
+}
+
+{
+    package Baz;
+    use Moose;
+
+    sub DEMOLISH {
+        $? = 0;
+    }
 }
 
-1;
+{
+    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;
+
+    {
+        Baz->new;
+    }
+
+    is( $@, 0, '$@ is still 0 after object is demolished without dying' );
+
+    Baz->meta->make_immutable, redo
+        if Baz->meta->is_mutable
+}
 
+done_testing;