From: Shawn M Moore Date: Tue, 21 Apr 2009 06:24:12 +0000 (-0400) Subject: Avoid duplication in running the same tests with and without immutable X-Git-Tag: 0.75_01~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=27f4baaf71c8a8463be903cc02a4e891fcc69022;p=gitmo%2FMoose.git Avoid duplication in running the same tests with and without immutable --- diff --git a/t/030_roles/019_build.t b/t/030_roles/019_build.t index 03b149a..fc4bb0e 100644 --- a/t/030_roles/019_build.t +++ b/t/030_roles/019_build.t @@ -33,42 +33,29 @@ do { with 'TestRole'; }; -is_deeply([splice @CALLS], [], "no calls to BUILD yet"); - -ClassWithBUILD->new; - -is_deeply([splice @CALLS], [ - 'TestRole::BUILD:before', - 'ClassWithBUILD::BUILD', - 'TestRole::BUILD:after', -]); - -ClassWithoutBUILD->new; - -is_deeply([splice @CALLS], [ - 'TestRole::BUILD:before', - 'TestRole::BUILD', - 'TestRole::BUILD:after', -]); - -ClassWithBUILD->meta->make_immutable; -ClassWithoutBUILD->meta->make_immutable; - -is_deeply([splice @CALLS], [], "no calls to BUILD yet"); - -ClassWithBUILD->new; - -is_deeply([splice @CALLS], [ - 'TestRole::BUILD:before', - 'ClassWithBUILD::BUILD', - 'TestRole::BUILD:after', -]); - -ClassWithoutBUILD->new; - -is_deeply([splice @CALLS], [ - 'TestRole::BUILD:before', - 'TestRole::BUILD', - 'TestRole::BUILD:after', -]); +{ + is_deeply([splice @CALLS], [], "no calls to BUILD yet"); + + ClassWithBUILD->new; + + is_deeply([splice @CALLS], [ + 'TestRole::BUILD:before', + 'ClassWithBUILD::BUILD', + 'TestRole::BUILD:after', + ]); + + ClassWithoutBUILD->new; + + is_deeply([splice @CALLS], [ + 'TestRole::BUILD:before', + 'TestRole::BUILD', + 'TestRole::BUILD:after', + ]); + + if (ClassWithBUILD->meta->is_mutable) { + ClassWithBUILD->meta->make_immutable; + ClassWithoutBUILD->meta->make_immutable; + redo; + } +}