| 1 | package Number::Extreme; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use 5.008_001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | our $VERSION = '0.29'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | use overload | ||||||||||||||||||||||||||||
| 8 | 0 | ▶ | '"0+"' => sub { $_[0]{current_value} }, | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.1
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | '""' => sub { $_[0]{current_value} }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 3 | fallback => 1; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 13 | 2 | my ($class, %args) = @_; | |||||||||||||||||||||||||||
| 14 | 2 | bless \%args, __PACKAGE__; | |||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 2 | ▶ | sub max { | ||||||||||||||||||||||||||
|
Subroutine
max: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 18 | 2 | my $class = shift; | |||||||||||||||||||||||||||
| 19 | 2 | my $extractor = shift; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | return $class->new( | ||||||||||||||||||||||||||||
| 22 | 198 | ▶ | cmp => sub { $_[1] > $_[0] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 2 | extractor => $extractor, | |||||||||||||||||||||||||||
| 24 | current_value => undef, | ||||||||||||||||||||||||||||
| 25 | current => undef, | ||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | sub min { | ||||||||||||||||||||||||||
|
Subroutine
min: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 30 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 31 | 0 | my $extractor = shift; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | return $class->new( | ||||||||||||||||||||||||||||
| 34 | 0 | ▶ | cmp => sub { $_[1] < $_[0] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 35 | 0 | extractor => $extractor, | |||||||||||||||||||||||||||
| 36 | current_value => undef, | ||||||||||||||||||||||||||||
| 37 | current => undef, | ||||||||||||||||||||||||||||
| 38 | @_, | ||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 1 | ▶ | sub amax { | ||||||||||||||||||||||||||
|
Subroutine
amax: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | 1 | my ($class, $array) = @_; | |||||||||||||||||||||||||||
| 44 | 1 | ▶ | $class->max(sub { $array->[$_] }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | ▶ | sub amin { | ||||||||||||||||||||||||||
|
Subroutine
amin: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 48 | 0 | my ($class, $array) = @_; | |||||||||||||||||||||||||||
| 49 | 0 | ▶ | $class->min(sub { $array->[$_] }); | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 200 | ▶ | sub test { | ||||||||||||||||||||||||||
|
Subroutine
test: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 53 | 200 | my ($self, $object) = @_; | |||||||||||||||||||||||||||
| 54 | 200 | local $_ = $object; | |||||||||||||||||||||||||||
| 55 | 200 | ▶ | my $value = $self->{extractor} ? $self->{extractor}->() : $_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 200 | ▶ | if (!defined $self->{current_value} || | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $self->{"current_value"} or $self->{"cmp"}->($self->{"current_value"}, $value)
MC/DC100%2/2
not defined $self->{"current_value"} or $self->{"cmp"}->($self->{"current_value"}, $value)
not defined $self->{"current_value"}
$self->{"cmp"}->($self->{"current_value"}, $value)
Truth table100%3/3
not(A) or B
A= not defined $self->{"current_value"}B= $self->{"cmp"}->($self->{"current_value"}, $value)
| |||||||||||||||||||||||||||||
| 58 | $self->{cmp}->($self->{current_value}, $value)) { | ||||||||||||||||||||||||||||
| 59 | 11 | $self->{current} = $_; | |||||||||||||||||||||||||||
| 60 | 11 | $self->{current_value} = $value; | |||||||||||||||||||||||||||
| 61 | 11 | return 1; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 2 | ▶ | sub current_value { $_[0]->{current_value} } | ||||||||||||||||||||||||||
|
Subroutine
current_value: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 66 | 2 | ▶ | sub current { $_[0]->{current} } | ||||||||||||||||||||||||||
|
Subroutine
current: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 3 | 1; | |||||||||||||||||||||||||||
| 69 | __END__ | ||||||||||||||||||||||||||||