App/Chart/Series/Func.pm untested

filter: Statementstmt 0.0% 0 / 44 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 61 CC 3 SCAR 14.6
CC
3
Cov
0%
fill_part
12.0
new
2.0
BEGIN
2.0
CRAP 4.3
1 # Copyright 2008, 2009, 2010 Kevin Ryde
2  
3 # This file is part of Chart.
4 #
5 # Chart is free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation; either version 3, or (at your option) any later version.
8 #
9 # Chart is distributed in the hope that it will be useful, but WITHOUT ANY
10 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 # details.
13 #
14 # You should have received a copy of the GNU General Public License along
15 # with Chart. If not, see <http://www.gnu.org/licenses/>.
16  
17 package App::Chart::Series::Func;
18 use 5.010;
19 use strict;
20 use warnings;
21 use Carp;
22 use List::Util qw(min max);
23 use Scalar::Util;
24  
25 use App::Chart::Database;
26 use App::Chart::TZ;
27 use base 'App::Chart::Series';
28  
29 # uncomment this to run the ### lines
30 #use Smart::Comments '###';
31  
32 sub new {
33 my ($class, $parent, $func) = @_;
34 ### Func new: "@_"
35 return $class->SUPER::new (parent => $parent,
36 func => $func);
37 }
38  
39 sub fill_part {
40 ### Func fill_part(): "@_"
41 my ($self, $lo, $hi) = @_;
42 my $parent = $self->{'parent'};
43 my $func = $self->{'func'};
44  
45 $parent->fill ($lo, $hi);
46 my $arrays = $self->{'arrays'};
47 while (my ($aname, $s) = each %$arrays) {
48 my $p = $parent->array($aname);
49  
50 my $hi = min ($hi, $#$p);
51 if ($#$s < $hi) { $#$s = $hi; } # pre-extend
52  
53 foreach my $i ($lo .. $hi) {
54 if (defined $p->[$i]) {
55 $s->[$i] = &$func ($p->[$i]);
56 }
57 }
58 }
59 }
60  
61 1;
62 __END__