PPI/Statement/Scheduled.pm

filter: Statementstmt 86.6% 13 / 15 Branchbran 75.0% 3 / 4 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 80.0% 4 / 5 Podpod 100% 2 / 2 totaltotal 62.8% 22 / 35 CC 5 SCAR 16.8
CC
5
Cov
64%
_complete
12.0
type
3.0
BEGIN
1.0
CRAP 5.3
« PPI/Token/_QuoteEngine.pm ↑ Summary PPI/Transform.pm »
1 package PPI::Statement::Scheduled;
2  
3 =pod
4  
5 =head1 NAME
6  
7 PPI::Statement::Scheduled - A scheduled code block
8  
9 =head1 INHERITANCE
10  
11 PPI::Statement::Scheduled
12 isa PPI::Statement::Sub
13 isa PPI::Statement
14 isa PPI::Node
15 isa PPI::Element
16  
17 =head1 DESCRIPTION
18  
19 A scheduled code block is one that is intended to be run at a specific
20 time during the loading process.
21  
22 There are five types of scheduled block:
23  
24 BEGIN {
25 # Executes as soon as this block is fully defined
26 ...
27 }
28  
29 CHECK {
30 # Executes after overall compile-phase in reverse order
31 ...
32 }
33  
34 UNITCHECK {
35 # Executes after compile-phase of individual module in reverse order
36 ...
37 }
38  
39 INIT {
40 # Executes just before run-time
41 ...
42 }
43  
44 END {
45 # Executes as late as possible in reverse order
46 ...
47 }
48  
49 Technically these scheduled blocks are actually subroutines, and in fact
50 may have 'sub' in front of them.
51  
52 =head1 METHODS
53  
54 =cut
55  
56 63 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
57 63 ▶use PPI::Statement::Sub ();
Subroutine BEGIN: called CC=1 SCAR=0.0
58  
59 63 our $VERSION = '1.260'; # VERSION
60  
61 63 our @ISA = "PPI::Statement::Sub";
62  
63 sub __LEXER__normal() { '' }
64  
65 sub _complete {
66 0 ▶ my $child = $_[0]->schild(-1);
Subroutine _complete: not called CC=3 SCAR=24.8
67 return !! (
68 0 ▶ defined $child
Condition0%0/6
defined $child && $child->isa('PPI::Structure::Block') && $child->complete
!ll&&!rl&&r
000
defined $child and $child->isa("PPI::Structure::Block")
!ll&&!rl&&r
000
MC/DC0%0/3
defined $child && $child->isa('PPI::Structure::Block') && $child->complete
defined $child $child->isa("PPI::Structure::Block") $child->complete
Truth table0%0/4
A and B && C
A= defined $childB= $child->isa("PPI::Structure::Block")C= $child->complete
ABCresult
0XX0
10X0
1100
1111
69 and
70 $child->isa('PPI::Structure::Block')
71 and
72 $child->complete
73 );
74 }
75  
76 =pod
77  
78 =head2 type
79  
80 The C<type> method returns the type of scheduled block, which should always be
81 one of C<'BEGIN'>, C<'CHECK'>, C<'UNITCHECK'>, C<'INIT'> or C<'END'>.
82  
83 =cut
84  
85 sub type {
86 85 ▶ my $self = shift;
Subroutine type: called CC=3 SCAR=11.1
Pod documented
87 85 ▶ my @children = $self->schildren or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my(@children) = $self->schildren or return undef 0 85 85
88 85 ▶ $children[0]->content eq 'sub'
Branch: 1 branch
BranchTrueFalseTotal
$children[0]->content eq 'sub' ? : 45 40 85
89 ? $children[1]->content
90 : $children[0]->content;
91 }
92  
93 # This is actually the same as Sub->name
94 sub name {
95 85 ▶ shift->type(@_);
Subroutine name: called CC=1 SCAR=0.0
Pod documented
96 }
97  
98 63 1;
99  
100 =pod
101  
102 =head1 TO DO
103  
104 - Write unit tests for this package
105  
106 =head1 SUPPORT
107  
108 See the L<support section|PPI/SUPPORT> in the main module.
109  
110 =head1 AUTHOR
111  
112 Adam Kennedy E<lt>adamk@cpan.orgE<gt>
113  
114 =head1 COPYRIGHT
115  
116 Copyright 2001 - 2011 Adam Kennedy.
117  
118 This program is free software; you can redistribute
119 it and/or modify it under the same terms as Perl itself.
120  
121 The full text of the license can be found in the
122 LICENSE file included with this module.
123  
124 =cut
« PPI/Token/_QuoteEngine.pm ↑ Summary PPI/Transform.pm »