File Coverage

blib/lib/Erlang/Parser/Node/FunLocalCase.pm
Criterion Covered Total %
statement 23 23 100.0
branch 4 4 100.0
condition 1 2 50.0
subroutine 2 2 100.0
pod 1 1 100.0
total 31 32 96.8


line stmt bran cond sub pod time code
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::FunLocalCase;
6              
7 3     3   9 use Moose;
  3         5  
  3         15  
8             with 'Erlang::Parser::Node';
9              
10             has 'args' => (is => 'rw', required => 1, isa => 'ArrayRef[Erlang::Parser::Node]');
11             has 'whens' => (is => 'rw', required => 1, isa => 'Erlang::Parser::Node::WhenList');
12             has 'stmts' => (is => 'rw', required => 1, isa => 'ArrayRef[Erlang::Parser::Node]');
13              
14             sub print {
15 266     266 1 314 my ($self, $fh, $depth) = @_;
16 266   50     461 $depth ||= 0;
17              
18 266         476 print $fh '(';
19 266         282 my $first = 1;
20 266         289 foreach (@{$self->args}) {
  266         6986  
21 314 100       468 if ($first) { $first = 0 } else { print $fh ', ' }
  244         308  
  70         120  
22 314         716 $_->print($fh, $depth);
23             }
24              
25 266         398 print $fh ') ';
26              
27 266         7156 $self->whens->print($fh, $depth);
28            
29 266         465 print $fh '-> ';
30 266         358 $first = 1;
31 266         263 foreach (@{$self->stmts}) {
  266         6883  
32 392 100       547 if ($first) { $first = 0 } else { print $fh ', ' }
  266         348  
  126         166  
33 392         995 $_->print($fh, $depth);
34             }
35             }
36              
37             __PACKAGE__->meta->make_immutable;
38              
39             =head1 NAME
40              
41             Erlang::Parser::Node::FunLocalCase - one case in a local fun
42              
43             =head1 DESCRIPTION
44              
45             To L<Erlang::Parser::Node::FunLocal> as L<Erlang::Parser::Node::Def> is to
46             L<Erlang::Parser::Node::DefList>.
47              
48             =head2 Accessors
49              
50             =over 4
51              
52             =item C<args>
53              
54             A list of L<Erlang::Parser::Node>s which constitute the argument patterns to be
55             matched.
56              
57             =item C<whens>
58              
59             The L<Erlang::Parser::Node::WhenList> containing guard expressions/sequences.
60              
61             =item C<stmts>
62              
63             A list of L<Erlang::Parser::Node>s; the body for the function.
64              
65             =back
66              
67             =head2 Methods
68              
69             =over 4
70              
71             =item C<print>
72              
73             Pretty-prints the node to its filehandle argument.
74              
75             =back
76              
77             =head1 EXAMPLE
78              
79             (X) when is_bool(X) -> 4
80              
81             =cut
82              
83             1;
84              
85             # vim: set sw=4 ts=4: