| 1 | package Zuzu::Value::Array; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 70 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 70 | our $VERSION = '0.007002'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 70 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 70 | ▶ | use Zuzu::Value::Bag; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 70 | ▶ | use Zuzu::Value::Set; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 70 | ▶ | use Zuzu::Value::Equality qw( value_equal ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 70 | ▶ | use Zuzu::Weak qw( slot_value store_value ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 70 | ▶ | use List::Util qw( sum0 ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | has 'items' => ( is => 'rw', default => sub { [] } ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 3616 | ▶ | has 'weak' => ( is => 'rw', default => sub { [] } ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 1262 | ▶ | sub _store_at { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_store_at: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 1262 | my ( $self, $index, $value, $weak ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 1262 | ▶ | $self->weak->[$index] = $weak ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 1262 | store_value( \$self->items->[$index], $value, $weak ); | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 1262 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 48818 | ▶ | sub _value_at { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_value_at: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 48818 | my ( $self, $index ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 48818 | return slot_value( \$self->items->[$index] ); | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 2345 | ▶ | sub resolved_items { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolved_items: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 2345 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 2345 | my @out; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 2345 | ▶ | for ( my $i = 0; $i < @{ $self->items }; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 25014 | push @out, $self->_value_at($i); | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 2345 | return @out; | |||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 1143 | ▶ | sub push { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
push: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 1143 | my ( $self, @vals ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 1143 | for my $value ( @vals ) { | |||||||||||||||||||||||||||||||||||||||||
| 48 | 1225 | my $index = scalar @{ $self->items }; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 1225 | $self->_store_at( $index, $value, 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 1143 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 9 | ▶ | sub push_weak { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
push_weak: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 9 | my ( $self, @vals ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 9 | for my $value ( @vals ) { | |||||||||||||||||||||||||||||||||||||||||
| 59 | 9 | my $index = scalar @{ $self->items }; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 9 | $self->_store_at( $index, $value, 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 9 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub pop { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pop: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | pop @{ $self->weak }; | |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | return pop @{ $self->items }; | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub unshift { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unshift: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my ( $self, @vals ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | CORE::unshift @{ $self->items }, (undef) x @vals; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | CORE::unshift @{ $self->weak }, (0) x @vals; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | for my $i ( 0 .. $#vals ) { | |||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | $self->_store_at( $i, $vals[$i], 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | ▶ | sub unshift_weak { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unshift_weak: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | my ( $self, @vals ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | CORE::unshift @{ $self->items }, (undef) x @vals; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | CORE::unshift @{ $self->weak }, (1) x @vals; | |||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | for my $i ( 0 .. $#vals ) { | |||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | $self->_store_at( $i, $vals[$i], 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | sub shift { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shift: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | shift @{ $self->weak }; | |||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | return shift @{ $self->items }; | |||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | sub clear { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $self->items( [] ); | |||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $self->weak( [] ); | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 5 | ▶ | sub copy { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
copy: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 5 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 5 | my $copy = Zuzu::Value::Array->new( items => [] ); | |||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 5 | ▶ | for ( my $i = 0; $i < @{ $self->items }; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 7 | ▶ | $copy->_store_at( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | $i, | ||||||||||||||||||||||||||||||||||||||||||
| 121 | $self->_value_at($i), | ||||||||||||||||||||||||||||||||||||||||||
| 122 | $self->weak->[$i] ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||
| 123 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 5 | return $copy; | |||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 23721 | ▶ | sub get { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=4 SCAR=16.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 23721 | my ( $self, $index, $default ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 131 | 23721 | ▶ | $index = 0 + ( $index // 0 ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$index // 0
MC/DC0%0/1
$index // 0
$index
Truth table50%1/2
A
A= $index
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | return $self->_value_at($index) | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 23721 | ▶ | if $index >= 0 and $index < @{ $self->items }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$index >= 0 and $index < @{$self->items;}
MC/DC0%0/2
$index >= 0 and $index < @{$self->items;}
$index >= 0
$index < @{$self->items;}
Truth table33%1/3
A and B
A= $index >= 0B= $index < @{$self->items;}
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | return $default; | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 2 | ▶ | sub set { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 2 | my ( $self, $index, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 2 | ▶ | $index = 0 + ( $index // 0 ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$index // 0
MC/DC0%0/1
$index // 0
$index
Truth table50%1/2
A
A= $index
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | $self->_store_at( $index, $value, 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | ▶ | sub set_weak { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_weak: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | my ( $self, $index, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | ▶ | $index = 0 + ( $index // 0 ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$index // 0
MC/DC0%0/1
$index // 0
$index
Truth table50%1/2
A
A= $index
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | $self->_store_at( $index, $value, 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 12 | ▶ | sub map { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
map: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 12 | my ( $self, $mapper ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 12 | my @out = map { $mapper->($_) } $self->resolved_items; | |||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 12 | return Zuzu::Value::Array->new( items => \@out ); | |||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 28 | ▶ | sub grep { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
grep: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 28 | my ( $self, $pred ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 164 | 28 | my @out = grep { $pred->($_) } $self->resolved_items; | |||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 28 | return Zuzu::Value::Array->new( items => \@out ); | |||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | ▶ | sub any { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | my ( $self, $pred ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 171 | 1 | for my $v ( $self->resolved_items ) { | |||||||||||||||||||||||||||||||||||||||||
| 172 | 2 | ▶ | return 1 if $pred->($v); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | ▶ | sub all { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | my ( $self, $pred ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | for my $v ( $self->resolved_items ) { | |||||||||||||||||||||||||||||||||||||||||
| 181 | 3 | ▶ | return 0 if !$pred->($v); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 177 | ▶ | sub first { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
first: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 177 | my ( $self, $pred ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 189 | 177 | for my $v ( $self->resolved_items ) { | |||||||||||||||||||||||||||||||||||||||||
| 190 | 617 | ▶ | return $v if $pred->($v); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 8 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 4 | ▶ | sub remove { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 4 | my ( $self, $pred ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 198 | 4 | my @items; | |||||||||||||||||||||||||||||||||||||||||
| 199 | my @weak; | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 4 | ▶ | for ( my $i = 0 ; $i < @{ $self->items } ; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 10 | my $value = $self->_value_at($i); | |||||||||||||||||||||||||||||||||||||||||
| 202 | 10 | ▶ | next if $pred->($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 5 | CORE::push @items, undef; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 5 | ▶ | CORE::push @weak, $self->weak->[$i] ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 5 | store_value( \$items[-1], $value, $weak[-1] ); | |||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 4 | $self->items( \@items ); | |||||||||||||||||||||||||||||||||||||||||
| 208 | 4 | $self->weak( \@weak ); | |||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 4 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | sub first_index { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
first_index: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my ( $self, $pred ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | for ( my $i = 0 ; $i < @{ $self->items } ; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | return $i if $pred->( $self->_value_at($i) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 2 | ▶ | sub reduce { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reduce: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 2 | my ( $self, $reducer ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 225 | 2 | ▶ | return undef if ! @{ $self->items }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 2 | my $acc = $self->_value_at(0); | |||||||||||||||||||||||||||||||||||||||||
| 228 | 2 | ▶ | for ( my $i = 1 ; $i < @{ $self->items } ; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 4 | $acc = $reducer->( $acc, $self->_value_at($i) ); | |||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | 2 | return $acc; | |||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 1 | ▶ | sub reductions { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reductions: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 1 | my ( $self, $reducer ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 1 | ▶ | return Zuzu::Value::Array->new( items => [] ) if ! @{ $self->items }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 1 | my @out; | |||||||||||||||||||||||||||||||||||||||||
| 240 | 1 | my $acc = $self->_value_at(0); | |||||||||||||||||||||||||||||||||||||||||
| 241 | 1 | CORE::push @out, $acc; | |||||||||||||||||||||||||||||||||||||||||
| 242 | 1 | ▶ | for ( my $i = 1 ; $i < @{ $self->items } ; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 2 | $acc = $reducer->( $acc, $self->_value_at($i) ); | |||||||||||||||||||||||||||||||||||||||||
| 244 | 2 | CORE::push @out, $acc; | |||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 1 | return Zuzu::Value::Array->new( items => \@out ); | |||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | sub sum { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sum: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | my @nums = map { 0 + ( $_ // 0 ) } $self->resolved_items; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_ // 0
MC/DC0%0/1
$_ // 0
$_
Truth table0%0/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | return sum0 @nums; | |||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | sub product { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
product: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | my @nums = map { 0 + ( $_ // 0 ) } $self->resolved_items; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_ // 0
MC/DC0%0/1
$_ // 0
$_
Truth table0%0/2
A
A= $_
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | return List::Util::product @nums; | |||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | sub head { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
head: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | my ( $self, $n ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | $n = 1 if !defined $n; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $n = 0 + $n; | |||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | $n = 0 if $n < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | my @out = $self->resolved_items; | |||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | $#out = $n - 1 if @out > $n; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | return Zuzu::Value::Array->new( items => \@out ); | |||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | sub tail { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tail: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | my ( $self, $n ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | $n = 1 if !defined $n; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | $n = 0 + $n; | |||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | $n = 0 if $n < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my @out = $self->resolved_items; | |||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | @out = () if $n == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | @out = @out[ @out - $n .. $#out ] if @out and $n > 0 and @out > $n; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
@out and $n > 0 and @out > $n
@out and $n > 0
MC/DC0%0/3
@out and $n > 0 and @out > $n
@out
$n > 0
@out > $n
Truth table0%0/4
A and B and C
A= @outB= $n > 0C= @out > $n
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | return Zuzu::Value::Array->new( items => \@out ); | |||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | sub slice { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
slice: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my ( $self, $start, $end ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my @items = $self->resolved_items; | |||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | my $length = scalar @items; | |||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | $start = 0 + ( $start // 0 ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$start // 0
MC/DC0%0/1
$start // 0
$start
Truth table0%0/2
A
A= $start
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | $end = defined $end ? 0 + $end : $length; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | $start += $length if $start < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | $end += $length if $end < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | $start = 0 if $start < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | $end = 0 if $end < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | $start = $length if $start > $length; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | $end = $length if $end > $length; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | my ( $from, $to ) = $start <= $end ? ( $start, $end ) : ( $end, $start ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | my @out = $from < $to ? @items[ $from .. $to - 1 ] : (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | return Zuzu::Value::Array->new( items => \@out ); | |||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | sub shuffle { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shuffle: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my @out = $self->resolved_items; | |||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | for ( my $i = @out - 1 ; $i > 0 ; $i-- ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my $j = int rand( $i + 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | @out[ $i, $j ] = @out[ $j, $i ]; | |||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | return Zuzu::Value::Array->new( items => \@out ); | |||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | sub sample { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sample: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | my ( $self, $n ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | $n = 1 if !defined $n; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | $n = 0 + $n; | |||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | $n = 0 if $n < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | my $shuffled = $self->shuffle; | |||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | return $shuffled->head($n); | |||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | 1 | ▶ | sub for_each_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
for_each_value: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 1 | my ( $self, $callback ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | 1 | for my $v ( $self->resolved_items ) { | |||||||||||||||||||||||||||||||||||||||||
| 334 | 3 | $callback->($v); | |||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | sub to_Iterator { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_Iterator: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my @items = $self->resolved_items; | |||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | my $index = 0; | |||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | die 'ExhaustedException' if $index >= @items; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | my $value = $items[$index]; | |||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | $index++; | |||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | 27 | ▶ | sub sort { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sort: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | 27 | my ( $self, $cmp ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 357 | 27 | my @out = CORE::sort { $cmp->( $a, $b ) } $self->resolved_items; | |||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | 27 | return Zuzu::Value::Array->new( items => \@out ); | |||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 1 | ▶ | sub sortstr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sortstr: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 1 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 364 | my @out = CORE::sort { | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 1 | ▶ | ( defined $a ? "$a" : '' ) cmp ( defined $b ? "$b" : '' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | } $self->resolved_items; | ||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | 1 | return Zuzu::Value::Array->new( items => \@out ); | |||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | 1 | ▶ | sub sortnum { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sortnum: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | 1 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 373 | my @out = CORE::sort { | ||||||||||||||||||||||||||||||||||||||||||
| 374 | 1 | ▶ | ( 0 + ( $a // 0 ) ) <=> ( 0 + ( $b // 0 ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$a // 0
$b // 0
MC/DC0%0/1
$a // 0
$a
MC/DC0%0/1
$b // 0
$b
Truth table50%1/2
A
A= $a
Truth table50%1/2
A
A= $b
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | } $self->resolved_items; | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | 1 | return Zuzu::Value::Array->new( items => \@out ); | |||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 1 | ▶ | sub reverse { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reverse: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | 1 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 382 | 1 | my @out = CORE::reverse $self->resolved_items; | |||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | 1 | return Zuzu::Value::Array->new( items => \@out ); | |||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | 2 | ▶ | sub contains { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
contains: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | 2 | my ( $self, $needle ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | 2 | for my $item ( $self->resolved_items ) { | |||||||||||||||||||||||||||||||||||||||||
| 392 | 5 | ▶ | return 1 if value_equal( $item, $needle ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | sub to_Set { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_Set: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | my $set = Zuzu::Value::Set->new( items => [] ); | |||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | $set->add( $self->resolved_items ); | |||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | return $set; | |||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | 3 | ▶ | sub to_Bag { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_Bag: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | 3 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | 3 | return Zuzu::Value::Bag->new( items => [ $self->resolved_items ] ); | |||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | sub to_Array { $_[0]->copy } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_Array: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | 7647 | ▶ | sub length { scalar @{ $_[0]->items } } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
length: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | 22 | ▶ | sub empty { @{ $_[0]->items } ? 0 : 1 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
empty: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | sub count { $_[0]->length } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | sub is_empty { $_[0]->empty } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_empty: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | 60 | ▶ | sub is_truthy { @{$_[0]->items} ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_truthy: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||
| 426 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | Zuzu::Value::Array - runtime value class for array values | ||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | Wraps runtime array values and provides truthiness semantics for collections. | ||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | =head1 INHERITANCE | ||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | Inherits from C<Moo::Object>. | ||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | =head1 ROLES | ||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | None. | ||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | =head2 items | ||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | Type: B<ArrayRef>. | ||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | Ordered array elements (expressions or runtime values). | ||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | Constructs and returns a new instance of this class. | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | =head2 is_truthy | ||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||
| 458 | Returns this runtime value's truthiness in ZuzuScript. | ||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | =head2 push | ||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | Appends one or more items and returns this array. | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | =head2 pop | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | Removes and returns the final item. | ||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | =head2 unshift | ||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | Prepends one or more items and returns this array. | ||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | =head2 shift | ||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | Removes and returns the first item. | ||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | =head2 clear | ||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||
| 478 | Removes all items and returns this array. | ||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | =head2 length | ||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||
| 482 | Returns the number of items. | ||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | =head2 map | ||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||
| 486 | Returns a new array by mapping each element through a callback. | ||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | =head2 grep | ||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||
| 490 | Returns a new array with elements where callback is true. | ||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||
| 492 | =head2 any | ||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||
| 494 | Returns true if any element satisfies the callback. | ||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||
| 496 | =head2 all | ||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||
| 498 | Returns true if all elements satisfy the callback. | ||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||
| 500 | =head2 first | ||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||
| 502 | Returns the first matching element or undef when none match. | ||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||
| 504 | =head2 remove | ||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | Removes elements where callback returns true. | ||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||
| 508 | =head2 contains | ||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | Returns true when the array contains a matching value. | ||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | =head2 to_Set | ||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||
| 514 | Returns a new set with type-aware unique values from this array. | ||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | =head2 to_Bag | ||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||
| 518 | Returns a new bag containing this array's values. | ||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||
| 520 | =head2 empty | ||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||
| 522 | Returns true when the array has no items. | ||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||
| 524 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||
| 526 | Subclasses: none in this distribution. | ||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | =head1 COPYRIGHT AND LICENCE | ||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||
| 530 | B<< Zuzu::Value::Array >> is copyright Toby Inkster. | ||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||
| 532 | It is free software; you may redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 533 | the terms of either the Artistic License 1.0 or the GNU General Public | ||||||||||||||||||||||||||||||||||||||||||
| 534 | License version 2. | ||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||
| 536 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||
| 538 | 70 | 1; | |||||||||||||||||||||||||||||||||||||||||