File Coverage

blib/lib/Erlang/Parser/Node/FunLocal.pm
Criterion Covered Total %
statement 14 14 100.0
branch 2 2 100.0
condition 1 2 50.0
subroutine 2 2 100.0
pod 1 1 100.0
total 20 21 95.2


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::FunLocal;
6              
7 3     3   12 use Moose;
  3         4  
  3         30  
8             with 'Erlang::Parser::Node';
9              
10             has 'cases' => (is => 'rw', required => 1, isa => 'ArrayRef[Erlang::Parser::Node::FunLocalCase]');
11              
12             sub print {
13 236     236 1 325 my ($self, $fh, $depth) = @_;
14 236   50     454 $depth ||= 0;
15              
16 236         384 print $fh 'fun ';
17              
18 236         259 my $first = 1;
19 236         354 foreach (@{$self->cases}) {
  236         6538  
20 266 100       497 if ($first) { $first = 0 } else { print $fh '; ' }
  236         271  
  30         57  
21              
22 266         968 $_->print($fh, $depth);
23             }
24              
25 236         563 print $fh ' end';
26             }
27              
28             __PACKAGE__->meta->make_immutable;
29              
30             =head1 NAME
31              
32             Erlang::Parser::Node::FunLocal - a lambda-style local fun
33              
34             =head1 DESCRIPTION
35              
36             A lambda-ish local fun definition, comprised of multiple cases; see
37             L<Erlang::Parser::Node::DefList>.
38              
39             =head2 Accessors
40              
41             =over 4
42              
43             =item C<cases>
44              
45             A list of L<Erlang::Parser::Node::FunLocalCase>s.
46              
47             =back
48              
49             =head2 Methods
50              
51             =over 4
52              
53             =item C<print>
54              
55             Pretty-prints the node to its filehandle argument.
56              
57             =back
58              
59             =head1 EXAMPLE
60              
61             fun (0) -> 1; (N) -> N + 1 end % wtf does this do
62              
63             =cut
64              
65             1;
66              
67             # vim: set sw=4 ts=4: