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

filter: Statementstmt 100% 24 / 24 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.1% 32 / 34 CC 5 SCAR 14.7
CC
5
Cov
97%
print
5.0
BEGIN
1.0
CRAP 4.3
« blib/lib/Erlang/Parser/Node/WhenList.pm ↑ Summary blib/lib/Erlang/Parser/Node/Alt.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::Receive;
6  
7 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 with 'Erlang::Parser::Node';
9  
10 4 has 'alts' => (is => 'rw', required => 1, isa => 'ArrayRef[Erlang::Parser::Node::Alt]');
11 4 has 'aft' => (is => 'rw', required => 0, isa => 'Maybe[Erlang::Parser::Node::ReceiveAfter]');
12  
13 sub print {
14 8 ▶ my ($self, $fh, $depth) = @_;
Subroutine print: called CC=5 SCAR=16.1
Pod documented
15 8 ▶ $depth ||= 0;
Condition50%1/2
$depth ||= 0
l!l
80
MC/DC0%0/1
$depth ||= 0
$depth
Truth table50%1/2
A
A= $depth
Aresult
11
00
16  
17 8 print $fh "receive\n";
18  
19 8 $depth++;
20  
21 8 print $fh "\t" x $depth;
22  
23 8 my $first = 1;
24 8 foreach (@{$self->alts}) {
25 30 ▶ if ($first) { $first = 0 } else { print $fh ";\n", "\t" x $depth }
Branch: 1 branch
BranchTrueFalseTotal
if ($first) { } 8 22 30
26 30 $_->print($fh ,$depth);
27 }
28  
29 8 $depth--;
30 8 print $fh "\n", "\t" x $depth;
31
32 8 ▶ $self->aft->print($fh, $depth) if defined $self->aft;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->aft 6 2 8
33
34 8 print $fh "\n", "\t" x $depth, "end";
35 }
36  
37 4 __PACKAGE__->meta->make_immutable;
38  
39 =head1 NAME
40  
41 Erlang::Parser::Node::Receive - a receive statement
42  
43 =head1 DESCRIPTION
44  
45 Receives a message from the mailbox which matches any pattern (and guard);
46 optionally with a timeout.
47  
48 =head2 Accessors
49  
50 =over 4
51  
52 =item C<alts>
53  
54 A list of L<Erlang::Parser::Node::Alt>s which are matched against the process
55 mailbox.
56  
57 =item C<aft>
58  
59 An optional L<Erlang::Parser::Node::ReceiveAfter>.
60  
61 =back
62  
63 =head2 Methods
64  
65 =over 4
66  
67 =item C<print>
68  
69 Pretty-prints the node to its filehandle argument.
70  
71 =back
72  
73 =head1 EXAMPLE
74  
75 receive
76 {X, Y} when is_bool(X) ->
77 X;
78 {X, Y, Z} ->
79 Y + Z;
80 _ ->
81 io:format("wth~n", [])
82 after
83 10000 ->
84 {error, timeout}
85 end
86  
87 =cut
88  
89 4 1;
90  
91 # vim: set sw=4 ts=4:
« blib/lib/Erlang/Parser/Node/WhenList.pm ↑ Summary blib/lib/Erlang/Parser/Node/Alt.pm »