2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
10 'Test::Output' => '0.01', # skip all if not installed
13 # this test script ensures that my idiom of:
14 # role: sub BUILD, after BUILD
15 # continues to work to run code after object initialization, whether the class
16 # has a BUILD method or not
24 sub BUILD { push @CALLS, 'TestRole::BUILD' }
25 before BUILD => sub { push @CALLS, 'TestRole::BUILD:before' };
26 after BUILD => sub { push @CALLS, 'TestRole::BUILD:after' };
30 package ClassWithBUILD;
37 sub BUILD { push @CALLS, 'ClassWithBUILD::BUILD' }
41 package ExplicitClassWithBUILD;
45 with 'TestRole' => { -excludes => 'BUILD' };
48 sub BUILD { push @CALLS, 'ExplicitClassWithBUILD::BUILD' }
52 package ClassWithoutBUILD;
58 is_deeply([splice @CALLS], [], "no calls to BUILD yet");
62 is_deeply([splice @CALLS], [
63 'TestRole::BUILD:before',
64 'ClassWithBUILD::BUILD',
65 'TestRole::BUILD:after',
68 ClassWithoutBUILD->new;
70 is_deeply([splice @CALLS], [
71 'TestRole::BUILD:before',
73 'TestRole::BUILD:after',
76 if (ClassWithBUILD->meta->is_mutable) {
77 ClassWithBUILD->meta->make_immutable;
78 ClassWithoutBUILD->meta->make_immutable;