fix incompatibilities with TB2
[gitmo/Moose.git] / lib / Test / Moose.pm
index 38f5fe6..f2f0d9e 100644 (file)
@@ -71,11 +71,17 @@ sub has_attribute_ok ($$;$) {
 sub with_immutable (&@) {
     my $block = shift;
     my $before = $Test->current_test;
+    my $passing_before = (Test::Builder->VERSION < 1.005 ? 0 : $Test->history->pass_count) || 0;
+
     $block->();
     Class::MOP::class_of($_)->make_immutable for @_;
     $block->();
+
     my $num_tests = $Test->current_test - $before;
-    return all { $_ } ($Test->summary)[-$num_tests..-1];
+    my $all_passed = Test::Builder->VERSION < 1.005
+        ? all { $_ } ($Test->summary)[-$num_tests..-1]
+        : $num_tests == $Test->history->pass_count - $passing_before;
+    return $all_passed;
 }
 
 1;