X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FTest%2FMouse.pm;h=6bf1ba7e4b5be3e819c2f2ade8629118fc7f4854;hb=a4b15169d428989d2e901708effe21f3eaab23b5;hp=34697ebb1524d40d6052d05ca6c923b2679a6785;hpb=73e9153a57c2adfd533a0ac5a3ad843ebfd4c7e7;p=gitmo%2FMouse.git diff --git a/lib/Test/Mouse.pm b/lib/Test/Mouse.pm index 34697eb..6bf1ba7 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 )], ); @@ -19,7 +20,7 @@ my $Test = Test::Builder->new; ## exported functions -sub meta_ok ($;$) { +sub meta_ok ($;$) { ## no critic my ($class_or_obj, $message) = @_; $message ||= "The object has a meta"; @@ -32,7 +33,7 @@ sub meta_ok ($;$) { } } -sub does_ok ($$;$) { +sub does_ok ($$;$) { ## no critic my ($class_or_obj, $does, $message) = @_; $message ||= "The object does $does"; @@ -45,7 +46,7 @@ sub does_ok ($$;$) { } } -sub has_attribute_ok ($$;$) { +sub has_attribute_ok ($$;$) { ## no critic my ($class_or_obj, $attr_name, $message) = @_; $message ||= "The object does has an attribute named $attr_name"; @@ -60,6 +61,20 @@ sub has_attribute_ok ($$;$) { } } +sub with_immutable (&@) { ## no critic + 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__