| 1 | package Type::Registry; | ||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||
| 3 | 32 | ▶ | use 5.008001; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 4 | 32 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 5 | 32 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||
| 7 | 32 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 8 | 32 | $Type::Registry::AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||||
| 9 | 32 | $Type::Registry::VERSION = '2.010001'; | |||||||||||||||||||||||||||||||||||||||
| 10 | } | ||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||
| 12 | 32 | $Type::Registry::VERSION =~ tr/_//d; | |||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||
| 14 | 32 | ▶ | use Exporter::Tiny qw( mkopt ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 15 | 32 | ▶ | use Scalar::Util qw( refaddr ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 16 | 32 | ▶ | use Type::Parser qw( eval_type ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 17 | 32 | ▶ | use Types::TypeTiny (); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||
| 19 | 32 | our @ISA = 'Exporter::Tiny'; | |||||||||||||||||||||||||||||||||||||||
| 20 | 32 | our @EXPORT_OK = qw(t); | |||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||
| 22 | 4 | ▶ | sub _croak ($;@) { require Error::TypeTiny; goto \&Error::TypeTiny::croak } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_croak: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||
| 24 | 15 | ▶ | sub _generate_t { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_t: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||
| 25 | 15 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||
| 26 | 15 | my ( $name, $value, $globals ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||
| 28 | 15 | my $reg; | |||||||||||||||||||||||||||||||||||||||
| 29 | 15 | ▶ | if ( $globals->{lexical} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | ▶ | if ( ref($value) eq 'HASH' and exists $value->{for_class} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $value eq "HASH" and exists $value->{"for_class"}
MC/DC0%0/2
ref $value eq "HASH" and exists $value->{"for_class"}
ref $value eq "HASH"
exists $value->{"for_class"}
Truth table33%1/3
A and B
A= ref $value eq "HASH"B= exists $value->{"for_class"}
| |||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | $reg = $class->for_class( $value->{for_class} ); | |||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||
| 33 | else { | ||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | $reg = $class->new; | |||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||
| 37 | else { | ||||||||||||||||||||||||||||||||||||||||
| 38 | 13 | $reg = $class->_for_class_or_ref( $globals->{into} ); | |||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||
| 41 | 15 | ▶ | sub (;$) { @_ ? $reg->lookup( @_ ) : $reg }; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 42 | } #/ sub _generate_t | ||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||
| 44 | 112 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 45 | 112 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||
| 46 | 112 | ▶ | ref( $class ) and _croak( "Not an object method" ); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 47 | 112 | bless {}, $class; | |||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||
| 50 | { | ||||||||||||||||||||||||||||||||||||||||
| 51 | 32 | my %registries; | |||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||
| 53 | 625 | ▶ | sub for_class { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
for_class: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 54 | 625 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||
| 55 | 625 | my ( $for ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 56 | 625 | ▶ | my $reg = ( $registries{$for} ||= $class->new ); | ||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$registries{$for} ||= $class->new
MC/DC0%0/2
$registries{$for} ||= $class->new
$registries{$for}
$class->new
Truth table66%2/3
A ||= B
A= $registries{$for}B= $class->new
| |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||
| 59 | 23 | ▶ | sub for_me { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
for_me: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 60 | 23 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||
| 61 | 23 | my $for = caller; | |||||||||||||||||||||||||||||||||||||||
| 62 | 23 | ▶ | $registries{$for} ||= $class->new; | ||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$registries{$for} ||= $class->new
MC/DC0%0/2
$registries{$for} ||= $class->new
$registries{$for}
$class->new
Truth table66%2/3
A ||= B
A= $registries{$for}B= $class->new
| |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||
| 65 | 13 | ▶ | sub _for_class_or_ref { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_for_class_or_ref: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||
| 66 | 13 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||
| 67 | 13 | my ( $for ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 68 | 13 | ▶ | $for = sprintf( 'HASH(0x%08X)', refaddr( $for ) ) if ref $for; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 69 | 13 | ▶ | my $reg = ( $registries{$for} ||= $class->new ); | ||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$registries{$for} ||= $class->new
MC/DC0%0/2
$registries{$for} ||= $class->new
$registries{$for}
$class->new
Truth table66%2/3
A ||= B
A= $registries{$for}B= $class->new
| |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||
| 73 | 32 | ▶ | sub add_types { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_types: called CC=24 SCAR=42.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 74 | 14 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 75 | 14 | my $opts = mkopt( \@_ ); | |||||||||||||||||||||||||||||||||||||||
| 76 | 14 | for my $opt ( @$opts ) { | |||||||||||||||||||||||||||||||||||||||
| 77 | 15 | my ( $library, $types ) = @$opt; | |||||||||||||||||||||||||||||||||||||||
| 78 | 15 | $library =~ s/^-/Types::/; | |||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||
| 80 | { | ||||||||||||||||||||||||||||||||||||||||
| 81 | 15 | ▶ | local $SIG{__DIE__} = sub { }; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 82 | 15 | eval "require $library"; | |||||||||||||||||||||||||||||||||||||||
| 83 | }; | ||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||
| 85 | 15 | my %hash; | |||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||
| 87 | 15 | ▶ | if ( $library->isa( "Type::Library" ) or $library eq 'Types::TypeTiny' ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition100%3/3
$library->isa("Type::Library") or $library eq "Types::TypeTiny"
MC/DC100%2/2
$library->isa("Type::Library") or $library eq "Types::TypeTiny"
$library->isa("Type::Library")
$library eq "Types::TypeTiny"
Truth table100%3/3
A or B
A= $library->isa("Type::Library")B= $library eq "Types::TypeTiny"
| |||||||||||||||||||||||||||||||||||||||||
| 88 | 13 | ▶ | $types ||= [qw/-types/]; | ||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$types ||= ["-types"]
MC/DC100%1/1
$types ||= ["-types"]
$types
Truth table100%2/2
A
A= $types
| |||||||||||||||||||||||||||||||||||||||||
| 89 | 13 | ▶ | Types::TypeTiny::is_ArrayLike( $types ) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 90 | or _croak( | ||||||||||||||||||||||||||||||||||||||||
| 91 | "Expected arrayref following '%s'; got %s", $library, | ||||||||||||||||||||||||||||||||||||||||
| 92 | $types | ||||||||||||||||||||||||||||||||||||||||
| 93 | ); | ||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||
| 95 | 13 | $library->import( { into => \%hash }, @$types ); | |||||||||||||||||||||||||||||||||||||||
| 96 | 13 | $hash{$_} = &{ $hash{$_} }() for keys %hash; | |||||||||||||||||||||||||||||||||||||||
| 97 | } #/ if ( $library->isa( "Type::Library"...)) | ||||||||||||||||||||||||||||||||||||||||
| 98 | ▶ | elsif ( $library->isa( "Exporter" ) | |||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$library->isa("Exporter") and my $type_tag = do {
no strict 'refs';
do {
"${library}::EXPORT_TAGS"
}->{"types"}
}
MC/DC50%1/2
$library->isa("Exporter") and my $type_tag = do {
no strict 'refs';
do {
"${library}::EXPORT_TAGS"
}->{"types"}
}
$library->isa("Exporter")
my $type_tag = do {
no strict 'refs';
do {
"${library}::EXPORT_TAGS"
}->{"types"}
}
Truth table66%2/3
A and B
A= $library->isa("Exporter")B= my $type_tag = do {
no strict 'refs';
do {
"${library}::EXPORT_TAGS"
}->{"types"}
}
| |||||||||||||||||||||||||||||||||||||||||
| 99 | 32 | ▶ | and my $type_tag = do { no strict 'refs'; ${"$library\::EXPORT_TAGS"}{'types'} } ) { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | ▶ | $types ||= $type_tag; | ||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$types ||= $type_tag
MC/DC0%0/2
$types ||= $type_tag
$types
$type_tag
Truth table33%1/3
A ||= B
A= $typesB= $type_tag
| |||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | $hash{$_} = $library->$_ for @$types; | |||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||
| 103 | elsif ( $library->isa( "MooseX::Types::Base" ) ) { | ||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | $types ||= []; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$types ||= []
MC/DC0%0/1
$types ||= []
$types
Truth table0%0/2
A
A= $types
| |||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | Types::TypeTiny::is_ArrayLike( $types ) && ( @$types == 0 ) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
Types::TypeTiny::is_ArrayLike($types) and @$types == 0
MC/DC0%0/2
Types::TypeTiny::is_ArrayLike($types) and @$types == 0
Types::TypeTiny::is_ArrayLike($types)
@$types == 0
Truth table0%0/3
A and B
A= Types::TypeTiny::is_ArrayLike($types)B= @$types == 0
| |||||||||||||||||||||||||||||||||||||||||
| 106 | or _croak( | ||||||||||||||||||||||||||||||||||||||||
| 107 | "Library '%s' is a MooseX::Types type constraint library. No import options currently supported", | ||||||||||||||||||||||||||||||||||||||||
| 108 | $library | ||||||||||||||||||||||||||||||||||||||||
| 109 | ); | ||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | require Moose::Util::TypeConstraints; | |||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my $moosextypes = $library->type_storage; | |||||||||||||||||||||||||||||||||||||||
| 113 | 0 | for my $name ( sort keys %$moosextypes ) { | |||||||||||||||||||||||||||||||||||||||
| 114 | my $tt = Types::TypeTiny::to_TypeTiny( | ||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | Moose::Util::TypeConstraints::find_type_constraint( $moosextypes->{$name} ) ); | |||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $hash{$name} = $tt; | |||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||
| 118 | } #/ elsif ( $library->isa( "MooseX::Types::Base"...)) | ||||||||||||||||||||||||||||||||||||||||
| 119 | elsif ( $library->isa( "MouseX::Types::Base" ) ) { | ||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | $types ||= []; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$types ||= []
MC/DC0%0/1
$types ||= []
$types
Truth table0%0/2
A
A= $types
| |||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | Types::TypeTiny::is_ArrayLike( $types ) && ( @$types == 0 ) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
Types::TypeTiny::is_ArrayLike($types) and @$types == 0
MC/DC0%0/2
Types::TypeTiny::is_ArrayLike($types) and @$types == 0
Types::TypeTiny::is_ArrayLike($types)
@$types == 0
Truth table0%0/3
A and B
A= Types::TypeTiny::is_ArrayLike($types)B= @$types == 0
| |||||||||||||||||||||||||||||||||||||||||
| 122 | or _croak( | ||||||||||||||||||||||||||||||||||||||||
| 123 | "Library '%s' is a MouseX::Types type constraint library. No import options currently supported", | ||||||||||||||||||||||||||||||||||||||||
| 124 | $library | ||||||||||||||||||||||||||||||||||||||||
| 125 | ); | ||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | require Mouse::Util::TypeConstraints; | |||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my $moosextypes = $library->type_storage; | |||||||||||||||||||||||||||||||||||||||
| 129 | 0 | for my $name ( sort keys %$moosextypes ) { | |||||||||||||||||||||||||||||||||||||||
| 130 | my $tt = Types::TypeTiny::to_TypeTiny( | ||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | Mouse::Util::TypeConstraints::find_type_constraint( $moosextypes->{$name} ) ); | |||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $hash{$name} = $tt; | |||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||
| 134 | } #/ elsif ( $library->isa( "MouseX::Types::Base"...)) | ||||||||||||||||||||||||||||||||||||||||
| 135 | else { | ||||||||||||||||||||||||||||||||||||||||
| 136 | 1 | _croak( "%s is not a type library", $library ); | |||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||
| 139 | 14 | for my $key ( sort keys %hash ) { | |||||||||||||||||||||||||||||||||||||||
| 140 | exists( $self->{$key} ) | ||||||||||||||||||||||||||||||||||||||||
| 141 | and $self->{$key}{uniq} != $hash{$key}{uniq} | ||||||||||||||||||||||||||||||||||||||||
| 142 | 523 | ▶ | and _croak( "Duplicate type name: %s", $key ); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $self->{$key} and $self->{$key}{"uniq"} != $hash{$key}{"uniq"}
MC/DC0%0/2
exists $self->{$key} and $self->{$key}{"uniq"} != $hash{$key}{"uniq"}
exists $self->{$key}
$self->{$key}{"uniq"} != $hash{$key}{"uniq"}
Truth table66%2/3
A and B
A= exists $self->{$key}B= $self->{$key}{"uniq"} != $hash{$key}{"uniq"}
| |||||||||||||||||||||||||||||||||||||||||
| 143 | 523 | $self->{$key} = $hash{$key}; | |||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||
| 145 | } #/ for my $opt ( @$opts ) | ||||||||||||||||||||||||||||||||||||||||
| 146 | 13 | $self; | |||||||||||||||||||||||||||||||||||||||
| 147 | } #/ sub add_types | ||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||
| 149 | 2677 | ▶ | sub add_type { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_type: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 150 | 2677 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 151 | 2677 | my ( $type, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 152 | 2677 | $type = Types::TypeTiny::to_TypeTiny( $type ); | |||||||||||||||||||||||||||||||||||||||
| 153 | 2677 | ▶ | $name ||= do { | ||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$name ||= do {
$type->is_anon and &_croak("Expected named type constraint; got anonymous type constraint");
$type->name
}
MC/DC100%2/2
$name ||= do {
$type->is_anon and &_croak("Expected named type constraint; got anonymous type constraint");
$type->name
}
$name
do {
$type->is_anon and &_croak("Expected named type constraint; got anonymous type constraint");
$type->name
}
Truth table100%3/3
A ||= B
A= $nameB= do {
$type->is_anon and &_croak("Expected named type constraint; got anonymous type constraint");
$type->name
}
| |||||||||||||||||||||||||||||||||||||||||
| 154 | 4 | ▶ | $type->is_anon | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 155 | and | ||||||||||||||||||||||||||||||||||||||||
| 156 | _croak( "Expected named type constraint; got anonymous type constraint" ); | ||||||||||||||||||||||||||||||||||||||||
| 157 | 3 | $type->name; | |||||||||||||||||||||||||||||||||||||||
| 158 | }; | ||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||
| 160 | exists( $self->{$name} ) | ||||||||||||||||||||||||||||||||||||||||
| 161 | and $self->{$name}{uniq} != $type->{uniq} | ||||||||||||||||||||||||||||||||||||||||
| 162 | 2676 | ▶ | and _croak( "Duplicate type name: %s", $name ); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $self->{$name} and $self->{$name}{"uniq"} != $type->{"uniq"}
MC/DC0%0/2
exists $self->{$name} and $self->{$name}{"uniq"} != $type->{"uniq"}
exists $self->{$name}
$self->{$name}{"uniq"} != $type->{"uniq"}
Truth table66%2/3
A and B
A= exists $self->{$name}B= $self->{$name}{"uniq"} != $type->{"uniq"}
| |||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||
| 164 | 2676 | $self->{$name} = $type; | |||||||||||||||||||||||||||||||||||||||
| 165 | 2676 | $self; | |||||||||||||||||||||||||||||||||||||||
| 166 | } #/ sub add_type | ||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||
| 168 | 5 | ▶ | sub alias_type { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
alias_type: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 169 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 170 | 5 | my ( $old, @new ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 171 | 5 | ▶ | my $lookup = eval { $self->lookup( $old ) } | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 172 | or _croak( "Expected existing type constraint name; got '$old'" ); | ||||||||||||||||||||||||||||||||||||||||
| 173 | 4 | $self->{$_} = $lookup for @new; | |||||||||||||||||||||||||||||||||||||||
| 174 | 4 | $self; | |||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||
| 177 | 200 | ▶ | sub simple_lookup { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
simple_lookup: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 178 | 200 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||
| 180 | 200 | my ( $tc ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 181 | 200 | $tc =~ s/(^\s+|\s+$)//g; | |||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||
| 183 | 200 | ▶ | if ( exists $self->{$tc} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 184 | 166 | return $self->{$tc}; | |||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||
| 186 | elsif ( $self->has_parent ) { | ||||||||||||||||||||||||||||||||||||||||
| 187 | 2 | return $self->get_parent->simple_lookup( @_ ); | |||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||
| 190 | 32 | return; | |||||||||||||||||||||||||||||||||||||||
| 191 | } #/ sub simple_lookup | ||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||
| 193 | 1 | ▶ | sub set_parent { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_parent: called CC=3 SCAR=12.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 195 | 1 | ▶ | $self->{'~~parent'} = | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||
| 196 | ref( $_[0] ) | ||||||||||||||||||||||||||||||||||||||||
| 197 | ? $_[0] | ||||||||||||||||||||||||||||||||||||||||
| 198 | : ( ref( $self ) || $self )->for_class( $_[0] ); | ||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | $self; | |||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | ▶ | sub clear_parent { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_parent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 204 | 1 | delete $self->{'~~parent'}; | |||||||||||||||||||||||||||||||||||||||
| 205 | 1 | $self; | |||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||
| 208 | 34 | ▶ | sub has_parent { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_parent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 209 | 34 | !!ref( shift->{'~~parent'} ); | |||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||
| 212 | 3 | ▶ | sub get_parent { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_parent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 213 | 3 | shift->{'~~parent'}; | |||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||
| 216 | 4 | ▶ | sub foreign_lookup { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
foreign_lookup: called CC=9 SCAR=29.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 217 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||
| 219 | 4 | ▶ | return $_[1] ? () : $self->simple_lookup( $_[0], 1 ) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 220 | unless $_[0] =~ /^(.+)::(\w+)$/; | ||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | my $library = $1; | |||||||||||||||||||||||||||||||||||||||
| 223 | 1 | my $typename = $2; | |||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||||||||||||||
| 226 | 1 | ▶ | local $SIG{__DIE__} = sub { }; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | eval "require $library;"; | |||||||||||||||||||||||||||||||||||||||
| 228 | }; | ||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | ▶ | if ( $library->isa( 'MooseX::Types::Base' ) ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | require Moose::Util::TypeConstraints; | |||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | my $type = Moose::Util::TypeConstraints::find_type_constraint( | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 233 | $library->get_type( $typename ) ) | ||||||||||||||||||||||||||||||||||||||||
| 234 | or return; | ||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | return Types::TypeTiny::to_TypeTiny( $type ); | |||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||
| 238 | 1 | ▶ | if ( $library->isa( 'MouseX::Types::Base' ) ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | require Mouse::Util::TypeConstraints; | |||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | my $sub = $library->can( $typename ) or return; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | my $type = Mouse::Util::TypeConstraints::find_type_constraint( $sub->() ) | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 242 | or return; | ||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | return Types::TypeTiny::to_TypeTiny( $type ); | |||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||
| 246 | 1 | ▶ | if ( $library->can( "get_type" ) ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 247 | 1 | my $type = $library->get_type( $typename ); | |||||||||||||||||||||||||||||||||||||||
| 248 | 1 | return Types::TypeTiny::to_TypeTiny( $type ); | |||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | return; | |||||||||||||||||||||||||||||||||||||||
| 252 | } #/ sub foreign_lookup | ||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||
| 254 | 39 | ▶ | sub lookup { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
lookup: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 255 | 39 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||
| 257 | 39 | ▶ | $self->simple_lookup( @_ ) or eval_type( $_[0], $self ); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||
| 260 | 1 | ▶ | sub make_union { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_union: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 261 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 262 | 1 | my ( @types ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||
| 264 | 1 | require Type::Tiny::Union; | |||||||||||||||||||||||||||||||||||||||
| 265 | 1 | return "Type::Tiny::Union"->new( type_constraints => \@types ); | |||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||
| 268 | 18 | ▶ | sub _make_union_by_overload { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_union_by_overload: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 269 | 18 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 270 | 18 | my ( @types ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||
| 272 | 18 | require Type::Tiny::Union; | |||||||||||||||||||||||||||||||||||||||
| 273 | 18 | return "Type::Tiny::Union"->new_by_overload( type_constraints => \@types ); | |||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||
| 276 | 1 | ▶ | sub make_intersection { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_intersection: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 277 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 278 | 1 | my ( @types ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||
| 280 | 1 | require Type::Tiny::Intersection; | |||||||||||||||||||||||||||||||||||||||
| 281 | 1 | return "Type::Tiny::Intersection"->new( type_constraints => \@types ); | |||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||
| 284 | 8 | ▶ | sub _make_intersection_by_overload { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_intersection_by_overload: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 285 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 286 | 8 | my ( @types ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||
| 288 | 8 | require Type::Tiny::Intersection; | |||||||||||||||||||||||||||||||||||||||
| 289 | 8 | return "Type::Tiny::Intersection"->new_by_overload( type_constraints => \@types ); | |||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||
| 292 | 10 | ▶ | sub make_class_type { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_class_type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 293 | 10 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 294 | 10 | my ( $class ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||
| 296 | 10 | require Types::Standard; | |||||||||||||||||||||||||||||||||||||||
| 297 | 10 | return Types::Standard::InstanceOf()->of( $class ); | |||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||
| 300 | 3 | ▶ | sub make_role_type { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_role_type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 301 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 302 | 3 | my ( $role ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||
| 304 | 3 | require Types::Standard; | |||||||||||||||||||||||||||||||||||||||
| 305 | 3 | return Types::Standard::ConsumerOf()->of( $role ); | |||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||
| 308 | 17 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||
| 309 | 17 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||
| 310 | 17 | my ( $method ) = ( our $AUTOLOAD =~ /(\w+)$/ ); | |||||||||||||||||||||||||||||||||||||||
| 311 | 17 | my $type = $self->simple_lookup( $method ); | |||||||||||||||||||||||||||||||||||||||
| 312 | 17 | ▶ | return $type if $type; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 313 | 1 | _croak( | |||||||||||||||||||||||||||||||||||||||
| 314 | q[Can't locate object method "%s" via package "%s"], $method, | ||||||||||||||||||||||||||||||||||||||||
| 315 | ref( $self ) | ||||||||||||||||||||||||||||||||||||||||
| 316 | ); | ||||||||||||||||||||||||||||||||||||||||
| 317 | } #/ sub AUTOLOAD | ||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||
| 319 | # Prevent AUTOLOAD being called for DESTROY! | ||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | return; # uncoverable statement | |||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||
| 324 | DELAYED: { | ||||||||||||||||||||||||||||||||||||||||
| 325 | 32 | our %DELAYED; | |||||||||||||||||||||||||||||||||||||||
| 326 | 32 | for my $package ( sort keys %DELAYED ) { | |||||||||||||||||||||||||||||||||||||||
| 327 | 69 | my $reg = __PACKAGE__->for_class( $package ); | |||||||||||||||||||||||||||||||||||||||
| 328 | 69 | my $types = $DELAYED{$package}; | |||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||
| 330 | 69 | for my $name ( sort keys %$types ) { | |||||||||||||||||||||||||||||||||||||||
| 331 | 2146 | $reg->add_type( $types->{$name}, $name ); | |||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||
| 334 | } #/ DELAYED: | ||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||
| 336 | 32 | 1; | |||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||
| 338 | __END__ | ||||||||||||||||||||||||||||||||||||||||