Statistics/R/IO/ParserState.pm

filter: Statementstmt 88.6% 39 / 44 Branchbran 50.0% 5 / 10 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 92.3% 12 / 13 Podpod 71.4% 5 / 7 totaltotal 81.0% 64 / 79 CC 7 SCAR 12.6
CC
7
Cov
81%
BUILDARGS
8.5
BUILD
2.1
__ANON__
2.0
CRAP 3.5
« Statistics/R/REXP/Environment.pm ↑ Summary Statistics/R/REXP/Vector.pm »
1 package Statistics::R::IO::ParserState;
2 # ABSTRACT: Current state of the IO parser
3 15 $Statistics::R::IO::ParserState::VERSION = '1.0002';
4 15 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 15 ▶use Class::Tiny::Antlers;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 15 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 has data => (
10 is => 'ro',
11 0 ▶ default => sub { [] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
12 15 );
13  
14 has position => (
15 is => 'ro',
16 973 ▶ default => sub { 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
17 15 );
18  
19 has singletons => (
20 is => 'ro',
21 973 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
22 15 );
23  
24  
25 284186 ▶sub BUILDARGS {
Subroutine BUILDARGS: called CC=6 SCAR=21.4
Pod undocumented
26 284186 my $class = shift;
27 284186 my $attributes = {};
28
29 284186 ▶ if ( scalar @_ == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @_ == 1) { } 0 284186 284186
elsif (@_ % 2) { } 0 284186 284186
30 0 ▶ if ( ref $_[0] eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 0 0
31 0 $attributes = $_[0]
32 }
33 else {
34 0 $attributes->{name} = $_[0]
35 }
36 }
37 elsif ( @_ % 2 ) {
38 0 die "The new() method for $class expects a hash reference or a key/value list."
39 . " You passed an odd number of arguments\n";
40 }
41 else {
42 284186 $attributes = { @_ };
43 }
44  
45 # split strings into a list of individual characters
46 284186 ▶ if (defined $attributes->{data} && !ref($attributes->{data})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $attributes->{"data"} and not ref $attributes->{"data"}) 981 283205 284186
Condition66%2/3
defined $attributes->{"data"} and not ref $attributes->{"data"}
!ll&&!rl&&r
0283205981
MC/DC50%1/2
defined $attributes->{"data"} and not ref $attributes->{"data"}
defined $attributes->{"data"} not ref $attributes->{"data"}
Truth table66%2/3
A and not(B)
A= defined $attributes->{"data"}B= not ref $attributes->{"data"}
ABresult
0X0
100
111
47 981 $attributes->{data} = [split //, $attributes->{data}];
48 }
49
50 $attributes
51 284186 }
52  
53 284186 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=7.2
Pod undocumented
54 284186 my $self = shift;
55
56 284186 ▶ die 'foo' unless ref($self->data) eq 'ARRAY'
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self->data eq "ARRAY" 0 284186 284186
57 }
58  
59 281234 ▶sub at {
Subroutine at: called CC=1 SCAR=0.0
Pod documented
60 281234 my $self = shift;
61 281234 $self->data->[$self->position]
62 }
63  
64 281262 ▶sub next {
Subroutine next: called CC=1 SCAR=0.0
Pod documented
65 281262 my $self = shift;
66
67 ref($self)->new(data => $self->data,
68 position => $self->position+1,
69 281262 singletons => [ @{$self->singletons} ])
70 }
71  
72 1937 ▶sub add_singleton {
Subroutine add_singleton: called CC=1 SCAR=0.0
Pod documented
73 1937 my ($self, $singleton) = (shift, shift);
74  
75 1937 my @new_singletons = @{$self->singletons};
76 1937 push @new_singletons, $singleton;
77 1937 ref($self)->new(data => $self->data,
78 position => $self->position,
79 singletons => [ @new_singletons ])
80 }
81  
82 1633 ▶sub get_singleton {
Subroutine get_singleton: called CC=1 SCAR=0.0
Pod documented
83 1633 my ($self, $singleton_id) = (shift, shift);
84 1633 $self->singletons->[$singleton_id]
85 }
86  
87 279805 ▶sub eof {
Subroutine eof: called CC=1 SCAR=0.0
Pod documented
88 279805 my $self = shift;
89 279805 $self->position >= scalar @{$self->data};
90 }
91  
92
93 15 1;
94  
95 __END__
« Statistics/R/REXP/Environment.pm ↑ Summary Statistics/R/REXP/Vector.pm »