From: gfx Date: Wed, 16 Dec 2009 08:22:28 +0000 (+0900) Subject: Add with_immutable to Test::Mouse X-Git-Tag: 0.45~24 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=commitdiff_plain;h=b6f6340b383df81ad237c75018adc554d87ecbf7;hp=adb5eb76f6875283f11d6f2b8d281568f0a4a688 Add with_immutable to Test::Mouse --- diff --git a/lib/Test/Mouse.pm b/lib/Test/Mouse.pm index 34697eb..a9583bf 100644 --- a/lib/Test/Mouse.pm +++ b/lib/Test/Mouse.pm @@ -10,6 +10,7 @@ Mouse::Exporter->setup_import_methods( meta_ok does_ok has_attribute_ok + with_immutable )], ); @@ -60,6 +61,20 @@ sub has_attribute_ok ($$;$) { } } +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 !grep{ !$_ } ($Test->summary)[-$num_tests .. -1]; +} + 1; __END__