File Coverage

blib/lib/Statistics/R/REXP/List.pm
Criterion Covered Total %
statement 39 40 97.5
branch 9 10 90.0
condition 4 6 66.6
subroutine 10 10 100.0
pod 1 1 100.0
total 63 67 94.0


line stmt bran cond sub pod time code
1             package Statistics::R::REXP::List;
2             # ABSTRACT: an R generic vector (list)
3             $Statistics::R::REXP::List::VERSION = '1.0002';
4 24     24   96601 use 5.010;
  24         81  
5              
6 24     24   122 use Scalar::Util qw(blessed weaken);
  24         48  
  24         1145  
7              
8 24     24   706 use Class::Tiny::Antlers;
  24         6065  
  24         146  
9 24     24   3378 use namespace::clean;
  24         17986  
  24         165  
10              
11             extends 'Statistics::R::REXP::Vector';
12 24     24   8404 use overload;
  24         2775  
  24         153  
13              
14              
15 24     24   983 use constant sexptype => 'VECSXP';
  24         44  
  24         6471  
16              
17             sub _to_s {
18 278     278   417 my $self = shift;
19            
20 278         464 my ($u, $unfold);
21             $u = $unfold = sub {
22 293     293   1663 join(', ', map { ref $_ eq ref [] ?
23 696 100       2646 '[' . &$unfold(@{$_}) . ']' :
  15 100       44  
24             (defined $_? $_ : 'undef') } @_);
25 278         1056 };
26 278         877 weaken $unfold;
27 278         643 $self->_type . '(' . &$unfold(@{$self->elements}) . ')';
  278         4725  
28             }
29              
30              
31             sub to_pl {
32 6     6 1 903 my $self = shift;
33             [ map {
34 16 100 66     83 if (blessed $_ && $_->can('to_pl')) {
35 6         18 my $x = $_->to_pl;
36 6 50       19 if (ref $x eq ref []) {
37 6 100 66     8 unless (scalar @{$x} > 1 ||
  6         30  
38             $_->isa('Statistics::R::REXP::List')) {
39 4         4 @{$x}
  4         15  
40             } else {
41 2         7 $x
42             }
43             } else {
44 0         0 $x
45             }
46             } else {
47 10         28 $_
48             }
49 6         7 } @{$self->elements} ]
  6         124  
50             }
51              
52              
53 234     234   567 sub _type { 'list'; }
54              
55              
56             1; # End of Statistics::R::REXP::List
57              
58             __END__