6 eval "use Test::Output;";
7 plan skip_all => "Test::Output is required for this test" if $@;
9 unless(eval { require Class::Method::Modifiers::Fast } or eval{ require Class::Method::Modifiers }){
10 plan skip_all => "Class::Method::Modifiers(::Fast)? is required for this test" if $@;
16 # this test script ensures that my idiom of:
17 # role: sub BUILD, after BUILD
18 # continues to work to run code after object initialization, whether the class
19 # has a BUILD method or not
27 sub BUILD { push @CALLS, 'TestRole::BUILD' }
28 before BUILD => sub { push @CALLS, 'TestRole::BUILD:before' };
29 after BUILD => sub { push @CALLS, 'TestRole::BUILD:after' };
33 package ClassWithBUILD;
40 sub BUILD { push @CALLS, 'ClassWithBUILD::BUILD' }
44 package ExplicitClassWithBUILD;
48 with 'TestRole' => { excludes => 'BUILD' };
51 sub BUILD { push @CALLS, 'ExplicitClassWithBUILD::BUILD' }
55 package ClassWithoutBUILD;
61 is_deeply([splice @CALLS], [], "no calls to BUILD yet");
65 is_deeply([splice @CALLS], [
66 'TestRole::BUILD:before',
67 'ClassWithBUILD::BUILD',
68 'TestRole::BUILD:after',
71 ClassWithoutBUILD->new;
73 is_deeply([splice @CALLS], [
74 'TestRole::BUILD:before',
76 'TestRole::BUILD:after',
79 if (ClassWithBUILD->meta->is_mutable) {
80 ClassWithBUILD->meta->make_immutable;
81 ClassWithoutBUILD->meta->make_immutable;