X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=t%2F030_roles%2F019_build.t;h=475e4fba4f039665c0987c27027e05e350285ab7;hp=8d3a4a4bd3b57b401e62d89d5b84a9a166c7eccf;hb=6cfa1e5e70616fb102915489c02d8347ffa912fb;hpb=4f9945f5a128e120049ce8a7a30cf469d1568b9b diff --git a/t/030_roles/019_build.t b/t/030_roles/019_build.t old mode 100644 new mode 100755 index 8d3a4a4..475e4fb --- a/t/030_roles/019_build.t +++ b/t/030_roles/019_build.t @@ -3,18 +3,11 @@ use strict; use warnings; use Test::More; BEGIN { - plan skip_all => - "This test requires Class::Method::Modifiers or Class::Method::Modifiers::Fast" - unless eval { - require Class::Method::Modifiers::Fast; - } or eval { - require Class::Method::Modifiers; - }; + eval "use Test::Output;"; + plan skip_all => "Test::Output is required for this test" if $@; + plan tests => 8; } -plan tests => 6; - - # this test script ensures that my idiom of: # role: sub BUILD, after BUILD # continues to work to run code after object initialization, whether the class @@ -34,53 +27,54 @@ do { do { package ClassWithBUILD; use Mouse; - with 'TestRole'; + + ::stderr_is { + with 'TestRole'; + } ''; sub BUILD { push @CALLS, 'ClassWithBUILD::BUILD' } }; do { - package ClassWithoutBUILD; + package ExplicitClassWithBUILD; use Mouse; - with 'TestRole'; -}; - -is_deeply([splice @CALLS], [], "no calls to BUILD yet"); -ClassWithBUILD->new; + ::stderr_is { + with 'TestRole' => { excludes => 'BUILD' }; + } ''; -is_deeply([splice @CALLS], [ - 'TestRole::BUILD:before', - 'ClassWithBUILD::BUILD', - 'TestRole::BUILD:after', -]); - -ClassWithoutBUILD->new; + sub BUILD { push @CALLS, 'ExplicitClassWithBUILD::BUILD' } +}; -is_deeply([splice @CALLS], [ - 'TestRole::BUILD:before', - 'TestRole::BUILD', - 'TestRole::BUILD:after', -]); +do { + package ClassWithoutBUILD; + use Mouse; + with 'TestRole'; +}; -ClassWithBUILD->meta->make_immutable; -ClassWithoutBUILD->meta->make_immutable; +{ + is_deeply([splice @CALLS], [], "no calls to BUILD yet"); -is_deeply([splice @CALLS], [], "no calls to BUILD yet"); + ClassWithBUILD->new; -ClassWithBUILD->new; + is_deeply([splice @CALLS], [ + 'TestRole::BUILD:before', + 'ClassWithBUILD::BUILD', + 'TestRole::BUILD:after', + ]); -is_deeply([splice @CALLS], [ - 'TestRole::BUILD:before', - 'ClassWithBUILD::BUILD', - 'TestRole::BUILD:after', -]); + ClassWithoutBUILD->new; -ClassWithoutBUILD->new; + is_deeply([splice @CALLS], [ + 'TestRole::BUILD:before', + 'TestRole::BUILD', + 'TestRole::BUILD:after', + ]); -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; + } +}