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

filter: Statementstmt 100% 32 / 32 Branchbran 100% 4 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 2 / 2 Podpod 100% 1 / 1 totaltotal 95.2% 40 / 42 CC 6 SCAR 16.7
CC
6
Cov
97%
print
6.0
BEGIN
1.0
CRAP 5.3
« blib/lib/Erlang/Parser/Node/FunLocalCase.pm ↑ Summary blib/lib/Erlang/Parser/Node/WhenList.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::Def;
6  
7 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 with 'Erlang::Parser::Node';
9  
10 4 has 'def' => (is => 'rw', required => 1, isa => 'Str');
11 4 has 'args' => (is => 'rw', required => 1, isa => 'ArrayRef[Erlang::Parser::Node]');
12 4 has 'whens' => (is => 'rw', required => 1, isa => 'Erlang::Parser::Node::WhenList');
13 4 has 'stmts' => (is => 'rw', required => 1, isa => 'ArrayRef[Erlang::Parser::Node]');
14  
15 sub print {
16 3238 ▶ my ($self, $fh, $depth) = @_;
Subroutine print: called CC=6 SCAR=17.9
Pod documented
17 3238 ▶ $depth ||= 0;
Condition50%1/2
$depth ||= 0
l!l
03238
MC/DC0%0/1
$depth ||= 0
$depth
Truth table50%1/2
A
A= $depth
Aresult
11
00
18  
19 3238 print $fh $self->def, '(';
20  
21 3238 my $first = 1;
22 3238 foreach (@{$self->args}) {
23 4618 ▶ if ($first) { $first = 0 } else { print $fh ', ' }
Branch: 1 branch
BranchTrueFalseTotal
if ($first) { } 2836 1782 4618
24 4618 $_->print($fh, $depth);
25 }
26
27 3238 $depth++;
28  
29 3238 print $fh ") ";
30  
31 3238 $self->whens->print($fh, $depth);
32
33 3238 print $fh "->\n", "\t" x $depth;
34 3238 $first = 1;
35 3238 foreach (@{$self->stmts}) {
36 5564 ▶ if ($first) { $first = 0 } else { print $fh ",\n", "\t" x $depth }
Branch: 1 branch
BranchTrueFalseTotal
if ($first) { } 3238 2326 5564
37 5564 $_->print($fh, $depth);
38 }
39  
40 3238 $depth--;
41 }
42  
43 4 __PACKAGE__->meta->make_immutable;
44  
45 =head1 NAME
46  
47 Erlang::Parser::Node::Def - a match in a function definition
48  
49 =head1 DESCRIPTION
50  
51 Contains a single pattern match and guard expr/seq list, with the body of the
52 function.
53  
54 =head2 Accessors
55  
56 =over 4
57  
58 =item C<def>
59  
60 The name of the function.
61  
62 =item C<args>
63  
64 A list of L<Erlang::Parser::Node>s which constitute the argument patterns to be
65 matched.
66  
67 =item C<whens>
68  
69 The L<Erlang::Parser::Node::WhenList> containing guard expressions/sequences.
70  
71 =item C<stmts>
72  
73 A list of L<Erlang::Parser::Node>s; the body for the function.
74  
75 =back
76  
77 =head2 Methods
78  
79 =over 4
80  
81 =item C<print>
82  
83 Pretty-prints the node to its filehandle argument.
84  
85 =back
86  
87 =head1 EXAMPLE
88  
89 x(Y) ->
90 Z = Y + Y,
91 Z * 2
92  
93 =cut
94  
95 4 1;
96  
97 # vim: set sw=4 ts=4:
« blib/lib/Erlang/Parser/Node/FunLocalCase.pm ↑ Summary blib/lib/Erlang/Parser/Node/WhenList.pm »