| 1 | package Sub::Meta::Returns; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 32 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 32 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 32 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 32 | our $VERSION = "0.15"; | |||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 32 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | use overload | ||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 32 | ▶ | fallback => 1, | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | eq => \&is_same_interface | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 32 | ; | |||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 248 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 248 | my ($class, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 17 | 248 | my $v = $args[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 18 | 248 | ▶ | my %args = @args == 1 ? ref $v && ref $v eq 'HASH' ? %{$v} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
ref $v and ref $v eq "HASH"
MC/DC100%2/2
ref $v and ref $v eq "HASH"
ref $v
ref $v eq "HASH"
Truth table100%3/3
A and B
A= ref $vB= ref $v eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | : ( scalar => $v, list => $v, void => $v ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | : @args; | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 248 | return bless \%args => $class; | |||||||||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 377 | ▶ | sub scalar() :method { my $self = shift; return $self->{scalar} } ## no critic (ProhibitBuiltinHomonyms) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scalar: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 198 | ▶ | sub list() { my $self = shift; return $self->{list} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 189 | ▶ | sub void() { my $self = shift; return $self->{void} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
void: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 40 | ▶ | sub coerce() { my $self = shift; return $self->{coerce} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coerce: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 340 | ▶ | sub has_scalar() { my $self = shift; return defined $self->{scalar} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_scalar: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 261 | ▶ | sub has_list() { my $self = shift; return defined $self->{list} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_list: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 243 | ▶ | sub has_void() { my $self = shift; return defined $self->{void} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_void: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 38 | ▶ | sub has_coerce() { my $self = shift; return defined $self->{coerce} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_coerce: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | ▶ | sub set_scalar { my ($self, $v) = @_; $self->{scalar} = $v; return $self } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_scalar: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 1 | ▶ | sub set_list { my ($self, $v) = @_; $self->{list} = $v; return $self } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_list: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | ▶ | sub set_void { my ($self, $v) = @_; $self->{void} = $v; return $self } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_void: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | sub set_coerce { my ($self, $v) = @_; $self->{coerce} = $v; return $self } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_coerce: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 53 | ▶ | sub is_same_interface { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_same_interface: called CC=12 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 53 | my ($self, $other) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 53 | ▶ | return unless Scalar::Util::blessed($other) && $other->isa('Sub::Meta::Returns'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
builtin::blessed($other) and $other->isa("Sub::Meta::Returns")
MC/DC100%2/2
builtin::blessed($other) and $other->isa("Sub::Meta::Returns")
builtin::blessed($other)
$other->isa("Sub::Meta::Returns")
Truth table100%3/3
A and B
A= builtin::blessed($other)B= $other->isa("Sub::Meta::Returns")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 51 | ▶ | if ($self->has_scalar) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 25 | ▶ | return unless _eq($self->scalar, $other->scalar) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 26 | ▶ | return if $other->has_scalar | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 34 | ▶ | if ($self->has_list) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 9 | ▶ | return unless _eq($self->list, $other->list) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 25 | ▶ | return if $other->has_list | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 31 | ▶ | if ($self->has_void) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 8 | ▶ | return unless _eq($self->void, $other->void) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 23 | ▶ | return if $other->has_void | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 28 | return !!1; | |||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 60 | ▶ | sub is_relaxed_same_interface { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_relaxed_same_interface: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 60 | my ($self, $other) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 60 | ▶ | return unless Scalar::Util::blessed($other) && $other->isa('Sub::Meta::Returns'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
builtin::blessed($other) and $other->isa("Sub::Meta::Returns")
MC/DC100%2/2
builtin::blessed($other) and $other->isa("Sub::Meta::Returns")
builtin::blessed($other)
$other->isa("Sub::Meta::Returns")
Truth table100%3/3
A and B
A= builtin::blessed($other)B= $other->isa("Sub::Meta::Returns")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 58 | ▶ | if ($self->has_scalar) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 27 | ▶ | return unless _eq($self->scalar, $other->scalar) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 46 | ▶ | if ($self->has_list) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 12 | ▶ | return unless _eq($self->list, $other->list) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 45 | ▶ | if ($self->has_void) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 12 | ▶ | return unless _eq($self->void, $other->void) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 44 | return !!1; | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 16 | ▶ | sub is_same_interface_inlined { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_same_interface_inlined: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 16 | my ($self, $v) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 16 | my @src; | |||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 16 | push @src => sprintf("Scalar::Util::blessed(%s) && %s->isa('Sub::Meta::Returns')", $v, $v); | |||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 16 | ▶ | push @src => $self->has_scalar ? _eq_inlined($self->scalar, sprintf('%s->scalar', $v)) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | : sprintf('!%s->has_scalar', $v); | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 16 | ▶ | push @src => $self->has_list ? _eq_inlined($self->list, sprintf('%s->list', $v)) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | : sprintf('!%s->has_list', $v); | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 16 | ▶ | push @src => $self->has_void ? _eq_inlined($self->void, sprintf('%s->void', $v)) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | : sprintf('!%s->has_void', $v); | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 16 | return join "\n && ", @src; | |||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 20 | ▶ | sub is_relaxed_same_interface_inlined { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_relaxed_same_interface_inlined: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 20 | my ($self, $v) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 20 | my @src; | |||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 20 | push @src => sprintf("Scalar::Util::blessed(%s) && %s->isa('Sub::Meta::Returns')", $v, $v); | |||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 20 | ▶ | push @src => _eq_inlined($self->scalar, sprintf('%s->scalar', $v)) if $self->has_scalar; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 20 | ▶ | push @src => _eq_inlined($self->list, sprintf('%s->list', $v)) if $self->has_list; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 20 | ▶ | push @src => _eq_inlined($self->void, sprintf('%s->void', $v)) if $self->has_void; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 20 | return join "\n && ", @src; | |||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 160 | ▶ | sub _eq { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_eq: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 160 | my ($type, $other) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 160 | ▶ | if (ref $type && ref $type eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $type and ref $type eq "ARRAY"
MC/DC100%2/2
ref $type and ref $type eq "ARRAY"
ref $type
ref $type eq "ARRAY"
Truth table100%3/3
A and B
A= ref $typeB= ref $type eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 11 | ▶ | return unless ref $other eq "ARRAY"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 8 | ▶ | return unless @$type == @$other; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 4 | ▶ | for (my $i = 0; $i < @$type; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 8 | ▶ | return unless $type->[$i] eq $other->[$i]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 149 | ▶ | return unless defined $other && $type eq $other; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $other and $type eq $other
MC/DC100%2/2
defined $other and $type eq $other
defined $other
$type eq $other
Truth table100%3/3
A and B
A= defined $otherB= $type eq $other
| |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 115 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 40 | ▶ | sub _eq_inlined { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_eq_inlined: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 40 | my ($type, $v) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 40 | my @src; | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | 40 | ▶ | if (ref $type && ref $type eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $type and ref $type eq "ARRAY"
MC/DC100%2/2
ref $type and ref $type eq "ARRAY"
ref $type
ref $type eq "ARRAY"
Truth table100%3/3
A and B
A= ref $typeB= ref $type eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 2 | push @src => sprintf('ref %s eq "ARRAY"', $v); | |||||||||||||||||||||||||||||||||||||||||||||
| 146 | 2 | push @src => sprintf('%d == @{%s}', scalar @$type, $v); | |||||||||||||||||||||||||||||||||||||||||||||
| 147 | 2 | ▶ | for (my $i = 0; $i < @$type; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 4 | push @src => sprintf('"%s" eq %s->[%d]', $type->[$i], $v, $i); | |||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 38 | push @src => sprintf('defined %s && "%s" eq %s', $v, $type, $v); | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 40 | return join "\n && ", @src; | |||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 22 | ▶ | sub error_message { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_message: called CC=16 SCAR=27.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 22 | my ($self, $other) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 22 | ▶ | return sprintf('other returns must be Sub::Meta::Returns. got: %s', $other // 'Undef') | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%5/5
builtin::blessed($other) and $other->isa("Sub::Meta::Returns")
$other // "Undef"
MC/DC100%2/2
builtin::blessed($other) and $other->isa("Sub::Meta::Returns")
builtin::blessed($other)
$other->isa("Sub::Meta::Returns")
MC/DC100%1/1
$other // "Undef"
$other
Truth table100%3/3
A and B
A= builtin::blessed($other)B= $other->isa("Sub::Meta::Returns")
Truth table100%2/2
A
A= $other
| |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | unless Scalar::Util::blessed($other) && $other->isa('Sub::Meta::Returns'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 20 | ▶ | if ($self->has_scalar) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 7 | ▶ | return sprintf('invalid scalar return. got: %s, expected: %s', $other->scalar // '', $self->scalar) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$other->scalar // ""
MC/DC100%1/1
$other->scalar // ""
$other->scalar
Truth table100%2/2
A
A= $other->scalar
| |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | unless _eq($self->scalar, $other->scalar); | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 168 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 13 | ▶ | return 'should not have scalar return' if $other->has_scalar; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 14 | ▶ | if ($self->has_list) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 5 | ▶ | return sprintf('invalid list return. got: %s, expected: %s', $other->list // '', $self->list) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$other->list // ""
MC/DC100%1/1
$other->list // ""
$other->list
Truth table100%2/2
A
A= $other->list
| |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | unless _eq($self->list, $other->list); | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 9 | ▶ | return 'should not have list return' if $other->has_list; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 10 | ▶ | if ($self->has_void) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 4 | ▶ | return sprintf('invalid void return. got: %s, expected: %s', $other->void // '', $self->void) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$other->void // ""
MC/DC100%1/1
$other->void // ""
$other->void
Truth table100%2/2
A
A= $other->void
| |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | unless _eq($self->void, $other->void); | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 6 | ▶ | return 'should not have void return' if $other->has_void; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 6 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 21 | ▶ | sub relaxed_error_message { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
relaxed_error_message: called CC=13 SCAR=25.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 21 | my ($self, $other) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 21 | ▶ | return sprintf('other returns must be Sub::Meta::Returns. got: %s', $other // 'Undef') | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%5/5
builtin::blessed($other) and $other->isa("Sub::Meta::Returns")
$other // "Undef"
MC/DC100%2/2
builtin::blessed($other) and $other->isa("Sub::Meta::Returns")
builtin::blessed($other)
$other->isa("Sub::Meta::Returns")
MC/DC100%1/1
$other // "Undef"
$other
Truth table100%3/3
A and B
A= builtin::blessed($other)B= $other->isa("Sub::Meta::Returns")
Truth table100%2/2
A
A= $other
| |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | unless Scalar::Util::blessed($other) && $other->isa('Sub::Meta::Returns'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 19 | ▶ | if ($self->has_scalar) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 7 | ▶ | return sprintf('invalid scalar return. got: %s, expected: %s', $other->scalar // '', $self->scalar) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$other->scalar // ""
MC/DC100%1/1
$other->scalar // ""
$other->scalar
Truth table100%2/2
A
A= $other->scalar
| |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | unless _eq($self->scalar, $other->scalar); | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 16 | ▶ | if ($self->has_list) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 6 | ▶ | return sprintf('invalid list return. got: %s, expected: %s', $other->list // '', $self->list) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$other->list // ""
MC/DC100%1/1
$other->list // ""
$other->list
Truth table100%2/2
A
A= $other->list
| |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | unless _eq($self->list, $other->list); | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 14 | ▶ | if ($self->has_void) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 6 | ▶ | return sprintf('invalid void return. got: %s, expected: %s', $other->void // '', $self->void) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$other->void // ""
MC/DC100%1/1
$other->void // ""
$other->void
Truth table100%2/2
A
A= $other->void
| |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | unless _eq($self->void, $other->void); | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 12 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 19 | ▶ | sub _all_eq { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_all_eq: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 19 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 216 | 19 | ▶ | return $self->has_scalar | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$self->has_scalar && _eq($self->scalar, $self->list) && _eq($self->scalar, $self->void)
$self->has_scalar and _eq($self->scalar, $self->list)
MC/DC100%3/3
$self->has_scalar && _eq($self->scalar, $self->list) && _eq($self->scalar, $self->void)
$self->has_scalar
_eq($self->scalar, $self->list)
_eq($self->scalar, $self->void)
Truth table100%4/4
A and B && C
A= $self->has_scalarB= _eq($self->scalar, $self->list)C= _eq($self->scalar, $self->void)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | && _eq($self->scalar, $self->list) | ||||||||||||||||||||||||||||||||||||||||||||||
| 218 | && _eq($self->scalar, $self->void); | ||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 22 | ▶ | sub _display { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_display: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 22 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 22 | ▶ | if (ref $type && ref $type eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $type and ref $type eq "ARRAY"
MC/DC100%2/2
ref $type and ref $type eq "ARRAY"
ref $type
ref $type eq "ARRAY"
Truth table100%3/3
A and B
A= ref $typeB= ref $type eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 1 | return sprintf('[%s]', join ",", map { $_ . '' } @$type); | |||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 227 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 21 | return $type . ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 36 | ▶ | sub display { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
display: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 36 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 36 | ▶ | if (!$self->has_scalar && !$self->has_list && !$self->has_void) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%6/6
$self->has_scalar || $self->has_list || $self->has_void
$self->has_scalar or $self->has_list
MC/DC100%3/3
$self->has_scalar || $self->has_list || $self->has_void
$self->has_scalar
$self->has_list
$self->has_void
Truth table100%4/4
A or B || C
A= $self->has_scalarB= $self->has_listC= $self->has_void
| |||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 17 | return '*'; | |||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 238 | elsif (_all_eq($self)) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 14 | return _display($self->scalar); | |||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 5 | my @r; | |||||||||||||||||||||||||||||||||||||||||||||
| 243 | 5 | for my $key (qw(scalar list void)) { | |||||||||||||||||||||||||||||||||||||||||||||
| 244 | 15 | my $has = "has_$key"; | |||||||||||||||||||||||||||||||||||||||||||||
| 245 | 15 | ▶ | push @r => "$key => @{[_display($self->$key)]}" if $self->$has; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 5 | return "(@{[join ', ', @r]})"; | |||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 32 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 252 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||