File Coverage

blib/lib/PDL/NiceSlice/FilterUtilCall.pm
Criterion Covered Total %
statement 18 39 46.1
branch 0 12 0.0
condition 0 3 0.0
subroutine 6 8 75.0
pod 0 1 0.0
total 24 63 38.1


line stmt bran cond sub pod time code
1             # This original Filter::Util::Call-based
2             # PDL::NiceSlice engine.
3             #
4 1     1   9 use strict;
  1         2  
  1         42  
5 1     1   7 use warnings;
  1         2  
  1         69  
6 1     1   7 use Filter::Util::Call;
  1         2  
  1         109  
7              
8             {
9 1     1   7 no warnings 'redefine';
  1         3  
  1         609  
10             sub PDL::NiceSlice::FilterUtilCall::make_filter {
11 1     1 0 2 my ($class,$file,$offset) = @_;
12 1         5 my $terminator = terminator_regexp($class);
13             sub {
14 0     0   0 my ($status, $off, $end);
15 0         0 my $count = 0;
16 0         0 my $data = "";
17 0         0 while ($status = filter_read()) {
18 0 0       0 return $status if $status < 0;
19 0 0 0     0 if (defined($terminator) && m/$terminator/) {
20 0         0 $off=1;
21 0         0 last;
22             }
23 0 0       0 if (m/^\s*(__END__|__DATA__)\s*$/) {
24 0         0 $end=$1; $off = 1;
  0         0  
25 0         0 last;
26             }
27 0         0 $data .= $_;
28 0         0 $count++;
29 0         0 $_ = "";
30             }
31 0         0 $_ = $data;
32 0 0       0 $_ = findslice $_ unless $status < 0; # the actual filter
33 0 0       0 $_ .= "no $class;\n" if $off;
34 0 0       0 $_ .= "$end\n" if $end;
35 0         0 return $count;
36 1         11 };
37             }
38             }
39              
40             sub import {
41 1     1   14 my ($class) = @_;
42 1         4 my ($file,$offset) = (caller)[1,2]; # for error reporting
43             ## Parse class name into a regexp suitable for filtration
44 1         6 filter_add(PDL::NiceSlice::FilterUtilCall::make_filter($class, $file, $offset+1));
45             }
46              
47             sub unimport {
48 0     0     filter_del();
49             }
50              
51             1;