Statistics/R/REXP/Environment.pm

filter: Statementstmt 97.7% 44 / 45 Branchbran 83.3% 15 / 18 Conditioncond 66.6% 12 / 18 MC/DCmcdc 45.4% 5 / 11 Subroutinesub 100% 13 / 13 Podpod 50.0% 2 / 4 totaltotal 83.4% 91 / 109 CC 16 SCAR 14.2
CC
16
Cov
88%
BUILD
7.1
BUILDARGS
6.1
name
3.7
CRAP 4.1
« Statistics/R/IO/Base.pm ↑ Summary Statistics/R/IO/ParserState.pm »
1 package Statistics::R::REXP::Environment;
2 # ABSTRACT: an R environment
3 17 $Statistics::R::REXP::Environment::VERSION = '1.0002';
4 17 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 17 ▶use Scalar::Util qw(refaddr blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 17 ▶use Class::Tiny::Antlers qw(-default around);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 17 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 17 extends 'Statistics::R::REXP';
12  
13 17 ▶use constant sexptype => 'ENVSXP';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 has frame => (
16 is => 'ro',
17 344 ▶ default => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
18 { }
19 344 },
20 17 );
21  
22 17 has enclosure => (
23 is => 'ro',
24 );
25  
26  
27 use overload
28 17 ▶ '""' => sub { 'environment '. shift->name };
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
29  
30  
31 475 ▶sub BUILDARGS {
Subroutine BUILDARGS: called CC=6 SCAR=18.2
Pod undocumented
32 475 my $class = shift;
33 475 ▶ if ( scalar @_ == 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @_ == 1) { } 2 473 475
elsif (@_ % 2) { } 1 472 473
34 2 ▶ if ( ref $_[0] eq 'HASH' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 2 2
elsif (builtin::blessed($_[0]) and $_[0]->isa('Statistics::R::REXP::Environment')) { } 1 2 3
35 0 return $_[0];
36 ▶ } elsif ( blessed $_[0] && $_[0]->isa('Statistics::R::REXP::Environment') ) {
Condition66%2/3
builtin::blessed($_[0]) and $_[0]->isa("Statistics::R::REXP::Environment")
!ll&&!rl&&r
101
MC/DC50%1/2
builtin::blessed($_[0]) and $_[0]->isa("Statistics::R::REXP::Environment")
builtin::blessed($_[0]) $_[0]->isa("Statistics::R::REXP::Environment")
Truth table66%2/3
A and B
A= builtin::blessed($_[0])B= $_[0]->isa("Statistics::R::REXP::Environment")
ABresult
0X0
100
111
37 # copy constructor from another environment
38 1 return { frame => $_[0]->frame,
39 enclosure => $_[0]->enclosure };
40 }
41 1 die "Single parameters to new() must be a HASH data"
42 ." or a Statistics::R::REXP::Environment object => ". $_[0] ."\n";
43 }
44 elsif ( @_ % 2 ) {
45 1 die "The new() method for $class expects a hash reference or a key/value list."
46 . " You passed an odd number of arguments\n";
47 }
48 else {
49 472 return {@_};
50 }
51 }
52  
53  
54 472 ▶sub BUILD {
Subroutine BUILD: called CC=7 SCAR=19.7
Pod undocumented
55 472 my ($self, $args) = @_;
56  
57 # Required attribute type
58 die "Attribute 'frame' must be a reference to a hash of REXPs" if ref($self->frame) ne 'HASH' ||
59 472 ▶ grep { ! (blessed($_) && $_->isa('Statistics::R::REXP')) } values(%{$self->frame});
Branch: 1 branch
BranchTrueFalseTotal
if ref $self->frame ne "HASH" or grep {not builtin::blessed($_) && $_->isa("Statistics::R::REXP");} values %{$self->frame;} 1 471 472
Condition66%4/6
ref $self->frame ne "HASH" or grep {not builtin::blessed($_) && $_->isa("Statistics::R::REXP");} values %{$self->frame;}
l!l&&r!l&&!r
01471
builtin::blessed($_) && $_->isa('Statistics::R::REXP')
!ll&&!rl&&r
20578
MC/DC50%1/2
ref $self->frame ne "HASH" or grep {not builtin::blessed($_) && $_->isa("Statistics::R::REXP");} values %{$self->frame;}
ref $self->frame ne "HASH" grep {not builtin::blessed($_) && $_->isa("Statistics::R::REXP");} values %{$self->frame;}
MC/DC50%1/2
builtin::blessed($_) && $_->isa('Statistics::R::REXP')
builtin::blessed($_) $_->isa('Statistics::R::REXP')
Truth table66%2/3
A or B
A= ref $self->frame ne "HASH"B= grep {not builtin::blessed($_) && $_->isa("Statistics::R::REXP");} values %{$self->frame;}
ABresult
1X1
011
000
Truth table66%2/3
A && B
A= builtin::blessed($_)B= $_->isa('Statistics::R::REXP')
ABresult
0X0
100
111
60
61 471 ▶ die "Attribute 'enclosure' must be an instance of Environment" if defined $self->enclosure &&
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->enclosure and not builtin::blessed($self->enclosure) && $self->enclosure->isa("Statistics::R::REXP::Environment") 1 470 471
Condition83%5/6
defined $self->enclosure and not builtin::blessed($self->enclosure) && $self->enclosure->isa("Statistics::R::REXP::Environment")
!ll&&!rl&&r
3331371
builtin::blessed($self->enclosure) && $self->enclosure->isa('Statistics::R::REXP::Environment')
!ll&&!rl&&r
10137
MC/DC66%2/3
defined $self->enclosure and not builtin::blessed($self->enclosure) && $self->enclosure->isa("Statistics::R::REXP::Environment")
defined $self->enclosure builtin::blessed($self->enclosure) $self->enclosure->isa('Statistics::R::REXP::Environment')
Truth table75%3/4
A and not(B && C)
A= defined $self->enclosureB= builtin::blessed($self->enclosure)C= $self->enclosure->isa('Statistics::R::REXP::Environment')
ABCresult
0XX0
1110
10X1
1101
62 !(blessed($self->enclosure) && $self->enclosure->isa('Statistics::R::REXP::Environment'));
63 }
64  
65  
66 252 ▶around _eq => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
67 252 my $orig = shift;
68 252 ▶ return unless $orig->(@_);
Branch: 1 branch
BranchTrueFalseTotal
unless &$orig(@_) 17 235 252
69 235 my ($self, $obj) = (shift, shift);
70 235 ▶ Statistics::R::REXP::_compare_deeply($self->frame, $obj->frame) &&
Branch: 1 branch
BranchTrueFalseTotal
Statistics::R::REXP::_compare_deeply($self->frame, $obj->frame) and Statistics::R::REXP::_compare_deeply($self->enclosure, $obj->enclosure) 235 0 235
71 Statistics::R::REXP::_compare_deeply($self->enclosure, $obj->enclosure)
72 17 };
73  
74  
75 1 ▶sub name {
Subroutine name: called CC=3 SCAR=13.1
Pod documented
76 1 my $self = shift;
77 ($self->attributes && exists $self->attributes->{name}) ?
78 $self->attributes->{name} :
79 1 ▶ '0x' . sprintf('%x', refaddr $self)
Branch: 1 branch
BranchTrueFalseTotal
$self->attributes && exists $self->attributes->{'name'} ? : 0 1 1
Condition33%1/3
$self->attributes and exists $self->attributes->{"name"}
!ll&&!rl&&r
100
MC/DC0%0/2
$self->attributes and exists $self->attributes->{"name"}
$self->attributes exists $self->attributes->{"name"}
Truth table33%1/3
A and B
A= $self->attributesB= exists $self->attributes->{"name"}
ABresult
0X0
100
111
80 }
81  
82  
83 4 ▶sub to_pl {
Subroutine to_pl: called CC=1 SCAR=0.0
Pod documented
84 4 die "Environments do not have a native Perl representation"
85 }
86  
87  
88 17 1; # End of Statistics::R::REXP::Environment
89  
90 __END__
« Statistics/R/IO/Base.pm ↑ Summary Statistics/R/IO/ParserState.pm »