X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F030_roles%2F019_build.t;h=c520f811d20b12c4c4e5c98a47f3493ec3ee2498;hb=7ca5c5fb6e084d9c57bc022b336458afc74c6847;hp=f76ea5a32d03af5ca432a32b0b3f27b864c36594;hpb=6719984210754e8d012ae678536f194c35000823;p=gitmo%2FMouse.git diff --git a/t/030_roles/019_build.t b/t/030_roles/019_build.t old mode 100644 new mode 100755 index f76ea5a..c520f81 --- a/t/030_roles/019_build.t +++ b/t/030_roles/019_build.t @@ -1,7 +1,13 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 6; +use Test::More; +BEGIN { + eval "use Test::Output;"; + plan skip_all => "Test::Output is required for this test" if $@; + + plan tests => 8; +} # this test script ensures that my idiom of: # role: sub BUILD, after BUILD @@ -22,53 +28,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; + } +}