File Coverage

blib/lib/Statistics/R/REXP/List.pm
Criterion Covered Total %
statement 38 39 97.4
branch 9 10 90.0
condition 4 6 66.6
subroutine 10 10 100.0
pod 1 1 100.0
total 62 66 93.9


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.0001';
4 24     24   34490 use 5.010;
  24         52  
5              
6 24     24   76 use Scalar::Util qw(blessed weaken);
  24         24  
  24         985  
7              
8 24     24   934 use Class::Tiny::Antlers;
  24         7866  
  24         115  
9 24     24   2780 use namespace::clean;
  24         18944  
  24         94  
10              
11             extends 'Statistics::R::REXP::Vector';
12 24     24   6371 use overload;
  24         2794  
  24         126  
13              
14              
15 24     24   770 use constant sexptype => 'VECSXP';
  24         29  
  24         5856  
16              
17             sub _to_s {
18 278     278   261 my $self = shift;
19            
20 278         210 my ($u, $unfold);
21             $u = $unfold = sub {
22 293     293   1109 join(', ', map { ref $_ eq ref [] ?
23 696 100       2328 '[' . &$unfold(@{$_}) . ']' :
  15 100       37  
24             (defined $_? $_ : 'undef') } @_);
25 278         820 };
26 278         492 weaken $unfold;
27 278         464 $self->_type . '(' . &$unfold(@{$self->elements}) . ')';
  278         4498  
28             }
29              
30              
31             sub to_pl {
32 6     6 1 860 my $self = shift;
33             [ map {
34 16 100 66     73 if (blessed $_ && $_->can('to_pl')) {
35 6         12 my $x = $_->to_pl;
36 6 50       12 if (ref $x eq ref []) {
37 6 100 66     4 unless (scalar @{$x} > 1 ||
38             $_->isa('Statistics::R::REXP::List')) {
39 4         4 @{$x}
  4         11  
40             } else {
41 2         3 $x
42             }
43             } else {
44 0         0 $x
45             }
46             } else {
47 10         21 $_
48             }
49 6         6 } @{$self->elements} ]
  6         127  
50             }
51              
52              
53 234     234   400 sub _type { 'list'; }
54              
55              
56             1; # End of Statistics::R::REXP::List
57              
58             __END__