blib/lib/Erlang/Parser/Node/If.pm

filter: Statementstmt 100% 21 / 21 Branchbran 100% 2 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 2 / 2 Podpod 100% 1 / 1 totaltotal 93.1% 27 / 29 CC 4 SCAR 12.2
CC
4
Cov
96%
print
4.0
BEGIN
1.0
CRAP 3.4
« blib/lib/Erlang/Parser/Node/Begin.pm ↑ Summary blib/lib/Erlang/Parser/Node/ReceiveAfter.pm »
1 # Copyright 2011-2012 Yuki Izumi. ( anneli AT cpan DOT org )
2 # This is free software; you can redistribute it and/or modify it under the
3 # same terms as Perl itself.
4  
5 package Erlang::Parser::Node::If;
6  
7 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 with 'Erlang::Parser::Node';
9  
10 4 has 'cases' => (is => 'rw', required => 1, isa => 'ArrayRef[Erlang::Parser::Node::IfExpr]');
11  
12 sub print {
13 4 ▶ my ($self, $fh, $depth) = @_;
Subroutine print: called CC=4 SCAR=13.9
Pod documented
14 4 ▶ $depth ||= 0;
Condition50%1/2
$depth ||= 0
l!l
40
MC/DC0%0/1
$depth ||= 0
$depth
Truth table50%1/2
A
A= $depth
Aresult
11
00
15  
16 4 print $fh "if\n";
17  
18 4 $depth++;
19 4 print $fh "\t" x $depth;
20 4 my $first = 1;
21 4 foreach (@{$self->cases}) {
22 8 ▶ if ($first) { $first = 0 } else { print $fh ";\n", "\t" x $depth }
Branch: 1 branch
BranchTrueFalseTotal
if ($first) { } 4 4 8
23 8 $_->print($fh, $depth);
24 }
25  
26 4 $depth--;
27 4 print $fh "\n", "\t" x $depth, "end";
28 }
29  
30 4 __PACKAGE__->meta->make_immutable;
31  
32 =head1 NAME
33  
34 Erlang::Parser::Node::If - an 'if' statement
35  
36 =head1 DESCRIPTION
37  
38 A list of guards and statement blocks to execute if one is true.
39  
40 =head2 Accessors
41  
42 =over 4
43  
44 =item C<cases>
45  
46 A list of L<Erlang::Parser::Node::IfExpr>s.
47  
48 =back
49  
50 =head2 Methods
51  
52 =over 4
53  
54 =item C<print>
55  
56 Pretty-prints the node to its filehandle argument.
57  
58 =back
59  
60 =head1 EXAMPLE
61  
62 if
63 X>Y ->
64 true;
65 true ->
66 false
67 end
68  
69 =cut
70  
71 4 1;
72  
73 # vim: set sw=4 ts=4:
« blib/lib/Erlang/Parser/Node/Begin.pm ↑ Summary blib/lib/Erlang/Parser/Node/ReceiveAfter.pm »