7 "This test requires Class::Method::Modifiers or Class::Method::Modifiers::Fast"
9 require Class::Method::Modifiers::Fast;
11 require Class::Method::Modifiers;
18 # this test script ensures that my idiom of:
19 # role: sub BUILD, after BUILD
20 # continues to work to run code after object initialization, whether the class
21 # has a BUILD method or not
29 sub BUILD { push @CALLS, 'TestRole::BUILD' }
30 before BUILD => sub { push @CALLS, 'TestRole::BUILD:before' };
31 after BUILD => sub { push @CALLS, 'TestRole::BUILD:after' };
35 package ClassWithBUILD;
39 sub BUILD { push @CALLS, 'ClassWithBUILD::BUILD' }
43 package ClassWithoutBUILD;
48 is_deeply([splice @CALLS], [], "no calls to BUILD yet");
52 is_deeply([splice @CALLS], [
53 'TestRole::BUILD:before',
54 'ClassWithBUILD::BUILD',
55 'TestRole::BUILD:after',
58 ClassWithoutBUILD->new;
60 is_deeply([splice @CALLS], [
61 'TestRole::BUILD:before',
63 'TestRole::BUILD:after',
66 ClassWithBUILD->meta->make_immutable;
67 ClassWithoutBUILD->meta->make_immutable;
69 is_deeply([splice @CALLS], [], "no calls to BUILD yet");
73 is_deeply([splice @CALLS], [
74 'TestRole::BUILD:before',
75 'ClassWithBUILD::BUILD',
76 'TestRole::BUILD:after',
79 ClassWithoutBUILD->new;
81 is_deeply([splice @CALLS], [
82 'TestRole::BUILD:before',
84 'TestRole::BUILD:after',