blib/lib/Type/Tiny/Union.pm

filter: Statementstmt 89.8% 186 / 207 Branchbran 79.3% 73 / 92 Conditioncond 67.8% 19 / 28 MC/DCmcdc 44.4% 8 / 18 Subroutinesub 96.8% 31 / 32 Podpod 100% 13 / 13 totaltotal 84.6% 330 / 390 CC 70 SCAR 29.3
CC
70
Cov
85%
__ANON__
45.0
new
12.0
new_by_overload
8.0
CRAP 18.7
« lib/Type/Registry.pm ↑ Summary blib/lib/Type/Utils.pm »
1 package Type::Tiny::Union;
2  
3 41 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 41 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 41 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 41 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 41 $Type::Tiny::Union::AUTHORITY = 'cpan:TOBYINK';
9 41 $Type::Tiny::Union::VERSION = '2.010001';
10 }
11  
12 41 $Type::Tiny::Union::VERSION =~ tr/_//d;
13  
14 41 ▶use Scalar::Util qw< blessed >;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 41 ▶use Types::TypeTiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 4 ▶sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak }
Subroutine _croak: called CC=1 SCAR=0.0
18  
19 41 ▶use Type::Tiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
20 41 our @ISA = 'Type::Tiny';
21  
22 __PACKAGE__->_install_overloads(
23 897 ▶ q[@{}] => sub { $_[0]{type_constraints} ||= [] } );
Subroutine __ANON__: called CC=2 SCAR=7.2
Condition50%1/2
$_[0]{"type_constraints"} ||= []
l!l
8970
MC/DC0%0/1
$_[0]{"type_constraints"} ||= []
$_[0]{"type_constraints"}
Truth table50%1/2
A
A= $_[0]{"type_constraints"}
Aresult
11
00
24  
25 78 ▶sub new_by_overload {
Subroutine new_by_overload: called CC=7 SCAR=20.7
Pod documented
26 78 my $proto = shift;
27 0 ▶ my %opts = ( @_ == 1 ) ? %{ $_[0] } : @_;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 0 78 78
28  
29 78 my @types = @{ $opts{type_constraints} };
30 78 ▶ if ( my @makers = map scalar( blessed($_) && $_->can( 'new_union' ) ), @types ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@makers) = map(scalar(builtin::blessed($_) and $_->can("new_union")), @types)) 78 0 78
Condition66%2/3
builtin::blessed($_) && $_->can('new_union')
!ll&&!rl&&r
01563
MC/DC50%1/2
builtin::blessed($_) && $_->can('new_union')
builtin::blessed($_) $_->can('new_union')
Truth table66%2/3
A && B
A= builtin::blessed($_)B= $_->can('new_union')
ABresult
0X0
100
111
31 78 my $first_maker = shift @makers;
32 78 ▶ if ( ref $first_maker ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $first_maker) 1 77 78
33 1 ▶ my $all_same = not grep +( !defined $_ or $_ ne $first_maker ), @makers;
Condition33%1/3
!defined($_) || $_ ne $first_maker
l!l&&r!l&&!r
001
MC/DC0%0/2
!defined($_) || $_ ne $first_maker
!defined($_) $_ ne $first_maker
Truth table33%1/3
not(A) || B
A= !defined($_)B= $_ ne $first_maker
ABresult
1X1
011
000
34 1 ▶ if ( $all_same ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($all_same) 1 0 1
35 1 return ref( $types[0] )->$first_maker( %opts );
36 }
37 }
38 }
39  
40 77 return $proto->new( \%opts );
41 }
42  
43 165 ▶sub new {
Subroutine new: called CC=12 SCAR=24.9
Pod documented
44 165 my $proto = shift;
45
46 165 ▶ my %opts = ( @_ == 1 ) ? %{ $_[0] } : @_;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 77 88 165
47 _croak
48 "Union type constraints cannot have a parent constraint passed to the constructor"
49 165 ▶ if exists $opts{parent};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"parent"} 1 164 165
50 _croak
51 "Union type constraints cannot have a constraint coderef passed to the constructor"
52 164 ▶ if exists $opts{constraint};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"constraint"} 1 163 164
53 _croak
54 "Union type constraints cannot have a inlining coderef passed to the constructor"
55 163 ▶ if exists $opts{inlined};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"inlined"} 1 162 163
56 _croak "Need to supply list of type constraints"
57 162 ▶ unless exists $opts{type_constraints};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts{"type_constraints"} 1 161 162
58
59 $opts{type_constraints} = [
60 333 ▶ map { $_->isa( __PACKAGE__ ) ? @$_ : $_ }
Branch: 1 branch
BranchTrueFalseTotal
$_->isa(__PACKAGE__) ? : 13 320 333
61 map Types::TypeTiny::to_TypeTiny( $_ ),
62 @{
63 161 ref $opts{type_constraints} eq "ARRAY"
64 ? $opts{type_constraints}
65 161 ▶ : [ $opts{type_constraints} ]
Branch: 1 branch
BranchTrueFalseTotal
ref $opts{'type_constraints'} eq 'ARRAY' ? : 161 0 161
66 }
67 ];
68
69 161 if ( Type::Tiny::_USE_XS ) {
70 161 my @constraints = @{ $opts{type_constraints} };
71 my @known = map {
72 161 my $known = Type::Tiny::XS::is_known( $_->compiled_check );
73 352 ▶ defined( $known ) ? $known : ();
Branch: 1 branch
BranchTrueFalseTotal
defined $known ? : 206 146 352
74 } @constraints;
75
76 161 ▶ if ( @known == @constraints ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@known == @constraints) 58 103 161
77 58 my $xsub = Type::Tiny::XS::get_coderef_for(
78 sprintf "AnyOf[%s]",
79 join( ',', @known )
80 );
81 58 ▶ $opts{compiled_type_constraint} = $xsub if $xsub;
Branch: 1 branch
BranchTrueFalseTotal
if $xsub 58 0 58
82 }
83 } #/ if ( Type::Tiny::_USE_XS)
84
85 161 my $self = $proto->SUPER::new( %opts );
86 161 ▶ $self->coercion if grep $_->has_coercion, @$self;
Branch: 1 branch
BranchTrueFalseTotal
if grep $_->has_coercion, @$self 62 99 161
87 161 return $self;
88 } #/ sub new
89  
90 161 ▶sub _lockdown {
Subroutine _lockdown: called CC=1 SCAR=0.0
91 161 my ( $self, $callback ) = @_;
92 161 $callback->( $self->{type_constraints} );
93 }
94  
95 186 ▶sub type_constraints { $_[0]{type_constraints} }
Subroutine type_constraints: called CC=1 SCAR=0.0
Pod documented
96 53 ▶sub constraint { $_[0]{constraint} ||= $_[0]->_build_constraint }
Subroutine constraint: called CC=2 SCAR=7.2
Pod documented
Condition66%2/3
$_[0]{"constraint"} ||= $_[0]->_build_constraint
l!l&&r!l&&!r
29240
MC/DC0%0/2
$_[0]{"constraint"} ||= $_[0]->_build_constraint
$_[0]{"constraint"} $_[0]->_build_constraint
Truth table66%2/3
A ||= B
A= $_[0]{"constraint"}B= $_[0]->_build_constraint
ABresult
1X1
011
000
97  
98 169 ▶sub _is_null_constraint { 0 }
Subroutine _is_null_constraint: called CC=1 SCAR=0.0
99  
100 89 ▶sub _build_display_name {
Subroutine _build_display_name: called CC=1 SCAR=0.0
101 89 my $self = shift;
102 89 join q[|], @$self;
103 }
104  
105 65 ▶sub _build_coercion {
Subroutine _build_coercion: called CC=1 SCAR=0.0
106 65 require Type::Coercion::Union;
107 65 my $self = shift;
108 65 return "Type::Coercion::Union"->new( type_constraint => $self );
109 }
110  
111 24 ▶sub _build_constraint {
Subroutine _build_constraint: called CC=1 SCAR=0.0
112 24 my @checks = map $_->compiled_check, @{ +shift };
113 182 ▶ return sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
114 182 my $val = $_;
115 182 ▶ $_->( $val ) && return !!1 for @checks;
Branch: 1 branch
BranchTrueFalseTotal
&$_($val) and 170 79 249
116 12 return;
117 }
118 24 }
119  
120 241 ▶sub can_be_inlined {
Subroutine can_be_inlined: called CC=1 SCAR=0.0
Pod documented
121 241 my $self = shift;
122 241 not grep !$_->can_be_inlined, @$self;
123 }
124  
125 290 ▶sub inline_check {
Subroutine inline_check: called CC=6 SCAR=17.9
Pod documented
126 290 my $self = shift;
127
128 290 ▶ if ( Type::Tiny::_USE_XS and !exists $self->{xs_sub} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"xs_sub"}) 99 191 290
129 99 $self->{xs_sub} = undef;
130
131 99 my @constraints = @{ $self->type_constraints };
132 my @known = map {
133 99 my $known = Type::Tiny::XS::is_known( $_->compiled_check );
134 217 ▶ defined( $known ) ? $known : ();
Branch: 1 branch
BranchTrueFalseTotal
defined $known ? : 122 95 217
135 } @constraints;
136
137 99 ▶ if ( @known == @constraints ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@known == @constraints) 23 76 99
138 23 $self->{xs_sub} = Type::Tiny::XS::get_subname_for(
139 sprintf "AnyOf[%s]",
140 join( ',', @known )
141 );
142 }
143 } #/ if ( Type::Tiny::_USE_XS...)
144
145 290 my $code = sprintf '(%s)', join " or ", map $_->inline_check( $_[0] ), @$self;
146
147 290 ▶ return "do { $Type::Tiny::SafePackage $code }"
Branch: 1 branch
BranchTrueFalseTotal
if $Type::Tiny::AvoidCallbacks 40 250 290
148 if $Type::Tiny::AvoidCallbacks;
149 return "$self->{xs_sub}\($_[0]\)"
150 250 ▶ if $self->{xs_sub};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"xs_sub"} 48 202 250
151 202 return $code;
152 } #/ sub inline_check
153  
154 0 ▶sub _instantiate_moose_type {
Subroutine _instantiate_moose_type: not called CC=1 SCAR=6.9
155 0 my $self = shift;
156 0 my %opts = @_;
157 0 delete $opts{parent};
158 0 delete $opts{constraint};
159 0 delete $opts{inlined};
160
161 0 my @tc = map $_->moose_type, @{ $self->type_constraints };
162
163 0 require Moose::Meta::TypeConstraint::Union;
164 0 return "Moose::Meta::TypeConstraint::Union"
165 ->new( %opts, type_constraints => \@tc );
166 } #/ sub _instantiate_moose_type
167  
168 94 ▶sub has_parent {
Subroutine has_parent: called CC=1 SCAR=0.0
Pod documented
169 94 defined( shift->parent );
170 }
171  
172 244 ▶sub parent {
Subroutine parent: called CC=2 SCAR=6.9
Pod documented
173 244 ▶ $_[0]{parent} ||= $_[0]->_build_parent;
Condition100%3/3
$_[0]{"parent"} ||= $_[0]->_build_parent
l!l&&r!l&&!r
201385
MC/DC100%2/2
$_[0]{"parent"} ||= $_[0]->_build_parent
$_[0]{"parent"} $_[0]->_build_parent
Truth table100%3/3
A ||= B
A= $_[0]{"parent"}B= $_[0]->_build_parent
ABresult
1X1
011
000
174 }
175  
176 43 ▶sub _build_parent {
Subroutine _build_parent: called CC=3 SCAR=11.0
177 43 my $self = shift;
178 43 my ( $first, @rest ) = @$self;
179
180 43 for my $parent ( $first, $first->parents ) {
181 145 ▶ return $parent unless grep !$_->is_a_type_of( $parent ), @rest;
Branch: 1 branch
BranchTrueFalseTotal
unless grep((!$_->is_a_type_of($parent)), @rest) 38 107 145
182 }
183
184 5 return;
185 } #/ sub _build_parent
186  
187 4 ▶sub find_type_for {
Subroutine find_type_for: called CC=3 SCAR=11.0
Pod documented
188 4 my @types = @{ +shift };
189 4 for my $type ( @types ) {
190 7 ▶ return $type if $type->check( @_ );
Branch: 1 branch
BranchTrueFalseTotal
if $type->check(@_) 3 4 7
191 }
192 1 return;
193 }
194  
195 1 ▶sub validate_explain {
Subroutine validate_explain: called CC=4 SCAR=14.2
Pod documented
196 1 my $self = shift;
197 1 my ( $value, $varname ) = @_;
198 1 ▶ $varname = '$_' unless defined $varname;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $varname 0 1 1
199
200 1 ▶ return undef if $self->check( $value );
Branch: 1 branch
BranchTrueFalseTotal
if $self->check($value) 0 1 1
201
202 1 require Type::Utils;
203 return [
204 sprintf(
205 '"%s" requires that the value pass %s',
206 $self,
207 Type::Utils::english_list( \"or", map qq["$_"], @$self ),
208 ),
209 map {
210 1 $_->get_message( $value ),
211 2 ▶ map( " $_", @{ $_->validate_explain( $value ) || [] } ),
Condition50%1/2
$_->validate_explain($value) || []
l!l
20
MC/DC0%0/1
$_->validate_explain($value) || []
$_->validate_explain($value)
Truth table50%1/2
A
A= $_->validate_explain($value)
Aresult
11
00
212 } @$self
213 ];
214 } #/ sub validate_explain
215  
216 5 ▶my $_delegate = sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
217 5 my ( $self, $method ) = ( shift, shift );
218 5 my @types = @{ $self->type_constraints };
219
220 5 my @unsupported = grep !$_->can( $method ), @types;
221 5 ▶ _croak( 'Could not apply method %s to all types within the union', $method )
Branch: 1 branch
BranchTrueFalseTotal
if @unsupported 0 5 5
222 if @unsupported;
223
224 5 ref( $self )->new( type_constraints => [ map $_->$method( @_ ), @types ] );
225 41 };
226  
227 2 ▶sub stringifies_to {
Subroutine stringifies_to: called CC=1 SCAR=0.0
Pod documented
228 2 my $self = shift;
229 2 $self->$_delegate( stringifies_to => @_ );
230 }
231  
232 2 ▶sub numifies_to {
Subroutine numifies_to: called CC=1 SCAR=0.0
Pod documented
233 2 my $self = shift;
234 2 $self->$_delegate( numifies_to => @_ );
235 }
236  
237 1 ▶sub with_attribute_values {
Subroutine with_attribute_values: called CC=1 SCAR=0.0
Pod documented
238 1 my $self = shift;
239 1 $self->$_delegate( with_attribute_values => @_ );
240 }
241  
242 168 ▶push @Type::Tiny::CMP, sub {
Subroutine __ANON__: called CC=35 SCAR=38.1
243 168 my $A = shift->find_constraining_type;
244 168 my $B = shift->find_constraining_type;
245
246 168 ▶ if ( $A->isa( __PACKAGE__ ) and $B->isa( __PACKAGE__ ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($A->isa(__PACKAGE__) and $B->isa(__PACKAGE__)) 2 166 168
Condition100%3/3
$A->isa(__PACKAGE__) and $B->isa(__PACKAGE__)
!ll&&!rl&&r
15792
MC/DC100%2/2
$A->isa(__PACKAGE__) and $B->isa(__PACKAGE__)
$A->isa(__PACKAGE__) $B->isa(__PACKAGE__)
Truth table100%3/3
A and B
A= $A->isa(__PACKAGE__)B= $B->isa(__PACKAGE__)
ABresult
0X0
100
111
247 2 my @A_constraints = @{ $A->type_constraints };
248 2 my @B_constraints = @{ $B->type_constraints };
249
250 # If everything in @A_constraints is equal to something in @B_constraints and vice versa, then $A equiv to $B
251 EQUALITY: {
252 2 my $everything_in_a_is_equal = 1;
253 2 OUTER: for my $A_child ( @A_constraints ) {
254 3 INNER: for my $B_child ( @B_constraints ) {
255 5 ▶ if ( $A_child->equals( $B_child ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($A_child->equals($B_child)) 2 3 5
256 2 next OUTER;
257 }
258 }
259 1 $everything_in_a_is_equal = 0;
260 1 last OUTER;
261 }
262
263 2 my $everything_in_b_is_equal = 1;
264 2 OUTER: for my $B_child ( @B_constraints ) {
265 4 INNER: for my $A_child ( @A_constraints ) {
266 7 ▶ if ( $B_child->equals( $A_child ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($B_child->equals($A_child)) 3 4 7
267 3 next OUTER;
268 }
269 }
270 1 $everything_in_b_is_equal = 0;
271 1 last OUTER;
272 }
273
274 2 ▶ return Type::Tiny::CMP_EQUIVALENT
Branch: 1 branch
BranchTrueFalseTotal
if $everything_in_a_is_equal and $everything_in_b_is_equal 1 1 2
Condition66%2/3
$everything_in_a_is_equal and $everything_in_b_is_equal
!ll&&!rl&&r
101
MC/DC50%1/2
$everything_in_a_is_equal and $everything_in_b_is_equal
$everything_in_a_is_equal $everything_in_b_is_equal
Truth table66%2/3
A and B
A= $everything_in_a_is_equalB= $everything_in_b_is_equal
ABresult
0X0
100
111
275 if $everything_in_a_is_equal && $everything_in_b_is_equal;
276 } #/ EQUALITY:
277
278 # If everything in @A_constraints is a subtype of something in @B_constraints, then $A is subtype of $B
279 SUBTYPE: {
280 1 OUTER: for my $A_child ( @A_constraints ) {
281 1 my $a_child_is_subtype_of_something = 0;
282 1 INNER: for my $B_child ( @B_constraints ) {
283 2 ▶ if ( $A_child->is_a_type_of( $B_child ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($A_child->is_a_type_of($B_child)) 0 2 2
284 0 ++$a_child_is_subtype_of_something;
285 0 last INNER;
286 }
287 }
288 1 ▶ if ( not $a_child_is_subtype_of_something ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($a_child_is_subtype_of_something) 1 0 1
289 1 last SUBTYPE;
290 }
291 } #/ OUTER: for my $A_child ( @A_constraints)
292 0 return Type::Tiny::CMP_SUBTYPE;
293 } #/ SUBTYPE:
294
295 # If everything in @B_constraints is a subtype of something in @A_constraints, then $A is supertype of $B
296 SUPERTYPE: {
297 1 OUTER: for my $B_child ( @B_constraints ) {
298 2 my $b_child_is_subtype_of_something = 0;
299 2 INNER: for my $A_child ( @A_constraints ) {
300 4 ▶ if ( $B_child->is_a_type_of( $A_child ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($B_child->is_a_type_of($A_child)) 1 3 4
301 1 ++$b_child_is_subtype_of_something;
302 1 last INNER;
303 }
304 }
305 2 ▶ if ( not $b_child_is_subtype_of_something ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($b_child_is_subtype_of_something) 1 1 2
306 1 last SUPERTYPE;
307 }
308 } #/ OUTER: for my $B_child ( @B_constraints)
309 0 return Type::Tiny::CMP_SUPERTYPE;
310 } #/ SUPERTYPE:
311 } #/ if ( $A->isa( __PACKAGE__...))
312
313 # I think it might be possible to merge this into the first bit by treating $B as union[$B].
314 # Test cases first though.
315 167 ▶ if ( $A->isa( __PACKAGE__ ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($A->isa(__PACKAGE__)) 10 157 167
316 10 my @A_constraints = @{ $A->type_constraints };
317 10 ▶ if ( @A_constraints == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@A_constraints == 1) 0 10 10
318 0 my $result = Type::Tiny::cmp( $A_constraints[0], $B );
319 0 ▶ return $result unless $result eq Type::Tiny::CMP_UNKNOWN;
Branch: 1 branch
BranchTrueFalseTotal
unless $result eq "" 0 0 0
320 }
321 10 my $subtype = 1;
322 10 for my $child ( @A_constraints ) {
323 18 ▶ if ( $B->is_a_type_of( $child ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($B->is_a_type_of($child)) 5 13 18
324 5 return Type::Tiny::CMP_SUPERTYPE;
325 }
326 13 ▶ if ( $subtype and not $B->is_supertype_of( $child ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subtype and not $B->is_supertype_of($child)) 8 5 13
Condition66%2/3
$subtype and not $B->is_supertype_of($child)
!ll&&!rl&&r
508
MC/DC50%1/2
$subtype and not $B->is_supertype_of($child)
$subtype not $B->is_supertype_of($child)
Truth table66%2/3
A and not(B)
A= $subtypeB= not $B->is_supertype_of($child)
ABresult
0X0
100
111
327 8 $subtype = 0;
328 }
329 }
330 5 ▶ if ( $subtype ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subtype) 0 5 5
331 0 return Type::Tiny::CMP_SUBTYPE;
332 }
333 } #/ if ( $A->isa( __PACKAGE__...))
334
335 # I think it might be possible to merge this into the first bit by treating $A as union[$A].
336 # Test cases first though.
337 162 ▶ if ( $B->isa( __PACKAGE__ ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($B->isa(__PACKAGE__)) 2 160 162
338 2 my @B_constraints = @{ $B->type_constraints };
339 2 ▶ if ( @B_constraints == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@B_constraints == 1) 0 2 2
340 0 my $result = Type::Tiny::cmp( $A, $B_constraints[0] );
341 0 ▶ return $result unless $result eq Type::Tiny::CMP_UNKNOWN;
Branch: 1 branch
BranchTrueFalseTotal
unless $result eq "" 0 0 0
342 }
343 2 my $supertype = 1;
344 2 for my $child ( @B_constraints ) {
345 4 ▶ if ( $A->is_a_type_of( $child ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($A->is_a_type_of($child)) 0 4 4
346 0 return Type::Tiny::CMP_SUBTYPE;
347 }
348 4 ▶ if ( $supertype and not $A->is_supertype_of( $child ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($supertype and not $A->is_supertype_of($child)) 2 2 4
Condition66%2/3
$supertype and not $A->is_supertype_of($child)
!ll&&!rl&&r
022
MC/DC50%1/2
$supertype and not $A->is_supertype_of($child)
$supertype not $A->is_supertype_of($child)
Truth table66%2/3
A and not(B)
A= $supertypeB= not $A->is_supertype_of($child)
ABresult
0X0
100
111
349 2 $supertype = 0;
350 }
351 }
352 2 ▶ if ( $supertype ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($supertype) 0 2 2
353 0 return Type::Tiny::CMP_SUPERTYPE;
354 }
355 } #/ if ( $B->isa( __PACKAGE__...))
356
357 162 return Type::Tiny::CMP_UNKNOWN;
358 41 };
359  
360 41 1;
361  
362 __END__
« lib/Type/Registry.pm ↑ Summary blib/lib/Type/Utils.pm »