| 1 | 2 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | package LINQ::FieldSet::Assertion; | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 9 | ▶ | my $_process_args = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 9 | require Scalar::Util; | |||||||||||||||||||||||||||||||||||||||||
| 9 | 9 | ▶ | if ( Scalar::Util::blessed( $_[0] ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
builtin::blessed($_[0]) and builtin::blessed($_[1]) and @_ < 4
builtin::blessed($_[0]) and builtin::blessed($_[1])
MC/DC33%1/3
builtin::blessed($_[0]) and builtin::blessed($_[1]) and @_ < 4
builtin::blessed($_[0])
builtin::blessed($_[1])
@_ < 4
Truth table50%2/4
A and B and C
A= builtin::blessed($_[0])B= builtin::blessed($_[1])C= @_ < 4
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | and Scalar::Util::blessed( $_[1] ) | ||||||||||||||||||||||||||||||||||||||||||
| 11 | and @_ < 4 ) | ||||||||||||||||||||||||||||||||||||||||||
| 12 | { | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | return $_[2] ? ( $_[1], $_[0] ) : ( $_[0], $_[1] ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 6 | my ( $self, @other ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 6 | my $other = __PACKAGE__->new( @other ); | |||||||||||||||||||||||||||||||||||||||||
| 18 | 6 | return ( $self, $other ); | |||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | our $VERSION = '0.003'; | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use Class::Tiny; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | use parent qw( LINQ::FieldSet ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | use LINQ::Util::Internal (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | ▶ | use overload ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 'fallback' => !!1, | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | q[bool] => sub { !! 1 }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | q[""] => 'to_string', | |||||||||||||||||||||||||||||||||||||||||
| 33 | q[&{}] => 'coderef', | ||||||||||||||||||||||||||||||||||||||||||
| 34 | q[|] => 'or', | ||||||||||||||||||||||||||||||||||||||||||
| 35 | q[&] => 'and', | ||||||||||||||||||||||||||||||||||||||||||
| 36 | q[~] => 'not', | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 41 | ▶ | sub _known_parameter_names { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_known_parameter_names: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 41 | my ( $self ) = ( shift ); | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 41 | $self->SUPER::_known_parameter_names, | |||||||||||||||||||||||||||||||||||||||||
| 44 | 'is' => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 'in' => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 'like' => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 'match' => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 'to' => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 'cmp' => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 'numeric' => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 'string' => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 'nix' => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 'nocase' => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 55 | } #/ sub _known_parameter_names | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 69 | ▶ | sub coderef { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coderef: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 69 | my ( $self ) = ( shift ); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 69 | ▶ | $self->{coderef} ||= $self->_build_coderef; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$self->{"coderef"} ||= $self->_build_coderef
MC/DC100%2/2
$self->{"coderef"} ||= $self->_build_coderef
$self->{"coderef"}
$self->_build_coderef
Truth table100%3/3
A ||= B
A= $self->{"coderef"}B= $self->_build_coderef
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 41 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 41 | my ( $self ) = ( shift ); | |||||||||||||||||||||||||||||||||||||||||
| 64 | 41 | ▶ | if ( $self->seen_asterisk ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | LINQ::Util::Internal::throw( | |||||||||||||||||||||||||||||||||||||||||
| 66 | "CallerError", | ||||||||||||||||||||||||||||||||||||||||||
| 67 | message => "Field '*' does not make sense for assertions", | ||||||||||||||||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 40 | ▶ | sub _build_coderef { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_coderef: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 40 | my ( $self ) = ( shift ); | |||||||||||||||||||||||||||||||||||||||||
| 74 | 40 | my @checks = map $self->_make_check( $_ ), @{ $self->fields }; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 73 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 73 | for my $check ( @checks ) { | |||||||||||||||||||||||||||||||||||||||||
| 77 | 75 | ▶ | return !!0 unless $check->( $_ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 34 | return !!1; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 37 | }; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } #/ sub _build_coderef | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | { | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | my %makers = ( | |||||||||||||||||||||||||||||||||||||||||
| 85 | 'is' => '_make_is_check', | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 'in' => '_make_in_check', | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 'to' => '_make_to_check', | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 'like' => '_make_like_check', | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 'match' => '_make_match_check', | ||||||||||||||||||||||||||||||||||||||||||
| 90 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 41 | ▶ | sub _make_check { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_check: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 41 | my ( $self, $field ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 41 | my @found; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 41 | for my $key ( sort keys %makers ) { | |||||||||||||||||||||||||||||||||||||||||
| 97 | 205 | ▶ | push @found, $key if exists $field->params->{$key}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 41 | ▶ | if ( @found > 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | my $params = join q[, ], map "-$_", @found; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | LINQ::Util::Internal::throw( | |||||||||||||||||||||||||||||||||||||||||
| 103 | "CallerError", | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | message => "Multiple conflicting assertions ($params) found for field '@{[ $field->name ]}'", | |||||||||||||||||||||||||||||||||||||||||
| 105 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 40 | ▶ | if ( @found == 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | LINQ::Util::Internal::throw( | |||||||||||||||||||||||||||||||||||||||||
| 110 | "CallerError", | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | message => "No assertions found for field '@{[ $field->name ]}'", | |||||||||||||||||||||||||||||||||||||||||
| 112 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 39 | my $method = $makers{ $found[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 39 | return $self->$method( $field ); | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | { | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 2 | my %templates = ( | |||||||||||||||||||||||||||||||||||||||||
| 122 | 'numeric ==' => '%s == %s', | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 'numeric !=' => '%s != %s', | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 'numeric >' => '%s > %s', | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 'numeric >=' => '%s >= %s', | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 'numeric <' => '%s < %s', | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 'numeric <=' => '%s <= %s', | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 'string ==' => '%s eq %s', | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 'string !=' => '%s ne %s', | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 'string >' => '%s gt %s', | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 'string >=' => '%s ge %s', | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 'string <' => '%s lt %s', | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 'string <=' => '%s le %s', | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 'null ==' => '! defined( %s )', | ||||||||||||||||||||||||||||||||||||||||||
| 135 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 22 | ▶ | sub _make_is_check { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_is_check: called CC=14 SCAR=26.7
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 22 | my ( $self, $field ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 139 | 22 | my $getter = $field->getter; | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 22 | my $expected = $field->params->{is}; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 22 | ▶ | my $cmp = $field->params->{cmp} || "=="; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$field->params->{'cmp'} || '=='
MC/DC100%1/1
$field->params->{'cmp'} || '=='
$field->params->{'cmp'}
Truth table100%2/2
A
A= $field->params->{'cmp'}
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | my $type = | ||||||||||||||||||||||||||||||||||||||||||
| 144 | $field->params->{numeric} ? 'numeric' | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 22 | ▶ | : $field->params->{string} ? 'string' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | : !defined( $expected ) ? 'null' | ||||||||||||||||||||||||||||||||||||||||||
| 147 | : $expected =~ /^[0-9]+(?:\.[0-9]+)$/ ? 'numeric' | ||||||||||||||||||||||||||||||||||||||||||
| 148 | : !ref( $expected ) ? 'string' | ||||||||||||||||||||||||||||||||||||||||||
| 149 | : 'numeric'; | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 22 | ▶ | my $template = $templates{"$type $cmp"} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | or LINQ::Util::Internal::throw( | ||||||||||||||||||||||||||||||||||||||||||
| 152 | "CallerError", | ||||||||||||||||||||||||||||||||||||||||||
| 153 | message => "Unexpected comparator '$cmp' for type '$type'", | ||||||||||||||||||||||||||||||||||||||||||
| 154 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 21 | my $guts; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 21 | ▶ | if ( $type eq 'null' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | $guts = sprintf( $template, '$getter->( $_ )' ); | |||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | elsif ( $field->params->{nocase} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | ▶ | my $fold = ( $] > 5.016 ) ? 'CORE::fc' : 'lc'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | $guts = sprintf( | ||||||||||||||||||||||||||||||||||||||||||
| 163 | $template, | ||||||||||||||||||||||||||||||||||||||||||
| 164 | "$fold( \$getter->( \$_ ) )", | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | ▶ | ref( $expected ) ? "$fold( \$expected )" : do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | require B; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | "$fold( " . B::perlstring( $expected ) . ' )'; | |||||||||||||||||||||||||||||||||||||||||
| 168 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 169 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 170 | } #/ elsif ( $field->params->{...}) | ||||||||||||||||||||||||||||||||||||||||||
| 171 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 172 | $guts = sprintf( | ||||||||||||||||||||||||||||||||||||||||||
| 173 | $template, | ||||||||||||||||||||||||||||||||||||||||||
| 174 | '$getter->( $_ )', | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 18 | ▶ | ref( $expected ) ? '$expected' : do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 18 | require B; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 18 | B::perlstring( $expected ); | |||||||||||||||||||||||||||||||||||||||||
| 178 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 179 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 180 | } #/ else [ if ( $type eq 'null' )] | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 21 | ▶ | if ( $field->params->{nix} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | $guts = "!( $guts )"; | |||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 2 | ▶ | no warnings qw( uninitialized ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 21 | return eval "sub { $guts }"; | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 7 | ▶ | sub _make_to_check { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_to_check: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 7 | my ( $self, $field ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 192 | 7 | my $getter = $field->getter; | |||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 7 | my $other = 'LINQ::Field'->new( value => $field->params->{to} )->getter; | |||||||||||||||||||||||||||||||||||||||||
| 195 | 7 | ▶ | my $cmp = $field->params->{cmp} || "=="; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$field->params->{'cmp'} || '=='
MC/DC100%1/1
$field->params->{'cmp'} || '=='
$field->params->{'cmp'}
Truth table100%2/2
A
A= $field->params->{'cmp'}
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 7 | ▶ | my $type = $field->params->{string} ? 'string' : 'numeric'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 7 | ▶ | my $template = $templates{"$type $cmp"} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | or LINQ::Util::Internal::throw( | ||||||||||||||||||||||||||||||||||||||||||
| 199 | "CallerError", | ||||||||||||||||||||||||||||||||||||||||||
| 200 | message => "Unexpected comparator '$cmp' for type '$type'", | ||||||||||||||||||||||||||||||||||||||||||
| 201 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 7 | my $guts; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 7 | ▶ | if ( $field->params->{nocase} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 2 | ▶ | my $fold = ( $] > 5.016 ) ? 'CORE::fc' : 'lc'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | $guts = sprintf( | |||||||||||||||||||||||||||||||||||||||||
| 207 | $template, | ||||||||||||||||||||||||||||||||||||||||||
| 208 | "$fold( \$getter->( \$_ ) )", | ||||||||||||||||||||||||||||||||||||||||||
| 209 | "$fold( \$other->( \$_ ) )", | ||||||||||||||||||||||||||||||||||||||||||
| 210 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 211 | } #/ elsif ( $field->params->{...}) | ||||||||||||||||||||||||||||||||||||||||||
| 212 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 5 | $guts = sprintf( | |||||||||||||||||||||||||||||||||||||||||
| 214 | $template, | ||||||||||||||||||||||||||||||||||||||||||
| 215 | '$getter->( $_ )', | ||||||||||||||||||||||||||||||||||||||||||
| 216 | '$other->( $_ )', | ||||||||||||||||||||||||||||||||||||||||||
| 217 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 218 | } #/ else [ if ( $type eq 'null' )] | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 7 | ▶ | if ( $field->params->{nix} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 1 | $guts = "!( $guts )"; | |||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 2 | ▶ | no warnings qw( uninitialized ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 7 | return eval "sub { $guts }"; | |||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 2 | ▶ | sub _make_in_check { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_in_check: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 3 | my ( $self, $field ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 231 | 3 | my $getter = $field->getter; | |||||||||||||||||||||||||||||||||||||||||
| 232 | 3 | my @expected = @{ $field->params->{in} }; | |||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 3 | my $nix = ! $field->params->{nix}; | |||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 3 | ▶ | if ( $field->params->{nocase} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 2 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | my $value = lc $getter->( $_ ); | |||||||||||||||||||||||||||||||||||||||||
| 239 | 2 | for my $expected ( @expected ) { | |||||||||||||||||||||||||||||||||||||||||
| 240 | 3 | ▶ | return !!$nix if $value eq lc $expected; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 1 | return !$nix; | |||||||||||||||||||||||||||||||||||||||||
| 243 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 246 | 4 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 4 | my $value = $getter->( $_ ); | |||||||||||||||||||||||||||||||||||||||||
| 248 | 4 | for my $expected ( @expected ) { | |||||||||||||||||||||||||||||||||||||||||
| 249 | 7 | ▶ | return !!$nix if $value eq $expected; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 3 | return !$nix; | |||||||||||||||||||||||||||||||||||||||||
| 252 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | { | ||||||||||||||||||||||||||||||||||||||||||
| 257 | 5 | ▶ | my $_like_to_regexp = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=12 SCAR=29.7
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 5 | my ( $like, $ci ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 259 | 5 | my $re = ''; | |||||||||||||||||||||||||||||||||||||||||
| 260 | 5 | my %anchors = ( | |||||||||||||||||||||||||||||||||||||||||
| 261 | start => substr( $like, 0, 1 ) ne '%', | ||||||||||||||||||||||||||||||||||||||||||
| 262 | end => substr( $like, -1, 1 ) ne '%', | ||||||||||||||||||||||||||||||||||||||||||
| 263 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 5 | my @parts = split qr{(\\*[.%])}, $like; | |||||||||||||||||||||||||||||||||||||||||
| 265 | 5 | for my $p ( @parts ) { | |||||||||||||||||||||||||||||||||||||||||
| 266 | 10 | ▶ | next unless length $p; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 10 | my $backslash_count =()= $p =~ m{(\\)}g; | |||||||||||||||||||||||||||||||||||||||||
| 268 | 10 | my $wild_count =()= $p =~ m{([%.])}g; | |||||||||||||||||||||||||||||||||||||||||
| 269 | 10 | ▶ | if ( $wild_count ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 5 | ▶ | if ( $backslash_count && $backslash_count % 2 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$backslash_count and $backslash_count % 2
MC/DC0%0/2
$backslash_count and $backslash_count % 2
$backslash_count
$backslash_count % 2
Truth table33%1/3
A and B
A= $backslash_countB= $backslash_count % 2
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | my $last = substr( $p, -2, 2, '' ); | |||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $p =~ s{\\\\}{\\}; | |||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | $re .= quotemeta( $p . substr( $last, -1, 1 ) ); | |||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||
| 275 | elsif ( $backslash_count ) { | ||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my $last = substr( $p, -1, 1, '' ); | |||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $p =~ s{\\\\}{\\}; | |||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | $re .= quotemeta( $p ) . ( $last eq '%' ? '.*' : '.' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 5 | ▶ | $re .= $p eq '%' ? '.*' : '.'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | } #/ if ( $wild_count ) | ||||||||||||||||||||||||||||||||||||||||||
| 284 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 5 | $p =~ s{\\(.)}{$1}g; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 5 | $re .= quotemeta( $p ); | |||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | } #/ for my $p ( @parts ) | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 5 | ▶ | substr( $re, 0, 0, '\A' ) if $anchors{start}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 5 | ▶ | $re .= '\z' if $anchors{end}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | 5 | ▶ | $ci ? qr/$re/i : qr/$re/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 5 | ▶ | sub _make_like_check { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_like_check: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 5 | my ( $self, $field ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 298 | 5 | my $getter = $field->getter; | |||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | my $match = $_like_to_regexp->( | ||||||||||||||||||||||||||||||||||||||||||
| 301 | $field->params->{like}, | ||||||||||||||||||||||||||||||||||||||||||
| 302 | $field->params->{nocase}, | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | 5 | ▶ | if ( $field->params->{nix} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | 2 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 2 | my $value = $getter->( $_ ); | |||||||||||||||||||||||||||||||||||||||||
| 308 | 2 | $value !~ $match; | |||||||||||||||||||||||||||||||||||||||||
| 309 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 312 | 6 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | 6 | my $value = $getter->( $_ ); | |||||||||||||||||||||||||||||||||||||||||
| 314 | 6 | $value =~ $match; | |||||||||||||||||||||||||||||||||||||||||
| 315 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | 2 | ▶ | sub _make_match_check { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_match_check: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 2 | my ( $self, $field ) = ( shift, @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 322 | 2 | my $getter = $field->getter; | |||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 2 | my $match = $field->params->{match}; | |||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 2 | require match::simple; | |||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 2 | ▶ | if ( $field->params->{nix} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | 2 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 2 | my $value = $getter->( $_ ); | |||||||||||||||||||||||||||||||||||||||||
| 331 | 2 | not match::simple::match( $value, $match ); | |||||||||||||||||||||||||||||||||||||||||
| 332 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 2 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | 2 | my $value = $getter->( $_ ); | |||||||||||||||||||||||||||||||||||||||||
| 337 | 2 | match::simple::match( $value, $match ); | |||||||||||||||||||||||||||||||||||||||||
| 338 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | 4 | ▶ | sub not { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
not: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | 4 | my ( $self ) = ( shift ); | |||||||||||||||||||||||||||||||||||||||||
| 344 | 4 | return 'LINQ::FieldSet::Assertion::NOT'->new( | |||||||||||||||||||||||||||||||||||||||||
| 345 | left => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 346 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 5 | ▶ | sub and { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
and: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 5 | my ( $self, $other ) = &$_process_args; | |||||||||||||||||||||||||||||||||||||||||
| 351 | 5 | return 'LINQ::FieldSet::Assertion::AND'->new( | |||||||||||||||||||||||||||||||||||||||||
| 352 | left => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 353 | right => $other, | ||||||||||||||||||||||||||||||||||||||||||
| 354 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 1 | ▶ | sub or { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
or: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | 1 | my ( $self, $other ) = &$_process_args; | |||||||||||||||||||||||||||||||||||||||||
| 359 | 1 | return 'LINQ::FieldSet::Assertion::OR'->new( | |||||||||||||||||||||||||||||||||||||||||
| 360 | left => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 361 | right => $other, | ||||||||||||||||||||||||||||||||||||||||||
| 362 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | sub to_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_string: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | my ( $self ) = ( shift ); | |||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | sprintf 'check_fields(%s)', join q[, ], map $_->name, @{ $self->fields }; | |||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | package LINQ::FieldSet::Assertion::Combination; | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 2 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||||||
| 373 | 2 | our $VERSION = '0.003'; | |||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | 2 | ▶ | use Role::Tiny; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | 2 | requires( qw/ left right _build_coderef / ); | |||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 20 | ▶ | sub coderef { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coderef: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 20 | my ( $self ) = ( shift ); | |||||||||||||||||||||||||||||||||||||||||
| 380 | 20 | ▶ | $self->{coderef} ||= $self->_build_coderef; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$self->{"coderef"} ||= $self->_build_coderef
MC/DC100%2/2
$self->{"coderef"} ||= $self->_build_coderef
$self->{"coderef"}
$self->_build_coderef
Truth table100%3/3
A ||= B
A= $self->{"coderef"}B= $self->_build_coderef
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | 1 | ▶ | sub not { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
not: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | 1 | my ( $self ) = ( shift ); | |||||||||||||||||||||||||||||||||||||||||
| 385 | 1 | return 'LINQ::FieldSet::Assertion::NOT'->new( | |||||||||||||||||||||||||||||||||||||||||
| 386 | left => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 387 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | 1 | ▶ | sub and { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
and: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | 1 | my ( $self, $other ) = &$_process_args; | |||||||||||||||||||||||||||||||||||||||||
| 392 | 1 | return 'LINQ::FieldSet::Assertion::AND'->new( | |||||||||||||||||||||||||||||||||||||||||
| 393 | left => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 394 | right => $other, | ||||||||||||||||||||||||||||||||||||||||||
| 395 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | 2 | ▶ | sub or { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
or: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 399 | 2 | my ( $self, $other ) = &$_process_args; | |||||||||||||||||||||||||||||||||||||||||
| 400 | 2 | return 'LINQ::FieldSet::Assertion::OR'->new( | |||||||||||||||||||||||||||||||||||||||||
| 401 | left => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 402 | right => $other, | ||||||||||||||||||||||||||||||||||||||||||
| 403 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | package LINQ::FieldSet::Assertion::NOT; | ||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | 2 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||||||
| 409 | 2 | our $VERSION = '0.003'; | |||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | 2 | ▶ | use Class::Tiny qw( left ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 412 | 2 | ▶ | use Role::Tiny::With (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | 2 | Role::Tiny::With::with( 'LINQ::FieldSet::Assertion::Combination' ); | |||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | 2 | ▶ | use overload (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | 2 | 'overload'->import( | |||||||||||||||||||||||||||||||||||||||||
| 417 | q[&{}] => 'coderef', | ||||||||||||||||||||||||||||||||||||||||||
| 418 | q[|] => 'or', | ||||||||||||||||||||||||||||||||||||||||||
| 419 | q[&] => 'and', | ||||||||||||||||||||||||||||||||||||||||||
| 420 | q[~] => 'not', | ||||||||||||||||||||||||||||||||||||||||||
| 421 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | 3 | ▶ | sub _build_coderef { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_coderef: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | 3 | my ( $self ) = ( shift ); | |||||||||||||||||||||||||||||||||||||||||
| 425 | 3 | my $left = $self->left->coderef; | |||||||||||||||||||||||||||||||||||||||||
| 426 | 3 | ▶ | return sub { not $left->( $_ ) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | 1 | ▶ | sub not { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
not: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | 1 | my ( $self ) = ( shift ); | |||||||||||||||||||||||||||||||||||||||||
| 431 | 1 | return $self->left; | |||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | 1 | ▶ | sub right { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
right: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | 1 | LINQ::Util::Internal::throw( | |||||||||||||||||||||||||||||||||||||||||
| 436 | "InternalError", | ||||||||||||||||||||||||||||||||||||||||||
| 437 | message => 'Unexpected second branch to NOT.', | ||||||||||||||||||||||||||||||||||||||||||
| 438 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | package LINQ::FieldSet::Assertion::AND; | ||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | 2 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||||||
| 444 | 2 | our $VERSION = '0.003'; | |||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | 2 | ▶ | use Class::Tiny qw( left right ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | 2 | ▶ | use Role::Tiny::With (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 448 | 2 | Role::Tiny::With::with( 'LINQ::FieldSet::Assertion::Combination' ); | |||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | 2 | ▶ | use overload (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 451 | 2 | 'overload'->import( | |||||||||||||||||||||||||||||||||||||||||
| 452 | q[&{}] => 'coderef', | ||||||||||||||||||||||||||||||||||||||||||
| 453 | q[|] => 'or', | ||||||||||||||||||||||||||||||||||||||||||
| 454 | q[&] => 'and', | ||||||||||||||||||||||||||||||||||||||||||
| 455 | q[~] => 'not', | ||||||||||||||||||||||||||||||||||||||||||
| 456 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||
| 458 | 6 | ▶ | sub _build_coderef { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_coderef: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 459 | 6 | my ( $self ) = ( shift ); | |||||||||||||||||||||||||||||||||||||||||
| 460 | 6 | my $left = $self->left->coderef; | |||||||||||||||||||||||||||||||||||||||||
| 461 | 6 | my $right = $self->right->coderef; | |||||||||||||||||||||||||||||||||||||||||
| 462 | 6 | ▶ | return sub { $left->( $_ ) and $right->( $_ ) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | package LINQ::FieldSet::Assertion::OR; | ||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | 2 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||||||
| 468 | 2 | our $VERSION = '0.003'; | |||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | 2 | ▶ | use Class::Tiny qw( left right ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 471 | 2 | ▶ | use Role::Tiny::With (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | 2 | Role::Tiny::With::with( 'LINQ::FieldSet::Assertion::Combination' ); | |||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | 2 | ▶ | use overload (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 475 | 2 | 'overload'->import( | |||||||||||||||||||||||||||||||||||||||||
| 476 | q[&{}] => 'coderef', | ||||||||||||||||||||||||||||||||||||||||||
| 477 | q[|] => 'or', | ||||||||||||||||||||||||||||||||||||||||||
| 478 | q[&] => 'and', | ||||||||||||||||||||||||||||||||||||||||||
| 479 | q[~] => 'not', | ||||||||||||||||||||||||||||||||||||||||||
| 480 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||
| 482 | 3 | ▶ | sub _build_coderef { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_coderef: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 483 | 3 | my ( $self ) = ( shift ); | |||||||||||||||||||||||||||||||||||||||||
| 484 | 3 | my $left = $self->left->coderef; | |||||||||||||||||||||||||||||||||||||||||
| 485 | 3 | my $right = $self->right->coderef; | |||||||||||||||||||||||||||||||||||||||||
| 486 | 3 | ▶ | return sub { $left->( $_ ) or $right->( $_ ) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | __END__ | ||||||||||||||||||||||||||||||||||||||||||