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

filter: Statementstmt 100% 27 / 27 Branchbran 100% 4 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 2 / 2 Podpod 100% 1 / 1 totaltotal 94.5% 35 / 37 CC 5 SCAR 14.7
CC
5
Cov
97%
print
5.0
BEGIN
1.0
CRAP 4.3
« blib/lib/Erlang/Parser/Node/Receive.pm ↑ Summary blib/lib/Erlang/Parser/Node/List.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::Alt;
6  
7 3 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 with 'Erlang::Parser::Node';
9  
10 3 has 'catch' => (is => 'rw', required => 0, isa => 'Bool');
11 3 has 'class' => (is => 'rw', required => 0, isa => 'Maybe[Str]');
12 3 has 'expr' => (is => 'rw', required => 1, isa => 'Erlang::Parser::Node');
13 3 has 'whens' => (is => 'rw', required => 1, isa => 'Erlang::Parser::Node::WhenList');
14 3 has 'stmts' => (is => 'rw', required => 1, isa => 'ArrayRef[Erlang::Parser::Node]');
15  
16 1366 ▶sub print {
Subroutine print: called CC=5 SCAR=16.1
Pod documented
17 1366 my ($self, $fh, $depth) = @_;
18 1366 ▶ $depth ||= 0;
Condition50%1/2
$depth ||= 0
l!l
13660
MC/DC0%0/1
$depth ||= 0
$depth
Truth table50%1/2
A
A= $depth
Aresult
11
00
19  
20 1366 ▶ print $fh $self->class, ':' if defined($self->class);
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->class 50 1316 1366
21 1366 $self->expr->print($fh, $depth);
22 1366 $depth++;
23 1366 print $fh ' ';
24  
25 1366 $self->whens->print($fh, $depth);
26
27 1366 print $fh "->\n", "\t" x $depth;
28  
29 1366 my $first = 1;
30 1366 foreach (@{$self->stmts}) {
31 1702 ▶ if ($first) { $first = 0 } else { print $fh ",\n", "\t" x $depth }
Branch: 1 branch
BranchTrueFalseTotal
if ($first) { } 1366 336 1702
32 1702 $_->print($fh, $depth);
33 }
34  
35 1366 $depth--;
36 }
37  
38 3 __PACKAGE__->meta->make_immutable;
39  
40 =head1 NAME
41  
42 Erlang::Parser::Node::Alt - an alternative in a case or try
43  
44 =head1 DESCRIPTION
45  
46 One alternative (the catch class (if any), pattern match, guards (if any) and
47 expressions) in a case or try statement.
48  
49 =head2 Accessors
50  
51 =over 4
52  
53 =item C<catch>
54  
55 True if this is a case in a catch clause. If so, it will also possess the
56 C<class> attribute.
57  
58 =item C<class>
59  
60 The class in the pattern match; the 'Z' in try X catch Y:Z -> ... end.
61  
62 =item C<expr>
63  
64 The L<Erlang::Parser::Node> pattern match expression.
65  
66 =item C<whens>
67  
68 A L<Erlang::Parser::Node::WhenList> of guard sequences/expressions, if any.
69  
70 =item C<stmts>
71  
72 A list of L<Erlang::Parser::Node>s; the body executed for this alternative.
73  
74 =back
75  
76 =head2 Methods
77  
78 =over 4
79  
80 =item C<print>
81  
82 Pretty-prints the node to its filehandle argument.
83  
84 =back
85  
86 =head1 EXAMPLE
87  
88 {X, Y} when is_bool(X) ->
89 Z = Y + Y,
90 Z * 2
91  
92 =cut
93  
94 3 1;
95  
96 # vim: set sw=4 ts=4:
« blib/lib/Erlang/Parser/Node/Receive.pm ↑ Summary blib/lib/Erlang/Parser/Node/List.pm »