fixing bug, thanks to Sartak
[gitmo/Moose.git] / t / 100_bugs / 012_DEMOLISH_eats_mini.t
index 81eac60..130e2c0 100644 (file)
@@ -3,12 +3,11 @@
 use strict;
 use warnings;
 
-use Test::More no_plan => 1;
+use Test::More tests => 5;
 use Test::Exception;
 
 BEGIN {
      use_ok('Moose');
-     use_ok('Moose::Util::TypeConstraints');
 }
 
 {
@@ -24,12 +23,31 @@ BEGIN {
     # if no call to ANY Moose::Object->new was done before.
     sub DEMOLISH {
         my ( $self ) = @_;
+        # ... 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" );
+{
+    my $obj = eval { Foo->new; };
+    ::like( $@, qr/is required/, "... Foo plain" );
+    ::is( $obj, undef, "... the object is undef" );
+}
+
+{
+    package Bar;
+    
+    sub new { die "Bar died"; }
+
+    sub DESTROY {
+        die "Vanilla Perl eats exceptions in DESTROY too";
+    }
+}
+
+{
+    my $obj = eval { Bar->new; };
+    ::like( $@, qr/Bar died/, "... Bar plain" );
+    ::is( $obj, undef, "... the object is undef" );
+}
 
 1;