use Sub::Exporter;
use Test::Builder;
+use List::MoreUtils 'all';
use Moose::Util 'does_role', 'find_meta';
our $VERSION = '0.93';
sub with_immutable (&@) {
my $block = shift;
+ my $before = $Test->current_test;
$block->();
$_->meta->make_immutable for @_;
$block->();
+ my $num_tests = $Test->current_test - $before;
+ return all { $_ } ($Test->summary)[-$num_tests..-1];
}
1;
use strict;
use warnings;
-use Test::Builder::Tester tests => 2;
+use Test::Builder::Tester tests => 5;
use Test::More;
BEGIN {
use Moose;
}
+{
+ package Bar;
+ use Moose;
+}
+
package main;
test_out("ok 1", "not ok 2");
test_fail(+2);
-with_immutable {
+my $ret = with_immutable {
ok(Foo->meta->is_mutable);
} qw(Foo);
+test_test('with_immutable failure');
+ok(!$ret, "one of our tests failed");
-test_test('with_immutable');
+test_out("ok 1", "ok 2");
+$ret = with_immutable {
+ ok(Bar->meta->find_method_by_name('new'));
+} qw(Bar);
+test_test('with_immutable success');
+ok($ret, "all tests succeeded");