| 1 | 18 | ▶ | use 5.008005; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 18 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 18 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 18 | ▶ | use XSLoader (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | package Type::Tiny::XS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 18 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 18 | our $VERSION = '0.025'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 18 | __PACKAGE__->XSLoader::load( $VERSION ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 18 | ▶ | use Scalar::Util qw(refaddr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 18 | my %names = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | map +( $_ => __PACKAGE__ . "::$_" ), qw/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | Any ArrayRef Bool ClassName CodeRef Defined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | FileHandle GlobRef HashRef Int Num Object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | Ref RegexpRef ScalarRef Str Undef Value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | PositiveInt PositiveOrZeroInt NonEmptyStr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ArrayLike HashLike CodeLike StringLike | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | Map Tuple Enum AnyOf AllOf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | / | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 18 | $names{Item} = $names{Any}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 18 | ▶ | if ( $] lt '5.010000' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | require MRO::Compat; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | *Type::Tiny::XS::Util::get_linear_isa = \&mro::get_linear_isa; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | my $overloaded = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | require overload; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | overload::Overloaded( ref $_[0] or $_[0] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $_[0] || $_[0]
ref $_[0] || $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | and overload::Method( ( ref $_[0] or $_[0] ), $_[1] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 18 | ▶ | no warnings qw( uninitialized redefine once ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | *StringLike = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | defined( $_[0] ) && !ref( $_[0] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
defined $_[0] && !ref($_[0]) || builtin::blessed($_[0]) && &$overloaded($_[0], '""')
defined $_[0] and not ref $_[0]
builtin::blessed($_[0]) and &$overloaded($_[0], "\"\"")
MC/DC0%0/4
defined $_[0] && !ref($_[0]) || builtin::blessed($_[0]) && &$overloaded($_[0], '""')
defined $_[0]
not ref $_[0]
builtin::blessed($_[0])
&$overloaded($_[0], "\"\"")
Truth table0%0/7
A and not(B) || C and D
A= defined $_[0]B= not ref $_[0]C= builtin::blessed($_[0])D= &$overloaded($_[0], "\"\"")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | or Scalar::Util::blessed( $_[0] ) && $overloaded->( $_[0], q[""] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | *CodeLike = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | ref( $_[0] ) eq 'CODE' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $_[0] eq 'CODE' || builtin::blessed($_[0]) && &$overloaded($_[0], '&{}')
builtin::blessed($_[0]) and &$overloaded($_[0], "&{}")
MC/DC0%0/3
ref $_[0] eq 'CODE' || builtin::blessed($_[0]) && &$overloaded($_[0], '&{}')
ref $_[0] eq 'CODE'
builtin::blessed($_[0])
&$overloaded($_[0], "&{}")
Truth table0%0/4
A || B and C
A= ref $_[0] eq 'CODE'B= builtin::blessed($_[0])C= &$overloaded($_[0], "&{}")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | or Scalar::Util::blessed( $_[0] ) && $overloaded->( $_[0], q[&{}] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | *HashLike = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | ref( $_[0] ) eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $_[0] eq 'HASH' || builtin::blessed($_[0]) && &$overloaded($_[0], '%{}')
builtin::blessed($_[0]) and &$overloaded($_[0], "%{}")
MC/DC0%0/3
ref $_[0] eq 'HASH' || builtin::blessed($_[0]) && &$overloaded($_[0], '%{}')
ref $_[0] eq 'HASH'
builtin::blessed($_[0])
&$overloaded($_[0], "%{}")
Truth table0%0/4
A || B and C
A= ref $_[0] eq 'HASH'B= builtin::blessed($_[0])C= &$overloaded($_[0], "%{}")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | or Scalar::Util::blessed( $_[0] ) && $overloaded->( $_[0], q[%{}] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | *ArrayLike = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | ref( $_[0] ) eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $_[0] eq 'ARRAY' || builtin::blessed($_[0]) && &$overloaded($_[0], '@{}')
builtin::blessed($_[0]) and &$overloaded($_[0], "\@{}")
MC/DC0%0/3
ref $_[0] eq 'ARRAY' || builtin::blessed($_[0]) && &$overloaded($_[0], '@{}')
ref $_[0] eq 'ARRAY'
builtin::blessed($_[0])
&$overloaded($_[0], "\@{}")
Truth table0%0/4
A || B and C
A= ref $_[0] eq 'ARRAY'B= builtin::blessed($_[0])C= &$overloaded($_[0], "\@{}")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | or Scalar::Util::blessed( $_[0] ) && $overloaded->( $_[0], q[@{}] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } #/ if ( $] < '5.010000' [) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 18 | my %coderefs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 579 | ▶ | sub _know { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_know: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 579 | my ( $coderef, $type ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 579 | $coderefs{ refaddr( $coderef ) } = $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 3 | ▶ | sub is_known { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_known: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 3 | my $coderef = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 3 | $coderefs{ refaddr( $coderef ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 18 | for ( reverse sort keys %names ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 18 | ▶ | no strict qw(refs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 558 | _know \&{ $names{$_} }, $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 18 | my $id = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 44 | ▶ | sub get_coderef_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_coderef_for: called CC=41 SCAR=42.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 44 | my $type = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | return do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 18 | ▶ | no strict qw(refs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 23 | \&{ $names{$type} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 44 | ▶ | } if exists $names{$type}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 21 | my $made; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 21 | ▶ | if ( $type =~ /^ArrayRef\[(.+)\]$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 11 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 7 | ▶ | my $child = get_coderef_for( $1 ) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 7 | $made = _parameterize_ArrayRef_for( $child ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ▶ | elsif ( $] ge '5.010000' and $type =~ /^ArrayLike\[(.+)\]$/ ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$] ge "5.010000" and $type =~ /^ArrayLike\[(.+)\]$/
MC/DC50%1/2
$] ge "5.010000" and $type =~ /^ArrayLike\[(.+)\]$/
$] ge "5.010000"
$type =~ /^ArrayLike\[(.+)\]$/
Truth table66%2/3
A and B
A= $] ge "5.010000"B= $type =~ /^ArrayLike\[(.+)\]$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | ▶ | my $child = get_coderef_for( $1 ) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | $made = _parameterize_ArrayLike_for( $child ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | elsif ( $type =~ /^HashRef\[(.+)\]$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | ▶ | my $child = get_coderef_for( $1 ) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | $made = _parameterize_HashRef_for( $child ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | ▶ | elsif ( $] ge '5.010000' and $type =~ /^HashLike\[(.+)\]$/ ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$] ge "5.010000" and $type =~ /^HashLike\[(.+)\]$/
MC/DC50%1/2
$] ge "5.010000" and $type =~ /^HashLike\[(.+)\]$/
$] ge "5.010000"
$type =~ /^HashLike\[(.+)\]$/
Truth table66%2/3
A and B
A= $] ge "5.010000"B= $type =~ /^HashLike\[(.+)\]$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | ▶ | my $child = get_coderef_for( $1 ) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | $made = _parameterize_HashLike_for( $child ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | elsif ( $type =~ /^Map\[(.+),(.+)\]$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 2 | my @children; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 2 | ▶ | if ( eval { require Type::Parser } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 2 | @children = map scalar( get_coderef_for( $_ ) ), _parse_parameters( $type ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | push @children, get_coderef_for( $1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | push @children, get_coderef_for( $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 2 | ▶ | @children == 2 or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | ▶ | defined or return for @children; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | $made = _parameterize_Map_for( \@children ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } #/ elsif ( $type =~ /^Map\[(.+),(.+)\]$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | elsif ( $type =~ /^(AnyOf|AllOf|Tuple)\[(.+)\]$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 4 | my $base = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | my @children = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | map scalar( get_coderef_for( $_ ) ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 4 | ▶ | ( eval { require Type::Parser } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | ? _parse_parameters( $type ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | : split( /,/, $2 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 4 | ▶ | defined or return for @children; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 4 | my $maker = __PACKAGE__->can( "_parameterize_${base}_for" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 4 | ▶ | $made = $maker->( \@children ) if $maker; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } #/ elsif ( $type =~ /^(AnyOf|AllOf|Tuple)\[(.+)\]$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | elsif ( $type =~ /^Maybe\[(.+)\]$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | my $child = get_coderef_for( $1 ) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | $made = _parameterize_Maybe_for( $child ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | elsif ( $type =~ /^InstanceOf\[(.+)\]$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | my $class = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 1 | ▶ | return unless Type::Tiny::XS::Util::is_valid_class_name( $class ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 1 | $made = Type::Tiny::XS::Util::generate_isa_predicate_for( $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | elsif ( $type =~ /^HasMethods\[(.+)\]$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my $methods = [ sort( split /,/, $1 ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | /^[^\W0-9]\w*$/ or return for @$methods; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $made = Type::Tiny::XS::Util::generate_can_predicate_for( $methods ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # Type::Tiny::Enum > 1.010003 double-quotes its enums | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | elsif ( $type =~ /^Enum\[".*"\]$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | ▶ | if ( eval { require Type::Parser } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | my $parsed = Type::Parser::parse( $type ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | ▶ | if ( $parsed->{type} eq "parameterized" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | my @todo = $parsed->{params}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | my @strings; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | my $bad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 1 | ▶ | while ( my $todo = shift @todo ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 6 | ▶ | if ( $todo->{type} eq 'list' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | push @todo, @{ $todo->{list} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | ▶ | elsif ( $todo->{type} eq "expression" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$todo->{"type"} eq "expression" and $todo->{"op"}->type eq Type::Parser::COMMA()
MC/DC50%1/2
$todo->{"type"} eq "expression" and $todo->{"op"}->type eq Type::Parser::COMMA()
$todo->{"type"} eq "expression"
$todo->{"op"}->type eq Type::Parser::COMMA()
Truth table66%2/3
A and B
A= $todo->{"type"} eq "expression"B= $todo->{"op"}->type eq Type::Parser::COMMA()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | && $todo->{op}->type eq Type::Parser::COMMA() ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 2 | push @todo, $todo->{lhs}, $todo->{rhs}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ▶ | elsif ( $todo->{type} eq "primary" && $todo->{token}->type eq "QUOTELIKE" ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$todo->{"type"} eq "primary" and $todo->{"token"}->type eq "QUOTELIKE"
MC/DC0%0/2
$todo->{"type"} eq "primary" and $todo->{"token"}->type eq "QUOTELIKE"
$todo->{"type"} eq "primary"
$todo->{"token"}->type eq "QUOTELIKE"
Truth table33%1/3
A and B
A= $todo->{"type"} eq "primary"B= $todo->{"token"}->type eq "QUOTELIKE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 3 | push @strings, eval( $todo->{token}->spelling ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | # Unexpected entry in the parse-tree, bail out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $bad = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } #/ while ( my $todo = shift ...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | ▶ | $made = _parameterize_Enum_for( \@strings ) unless $bad; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } #/ if ( $parsed->{type} eq...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } #/ if ( eval { require Type::Parser...}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } #/ elsif ( $type =~ /^Enum\[".*"\]$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | elsif ( $type =~ /^Enum\[(.+)\]$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 2 | my $strings = [ sort( split /,/, $1 ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 2 | $made = _parameterize_Enum_for( $strings ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 21 | ▶ | if ( $made ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 18 | ▶ | no strict qw(refs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 21 | my $slot = sprintf( '%s::AUTO::TC%d', __PACKAGE__, ++$id ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 21 | $names{$type} = $slot; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 21 | _know( $made, $type ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 21 | *$slot = $made; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 21 | return $made; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } #/ sub get_coderef_for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | sub get_subname_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_subname_for: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my $type = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | get_coderef_for( $type ) unless exists $names{$type}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $names{$type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 6 | ▶ | sub _parse_parameters { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_parameters: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 6 | my $got = Type::Parser::parse( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 6 | ▶ | $got->{params} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 6 | _handle_expr( $got->{params} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 51 | ▶ | sub _handle_expr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handle_expr: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 51 | my $e = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 51 | ▶ | if ( $e->{type} eq 'list' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 11 | return map _handle_expr( $_ ), @{ $e->{list} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 40 | ▶ | if ( $e->{type} eq 'parameterized' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 5 | my ( $base ) = _handle_expr( $e->{base} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 5 | my @params = _handle_expr( $e->{params} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 5 | return sprintf( '%s[%s]', $base, join( q[,], @params ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 35 | ▶ | if ( $e->{type} eq 'expression' and $e->{op}->type eq Type::Parser::COMMA() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$e->{"type"} eq "expression" and $e->{"op"}->type eq Type::Parser::COMMA()
MC/DC50%1/2
$e->{"type"} eq "expression" and $e->{"op"}->type eq Type::Parser::COMMA()
$e->{"type"} eq "expression"
$e->{"op"}->type eq Type::Parser::COMMA()
Truth table66%2/3
A and B
A= $e->{"type"} eq "expression"B= $e->{"op"}->type eq Type::Parser::COMMA()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 12 | return _handle_expr( $e->{lhs} ), _handle_expr( $e->{rhs} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 23 | ▶ | if ( $e->{type} eq 'primary' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 23 | return $e->{token}->spelling; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | '****'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } #/ sub _handle_expr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 18 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||