| 1 | package Aion::Types; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # Типы-валидаторы для Aion | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use common::sense; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 8 | ▶ | use warnings FATAL => 'recursion'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 8 | ▶ | use Aion::Meta::Util qw/subref_is_reachable val_to_str/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 8 | ▶ | use Aion::Type; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 8 | ▶ | use Aion::Type::Lim; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use List::Util qw/all any first/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use Exporter qw/import/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 8 | require overload; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 8 | ▶ | use POSIX qw//; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 8 | ▶ | use Scalar::Util qw/looks_like_number reftype refaddr blessed/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 8 | ▶ | use Sub::Util qw//; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | our @EXPORT = our @EXPORT_OK = grep { | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 8 | ▶ | eval {*{$Aion::Types::{$_}}{CODE}} && !/^(_|(NaN|import|all|any|first|looks_like_number|reftype|refaddr|blessed|subref_is_reachable|val_to_str|DBL_MAX)\z)/n | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
eval {
do {
*{$Aion::Types::{$_};}{'CODE'}
}
} && !/^(_|(NaN|import|all|any|first|looks_like_number|reftype|refaddr|blessed|subref_is_reachable|val_to_str|DBL_MAX)\z)/nu
MC/DC100%2/2
eval {
do {
*{$Aion::Types::{$_};}{'CODE'}
}
} && !/^(_|(NaN|import|all|any|first|looks_like_number|reftype|refaddr|blessed|subref_is_reachable|val_to_str|DBL_MAX)\z)/nu
eval {
do {
*{$Aion::Types::{$_};}{'CODE'}
}
}
!/^(_|(NaN|import|all|any|first|looks_like_number|reftype|refaddr|blessed|subref_is_reachable|val_to_str|DBL_MAX)\z)/nu
Truth table100%3/3
A && not(B)
A= eval {
do {
*{$Aion::Types::{$_};}{'CODE'}
}
}B= !/^(_|(NaN|import|all|any|first|looks_like_number|reftype|refaddr|blessed|subref_is_reachable|val_to_str|DBL_MAX)\z)/nu
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | } keys %Aion::Types::; | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | # Обрабатываем атрибут :Isa | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 14 | ▶ | sub MODIFY_CODE_ATTRIBUTES { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
MODIFY_CODE_ATTRIBUTES: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 14 | my ($pkg, $referent, @attributes) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 14 | ▶ | grep { /^Isa\((.*)\)\z/s? do { _Isa($pkg, $referent, $1); 0 }: 1 } @attributes | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 14 | ▶ | sub _Isa { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_Isa: called CC=7 SCAR=19.8
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 14 | my ($pkg, $referent, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 14 | my $subname = Sub::Util::subname $referent; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 14 | $subname =~ s/^.*:://; | |||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 14 | ▶ | die "Anonymous subroutine cannot use :Isa!" if $subname eq '__ANON__'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 14 | my @signature = eval "package $pkg; map { UNIVERSAL::isa(\$_, 'Aion::Type')? \$_: __PACKAGE__->can(\$_)? __PACKAGE__->can(\$_)->(): Aion::Types::External([\$_]) } ($data)"; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 14 | ▶ | die if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 14 | ▶ | die "$pkg\::$subname has no return type!" if @signature == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 14 | require Aion::Meta::Subroutine; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 14 | my $subroutine = Aion::Meta::Subroutine->new( | |||||||||||||||||||||||||||||||||||||||||
| 42 | pkg => $pkg, | ||||||||||||||||||||||||||||||||||||||||||
| 43 | subname => $subname, | ||||||||||||||||||||||||||||||||||||||||||
| 44 | signature => \@signature, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | referent => $referent, | ||||||||||||||||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 14 | ▶ | if(!subref_is_reachable($referent)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 4 | $Aion::META{$pkg}{require}{$subname} = $subroutine; | |||||||||||||||||||||||||||||||||||||||||
| 50 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 10 | my $require = delete $Aion::META{$pkg}{require}{$subname}; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 10 | ▶ | $require->compare($subroutine) if $require; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 10 | my $overload = $Aion::META{$pkg}{subroutine}{$subname}; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 10 | ▶ | $overload->compare($subroutine) if $overload; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 10 | $subroutine->wrap_sub; | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 8 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 8 | ▶ | my $INIT_ARGS = sub { @{&ARGS} = map External([$_]), &ARGS }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 8 | ▶ | my $INIT_KW_ARGS = sub { @{&ARGS} = List::Util::pairmap { $a => External([$b]) } &ARGS }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | my $COMBINE_SUBS = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=4.1
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my ($f1, $f2) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub { $f1->(); $f2->() } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | my $COMBINE_WHERE = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=4.6
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my ($f1, $f2) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | sub { $f1->() && $f2->() } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 317 | ▶ | my $IS_PARAM = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 317 | my @S = @_; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 317 | ▶ | while(@S) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 332 | my $arg = pop @S; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 332 | ▶ | return 1 if UNIVERSAL::isa($arg, 'Aion::Type') && $arg->{is_param}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
UNIVERSAL::isa($arg, "Aion::Type") and $arg->{"is_param"}
MC/DC50%1/2
UNIVERSAL::isa($arg, "Aion::Type") and $arg->{"is_param"}
UNIVERSAL::isa($arg, "Aion::Type")
$arg->{"is_param"}
Truth table66%2/3
A and B
A= UNIVERSAL::isa($arg, "Aion::Type")B= $arg->{"is_param"}
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 321 | push @S, @{$arg->{args}}; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | "" | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 8 | ▶ | my $REPLACE_PARAM; $REPLACE_PARAM = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=11 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 128 | my ($arg) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 128 | ▶ | return $arg unless UNIVERSAL::isa($arg, 'Aion::Type'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 116 | ▶ | if(my $param = $arg->{is_param}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 36 | ▶ | return $Aion::Type::SELF->{args}->[$param - 1] if $param > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | ▶ | return $Aion::Type::SELF->{N} if $param == -1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | ▶ | return $Aion::Type::SELF->{M} if $param == -2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | ▶ | return $Aion::Type::SELF if $param == -256; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | ▶ | return @{$Aion::Type::SELF->{args}} if $param == -1024; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | die "Parameter number invalid!"; | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 80 | ▶ | return $arg if !$arg->{args} || !List::Util::first { UNIVERSAL::isa($_, 'Aion::Type') } @{$arg->{args}}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
Condition33%1/3
$arg->{"args"} and &List::Util::first(sub {
UNIVERSAL::isa($_, "Aion::Type");
}
, @{$$arg{"args"};})
MC/DC0%0/2
$arg->{"args"} and &List::Util::first(sub {
UNIVERSAL::isa($_, "Aion::Type");
}
, @{$$arg{"args"};})
$arg->{"args"}
&List::Util::first(sub {
UNIVERSAL::isa($_, "Aion::Type");
}
, @{$$arg{"args"};})
Truth table33%1/3
A and B
A= $arg->{"args"}B= &List::Util::first(sub {
UNIVERSAL::isa($_, "Aion::Type");
}
, @{$$arg{"args"};})
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 64 | $arg = bless {%$arg}, 'Aion::Type'; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 64 | $arg->{args} = [map $REPLACE_PARAM->($_), @{$arg->{args}}]; | |||||||||||||||||||||||||||||||||||||||||
| 103 | 64 | ▶ | $arg->init if $arg->{init}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 64 | $arg | |||||||||||||||||||||||||||||||||||||||||
| 106 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 20 | ▶ | my $INIT_REPLACE_PARAM = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 20 | $Aion::Type::SELF->{as} = $REPLACE_PARAM->($Aion::Type::SELF->{as}); | |||||||||||||||||||||||||||||||||||||||||
| 110 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | # Создание типа | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 709 | ▶ | sub subtype(@) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subtype: called CC=21 SCAR=30.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 709 | my $subtype = shift; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 709 | my %o = @_; | |||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 709 | my ($as, $init_where, $where, $awhere, $message) = delete @o{qw/as init_where where awhere message/}; | |||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 709 | ▶ | die "subtype $subtype unused keys left: " . join ", ", keys %o if keys %o; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 708 | ▶ | die "subtype format is Name or Name[args] or Name`[args]" if $subtype !~ /^([A-Z_]\w*)(?:(\`)?\[(.*)\])?$/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 708 | my ($name, $is_maybe_arg, $is_arg) = ($1, $2, $3); | |||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 708 | my $pkg = scalar caller; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 708 | ▶ | die "subtype $subtype: ${pkg}::$name exists!" if *{"${pkg}::$name"}{CODE}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 707 | ▶ | if($is_maybe_arg) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 83 | ▶ | die "subtype $subtype: needs an awhere" if !$awhere; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 624 | ▶ | die "subtype $subtype: awhere is excess" if $awhere; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 705 | ▶ | my @init = $init_where? $init_where: (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 705 | my $init_types = do { given($is_arg) { | |||||||||||||||||||||||||||||||||||||||||
| 136 | 705 | $INIT_ARGS when /^[A-Z]\w*(,\s*[A-Z]\w*)?\.\.\.$/; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 673 | $INIT_KW_ARGS when /^[a-z]\w*\s*=>\s*[A-Z],?\s*\.\.\.$/; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 665 | when(/\b[A-Z]\b/) { | |||||||||||||||||||||||||||||||||||||||||
| 139 | 97 | my @args = split /\s*,\s*/, $is_arg; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 97 | my @typeno = grep { $args[$_] =~ /^[A-Z]/ } 0..@args-1; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 97 | ▶ | (sub { my ($typeno) = @_; sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 548 | my $args = &ARGS; | |||||||||||||||||||||||||||||||||||||||||
| 143 | 548 | $args->[$_] = External([$args->[$_]]) for @$typeno; | |||||||||||||||||||||||||||||||||||||||||
| 144 | 97 | } })->(\@typeno); | |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | }}; | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 705 | ▶ | unshift @init, $init_types if $init_types; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 705 | ▶ | $as = External([$as]) if defined $as; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 705 | ▶ | unshift @init, $INIT_REPLACE_PARAM if $as && $is_arg && $IS_PARAM->($as); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$as and $is_arg and &$IS_PARAM($as)
$as and $is_arg
MC/DC100%3/3
$as and $is_arg and &$IS_PARAM($as)
$as
$is_arg
&$IS_PARAM($as)
Truth table100%4/4
A and B and C
A= $asB= $is_argC= &$IS_PARAM($as)
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | # Тут coerce - прототип - единый для всех порождаемых типов одного типа с разными аргументами | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 705 | ▶ | my $type = Aion::Type->new( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition100%2/2
$where // \&Aion::Type::true
MC/DC100%1/1
$where // \&Aion::Type::true
$where
Truth table100%2/2
A
A= $where
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 157 | coerce => [], # prototype | ||||||||||||||||||||||||||||||||||||||||||
| 158 | test => $where // \&Aion::Type::true, | ||||||||||||||||||||||||||||||||||||||||||
| 159 | $as? (as => $as): (), | ||||||||||||||||||||||||||||||||||||||||||
| 160 | @init? (init => \@init): (), | ||||||||||||||||||||||||||||||||||||||||||
| 161 | $awhere? (a_test => $awhere): (), | ||||||||||||||||||||||||||||||||||||||||||
| 162 | $message? (message => $message): (), | ||||||||||||||||||||||||||||||||||||||||||
| 163 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 705 | ▶ | if($is_maybe_arg) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 82 | $type->make_maybe_arg($pkg) | |||||||||||||||||||||||||||||||||||||||||
| 167 | ▶ | } elsif($is_arg || @init) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$is_arg or @init
MC/DC100%2/2
$is_arg or @init
$is_arg
@init
Truth table100%3/3
A or B
A= $is_argB= @init
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 247 | $type->make_arg($pkg, $is_arg) | |||||||||||||||||||||||||||||||||||||||||
| 169 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 376 | $type->make($pkg) | |||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 689 | ▶ | sub as(@) { (as => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 106 | ▶ | sub init_where(&@) { (init_where => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_where: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 560 | ▶ | sub where(&@) { (where => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
where: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 83 | ▶ | sub awhere(&@) { (awhere => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
awhere: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 2 | ▶ | sub message(&@) { (message => @_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
message: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 49 | ▶ | sub SELF() { $Aion::Type::SELF } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SELF: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 4726 | ▶ | sub ARGS() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ARGS: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 4726 | ▶ | return $Aion::Type::SELF->{is_param_args} if $Aion::Type::SELF->{is_param_args}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 2189 | wantarray? @{$Aion::Type::SELF->{args}}: $Aion::Type::SELF->{args} | |||||||||||||||||||||||||||||||||||||||||
| 185 | 4725 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 396 | ▶ | sub A() { $Aion::Type::SELF->{args}[0] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
A: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 218 | ▶ | sub B() { $Aion::Type::SELF->{args}[1] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
B: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 2 | ▶ | sub C() { $Aion::Type::SELF->{args}[2] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
C: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 1 | ▶ | sub D() { $Aion::Type::SELF->{args}[3] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
D: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 80 | ▶ | sub M() :lvalue { $Aion::Type::SELF->{M} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
M: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 9 | ▶ | sub N() :lvalue { $Aion::Type::SELF->{N} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
N: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | # Создание транслятора. У типа может быть сколько угодно трансляторов из других типов | ||||||||||||||||||||||||||||||||||||||||||
| 195 | # coerce Type, from OtherType, via {...} | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 58 | ▶ | sub coerce(@) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coerce: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 58 | my ($type, %o) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 198 | 58 | my ($from, $via) = delete @o{qw/from via/}; | |||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 58 | ▶ | die "coerce $type unused keys left: " . join ", ", keys %o if keys %o; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 57 | ▶ | die "coerce $type not Aion::Type!" unless UNIVERSAL::isa($type, "Aion::Type"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 56 | ▶ | die "coerce $type: from is'nt Aion::Type!" unless UNIVERSAL::isa($from, "Aion::Type"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 54 | ▶ | die "coerce $type: via is not subroutine!" unless ref $via eq "CODE"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 52 | push @{$type->{coerce}}, [$from, $via]; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 52 | return; | |||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 54 | ▶ | sub from($) { (from => $_[0]) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 52 | ▶ | sub via(&) { (via => $_[0]) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
via: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 8 | ▶ | use constant DBL_MAX => do { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 8 | my $ieee_dbl_max_str = '1.7976931348623157e+308'; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 8 | ▶ | ($ieee_dbl_max_str+0) =~ /inf/i? do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | require Math::BigFloat; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | Math::BigFloat->new($ieee_dbl_max_str) | |||||||||||||||||||||||||||||||||||||||||
| 217 | }: $ieee_dbl_max_str+0 | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | ▶ | sub _8BITS() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_8BITS: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 1 | undef *_8BITS; | |||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | require Math::BigInt; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 1 | my $_8bits = Math::BigInt->new(8); | |||||||||||||||||||||||||||||||||||||||||
| 224 | 1 | constant->import(_8BITS => $_8bits); | |||||||||||||||||||||||||||||||||||||||||
| 225 | 1 | $_8bits | |||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 8 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 8 | subtype "Any"; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 8 | subtype "Control", as &Any; | |||||||||||||||||||||||||||||||||||||||||
| 232 | subtype "Union[A, B...]", as &Control, | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 8 | ▶ | where { my $val = $_; any { $_->include($val) } ARGS }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | subtype "Intersection[A, B...]", as &Control, | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 8 | ▶ | where { my $val = $_; all { $_->include($val) } ARGS }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | subtype "Exclude[A]", as &Control, | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 8 | ▶ | where { !A->test }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | subtype "Option[A]", as &Control, | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 4 | ▶ | init_where { SELF->{is_option} = 1 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 8 | ▶ | where { A->test }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | subtype "Wantarray[A, S]", as &Control, | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 1 | ▶ | init_where { SELF->{is_wantarray} = 1 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | where { ... }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 8 | subtype "Item", as &Any; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 7307 | ▶ | sub External($) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
External: called CC=7 SCAR=19.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 7307 | local $_ = $_[0][0]; | |||||||||||||||||||||||||||||||||||||||||
| 248 | UNIVERSAL::isa($_, 'Aion::Type')? $_: | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 7307 | ▶ | defined($_) && ref $_ eq ""? Object([$_]): do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $_ and ref $_ eq ""
MC/DC50%1/2
defined $_ and ref $_ eq ""
defined $_
ref $_ eq ""
Truth table66%2/3
A and B
A= defined $_B= ref $_ eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | die "Not External[${\val_to_str($_)}]" unless reftype($_) eq "CODE" || overload::Method($_, '&{}'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::reftype($_) eq "CODE" or overload::Method($_, "&{}")
MC/DC0%0/2
builtin::reftype($_) eq "CODE" or overload::Method($_, "&{}")
builtin::reftype($_) eq "CODE"
overload::Method($_, "&{}")
Truth table66%2/3
A or B
A= builtin::reftype($_) eq "CODE"B= overload::Method($_, "&{}")
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | Aion::Type->new( | ||||||||||||||||||||||||||||||||||||||||||
| 252 | name => 'External', | ||||||||||||||||||||||||||||||||||||||||||
| 253 | as => &Item, | ||||||||||||||||||||||||||||||||||||||||||
| 254 | args => $_[0], | ||||||||||||||||||||||||||||||||||||||||||
| 255 | test => $_, | ||||||||||||||||||||||||||||||||||||||||||
| 256 | UNIVERSAL::can($_, 'coerce') | ||||||||||||||||||||||||||||||||||||||||||
| 257 | 6 | ▶ | ? (coerce => [[&Any, (sub { my ($ex) = @_; sub { $ex->coerce } })->($_)]]) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | : (), | ||||||||||||||||||||||||||||||||||||||||||
| 259 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | 8 | ▶ | subtype "Bool", as &Item, where { ref $_ eq "" and /^(1|0|)\z/ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | 8 | ▶ | subtype "BoolLike", as &Item, where { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 8 | ▶ | return 1 if overload::Method($_, 'bool'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 6 | my $m = overload::Method($_, '0+'); | |||||||||||||||||||||||||||||||||||||||||
| 266 | 8 | ▶ | Bool()->include($m ? $m->($_) : $_) }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | subtype "Enum[e...]", as &Item, | ||||||||||||||||||||||||||||||||||||||||||
| 268 | 57 | ▶ | init_where { M = +{ map {($_ => $_)} ARGS } } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | 8 | ▶ | where { exists M->{$_} }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 8 | ▶ | subtype "Undef", as &Item, where { !defined $_ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 8 | subtype "Maybe[A]", as &Undef | A; | |||||||||||||||||||||||||||||||||||||||||
| 272 | 8 | ▶ | subtype "Defined", as &Item, where { defined $_ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | 8 | ▶ | subtype "Value", as &Defined, where { "" eq ref $_ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 8 | ▶ | subtype "Version", as &Value, where { "VSTRING" eq ref \$_ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 8 | ▶ | subtype "Str", as &Value, where { "SCALAR" eq ref \$_ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 8 | ▶ | subtype "Uni", as &Str, where { utf8::is_utf8($_) || /[\x80-\xFF]/a }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 8 | ▶ | subtype "Bin", as &Str, where { !utf8::is_utf8($_) && !/[\x80-\xFF]/a }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Condition100%3/3
utf8::is_utf8($_) || /[\x80-\xFF]/a
MC/DC100%2/2
utf8::is_utf8($_) || /[\x80-\xFF]/a
utf8::is_utf8($_)
/[\x80-\xFF]/a
Truth table100%3/3
A || B
A= utf8::is_utf8($_)B= /[\x80-\xFF]/a
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 8 | ▶ | subtype "NonEmptyStr", as &Str, where { /\S/ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | subtype "StartsWith[start]", as &Str, | ||||||||||||||||||||||||||||||||||||||||||
| 280 | 2 | ▶ | init_where { M = qr/^${\ quotemeta A}/ }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | 8 | ▶ | where { $_ =~ M }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | subtype "EndsWith[end]", as &Str, | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 2 | ▶ | init_where { N = qr/${\ quotemeta A}$/ }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 8 | ▶ | where { $_ =~ N }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | 8 | ▶ | subtype "Email", as &Str, where { /@/ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | 8 | ▶ | subtype "Tel", as &Str, where { /^\+\d{7,}\z/ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | 8 | ▶ | subtype "Url", as &Str, where { /^https?:\/\// }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | 8 | ▶ | subtype "Path", as &Str, where { /^\// }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 8 | ▶ | subtype "Html", as &Str, where { /^\s*<(!doctype\s+html|html)\b/i }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | 8 | ▶ | subtype "StrDate", as &Str, where { /^\d{4}-\d{2}-\d{2}\z/ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 8 | ▶ | subtype "StrDateTime", as &Str, where { /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\z/ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 8 | ▶ | subtype "StrMatch[regexp]", as &Str, where { $_ =~ A }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 8 | ▶ | subtype "PackageName", as &Str, where { no utf8; use bytes; /^(?:[a-z]\w*(?:::[a-z]\w*)*)\z/ia }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 8 | ▶ | subtype "ClassName", as &PackageName, where { !!$_->can('new') }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 8 | ▶ | subtype "RoleName", as &PackageName, where { !$_->can('new') && !!(@{"$_\::ISA"} || first { *{$_}{CODE} } values %{"$_\::"}) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Condition100%6/6
$_->can('new') || !(@{"${_}::ISA";} || &first(sub {
*{$_;}{'CODE'};
}
, values %{"${_}::";}))
@{"${_}::ISA";} || &first(sub {
*{$_;}{'CODE'};
}
, values %{"${_}::";})
MC/DC100%3/3
$_->can('new') || !(@{"${_}::ISA";} || &first(sub {
*{$_;}{'CODE'};
}
, values %{"${_}::";}))
$_->can('new')
@{"${_}::ISA";}
&first(sub {
*{$_;}{'CODE'};
}
, values %{"${_}::";})
Truth table100%4/4
A || not(B || C)
A= $_->can('new')B= @{"${_}::ISA";}C= &first(sub {
*{$_;}{'CODE'};
}
, values %{"${_}::";})
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | 8 | ▶ | subtype "StrRat", as &Str, where { m!\s*/\s*!? &Num->include($`) && &Num->include($`): &Num->test }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.7
Branch: 1 branch
Condition33%1/3
&Num->include($`) and &Num->include($`)
MC/DC0%0/2
&Num->include($`) and &Num->include($`)
&Num->include($`)
&Num->include($`)
Truth table33%1/3
A and B
A= &Num->include($`)B= &Num->include($`)
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 8 | ▶ | subtype "Num", as &Str, where { looks_like_number($_) && /[\dfn]\z/i }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 8 | ▶ | subtype "Int", as &Num, where { /^[-+]?\d+\z/ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | 8 | ▶ | subtype "Ref", as &Defined, where { "" ne ref $_ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 301 | subtype "Tied`[class]", as &Ref, | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 7 | ▶ | where { my $ref = reftype($_); !!( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 7 | ▶ | $ref eq "HASH"? tied %$_: | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | $ref eq "ARRAY"? tied @$_: | ||||||||||||||||||||||||||||||||||||||||||
| 305 | $ref eq "SCALAR"? tied $$_: | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ||||||||||||||||||||||||||||||||||||||||||
| 307 | ) } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 7 | ▶ | awhere { my $ref = reftype($_); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | 7 | ▶ | $ref eq "HASH"? A eq ref tied %$_: | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | $ref eq "ARRAY"? A eq ref tied @$_: | ||||||||||||||||||||||||||||||||||||||||||
| 311 | $ref eq "SCALAR"? A eq ref tied $$_: | ||||||||||||||||||||||||||||||||||||||||||
| 312 | "" | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 314 | 8 | ▶ | subtype "LValueRef", as &Ref, where { ref $_ eq "LVALUE" }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 8 | ▶ | subtype "FormatRef", as &Ref, where { ref $_ eq "FORMAT" }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | 8 | ▶ | subtype "CodeRef", as &Ref, where { ref $_ eq "CODE" }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | 8 | ▶ | subtype "NamedCode[subname]", as &CodeRef, where { Sub::Util::subname($_) ~~ A }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | 8 | ▶ | subtype "ProtoCode[prototype]", as &CodeRef, where { Sub::Util::prototype($_) ~~ A }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 8 | ▶ | subtype "ForwardRef", as &CodeRef, where { !subref_is_reachable($_) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 8 | ▶ | subtype "ImplementRef", as &CodeRef, where { subref_is_reachable($_) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | subtype "Isa[type...]", as &CodeRef, | ||||||||||||||||||||||||||||||||||||||||||
| 322 | 5 | ▶ | init_where { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 5 | my $pkg = caller(2); | |||||||||||||||||||||||||||||||||||||||||
| 324 | 5 | ▶ | SELF->{args} = [ map { External([UNIVERSAL::isa($_, 'Aion::Type')? $_: $pkg->can($_)? $pkg->can($_)->(): $_]) } ARGS ]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 5 | ▶ | where { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | 5 | ▶ | my $subroutine = $Aion::Isa{pack "J", refaddr $_} or return ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | 4 | my $signature = $subroutine->{signature}; | |||||||||||||||||||||||||||||||||||||||||
| 329 | 4 | my $args = ARGS; | |||||||||||||||||||||||||||||||||||||||||
| 330 | 4 | ▶ | return "" if @$signature != @$args; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 3 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||
| 332 | 3 | for my $type (@$args) { | |||||||||||||||||||||||||||||||||||||||||
| 333 | 8 | ▶ | return "" unless $signature->[$i++] eq $type; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 1 | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 337 | 8 | ▶ | subtype "RegexpRef", as &Ref, where { ref $_ eq "Regexp" }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | subtype "ValueRef`[A]", as &Ref, | ||||||||||||||||||||||||||||||||||||||||||
| 339 | 10 | ▶ | where { ref($_) ~~ ["SCALAR", "REF"] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 8 | ▶ | awhere { ref($_) ~~ ["SCALAR", "REF"] && A->include($$_) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | subtype "ScalarRef`[A]", as &ValueRef, | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 2 | ▶ | where { ref $_ eq "SCALAR" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | 8 | ▶ | awhere { ref $_ eq "SCALAR" && A->include($$_) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | subtype "RefRef`[A]", as &ValueRef, | ||||||||||||||||||||||||||||||||||||||||||
| 345 | 2 | ▶ | where { ref $_ eq "REF" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 8 | ▶ | awhere { ref $_ eq "REF" && A->include($$_) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | 8 | ▶ | subtype "GlobRef", as &Ref, where { ref $_ eq "GLOB" }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | subtype "FileHandle", as &GlobRef, | ||||||||||||||||||||||||||||||||||||||||||
| 349 | 8 | ▶ | where { !!*$_{IO} }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | subtype "ArrayRef`[A]", as &Ref, | ||||||||||||||||||||||||||||||||||||||||||
| 351 | 31 | ▶ | where { ref $_ eq "ARRAY" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 8 | ▶ | awhere { my $A = A; ref $_ eq "ARRAY" && all { $A->test } @$_ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | subtype "Tuple[A...]", as &ArrayRef, | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 18 | ▶ | where { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | 18 | my $k = 0; | |||||||||||||||||||||||||||||||||||||||||
| 356 | 18 | for my $A (ARGS) { | |||||||||||||||||||||||||||||||||||||||||
| 357 | 25 | ▶ | return "" if $A->exclude($_->[$k++]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||
| 359 | 14 | $k == @$_ | |||||||||||||||||||||||||||||||||||||||||
| 360 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 361 | subtype "CycleTuple[A...]", as &ArrayRef, | ||||||||||||||||||||||||||||||||||||||||||
| 362 | 4 | ▶ | where { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 4 | my $k = 0; | |||||||||||||||||||||||||||||||||||||||||
| 364 | 4 | ▶ | while($k < @$_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | 7 | for my $A (ARGS) { | |||||||||||||||||||||||||||||||||||||||||
| 366 | 14 | ▶ | return "" if $A->exclude($_->[$k++]); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | 2 | $k == @$_ | |||||||||||||||||||||||||||||||||||||||||
| 370 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 371 | subtype "HashRef`[A]", as &Ref, | ||||||||||||||||||||||||||||||||||||||||||
| 372 | 123 | ▶ | where { ref $_ eq "HASH" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 8 | ▶ | awhere { my $A = A; ref $_ eq "HASH" && all { $A->test } values %$_ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | subtype "Dict[k => A, ...]", as &HashRef, | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 7 | ▶ | where { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | 7 | my $count = 0; my $k; | |||||||||||||||||||||||||||||||||||||||||
| 377 | 7 | for my $A (ARGS) { | |||||||||||||||||||||||||||||||||||||||||
| 378 | 28 | ▶ | $k = $A, next unless ref $A; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 14 | ▶ | if(exists $_->{$k}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | 11 | ▶ | return "" if $A->exclude($_->{$k}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | 10 | $count++; | |||||||||||||||||||||||||||||||||||||||||
| 382 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 383 | 3 | ▶ | return "" if !exists $A->{is_option}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||
| 386 | 5 | $count == keys %$_ | |||||||||||||||||||||||||||||||||||||||||
| 387 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 388 | subtype "Map[K, V]", as &HashRef, | ||||||||||||||||||||||||||||||||||||||||||
| 389 | 5 | ▶ | where { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | 5 | my ($K, $V) = ARGS; | |||||||||||||||||||||||||||||||||||||||||
| 391 | 5 | ▶ | while(my ($k, $v) = each %$_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 392 | 5 | ▶ | return "" unless $K->include($k) && $V->include($v); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$K->include($k) and $V->include($v)
MC/DC100%2/2
$K->include($k) and $V->include($v)
$K->include($k)
$V->include($v)
Truth table100%3/3
A and B
A= $K->include($k)B= $V->include($v)
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 395 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 396 | subtype "Object`[class]", as &Ref, | ||||||||||||||||||||||||||||||||||||||||||
| 397 | 27 | ▶ | where { blessed($_) ne "" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | 8 | ▶ | awhere { blessed($_) && $_->isa(A) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 399 | subtype "Me", as &Object, | ||||||||||||||||||||||||||||||||||||||||||
| 400 | 8 | ▶ | init_where { SELF->{as} = Object([caller(2)]) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | 8 | subtype "Rat", as 'Math::BigRat'; | |||||||||||||||||||||||||||||||||||||||||
| 402 | subtype "RegexpLike", as &Ref, | ||||||||||||||||||||||||||||||||||||||||||
| 403 | 8 | ▶ | where { reftype($_) eq "REGEXP" || !!overload::Method($_, 'qr') }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | subtype "CodeLike", as &Ref, | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 8 | ▶ | where { reftype($_) eq "CODE" || !!overload::Method($_, '&{}') }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | subtype "ArrayLike`[A]", as &Ref, | ||||||||||||||||||||||||||||||||||||||||||
| 407 | 13 | ▶ | where { reftype($_) eq "ARRAY" || !!overload::Method($_, '@{}') } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | 8 | ▶ | awhere { &ArrayLike->test && do { my $A = A; all { $A->test } @$_ }}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 409 | subtype "Lim[from, to?]", as &ArrayLike, | ||||||||||||||||||||||||||||||||||||||||||
| 410 | 27 | ▶ | init_where { unshift @{&ARGS}, 0 if @{&ARGS} == 1; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | 8 | ▶ | where { A <= @$_ && @$_ <= B }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 412 | subtype "HashLike`[A]", as &Ref, | ||||||||||||||||||||||||||||||||||||||||||
| 413 | 17 | ▶ | where { reftype($_) eq "HASH" || !!overload::Method($_, "%{}") } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | 8 | ▶ | awhere { &HashLike->test && do { my $A = A; all { $A->test } values %$_ }}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | subtype "HasProp[p...]", as &HashLike, | ||||||||||||||||||||||||||||||||||||||||||
| 416 | 8 | ▶ | where { my $x = $_; all { exists $x->{$_} } ARGS }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | subtype "LimKeys[from, to?]", as &HashLike, | ||||||||||||||||||||||||||||||||||||||||||
| 418 | 20 | ▶ | init_where { unshift @{&ARGS}, 0 if @{&ARGS} == 1; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | 8 | ▶ | where { A <= scalar keys %$_ && scalar keys %$_ <= B }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | 8 | subtype "Like", as &Str | &Object; | |||||||||||||||||||||||||||||||||||||||||
| 422 | subtype "HasMethods[m...]", as &Like, | ||||||||||||||||||||||||||||||||||||||||||
| 423 | 8 | ▶ | where { my $x = $_; all { $x->can($_) } ARGS }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | subtype "Overload`[m...]", as &Like, | ||||||||||||||||||||||||||||||||||||||||||
| 425 | 4 | ▶ | where { !!overload::Overloaded($_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | 8 | ▶ | awhere { my $x = $_; all { overload::Method($x, $_) } ARGS }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | 8 | ▶ | subtype "InstanceOf[class...]", as &Like, where { my $x = $_; all { $x->isa($_) } ARGS }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | 8 | ▶ | subtype "ConsumerOf[role...]", as &Like, where { my $x = $_; all { $x->DOES($_) } ARGS }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 429 | 8 | ▶ | subtype "StrLike", as &Like, where { !blessed($_) or !!overload::Method($_, '""') }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
Condition66%2/3
builtin::blessed($_) && !overload::Method($_, '""')
MC/DC0%0/2
builtin::blessed($_) && !overload::Method($_, '""')
builtin::blessed($_)
!overload::Method($_, '""')
Truth table66%2/3
A && not(B)
A= builtin::blessed($_)B= !overload::Method($_, '""')
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | subtype "Len[from, to?]", as &StrLike, | ||||||||||||||||||||||||||||||||||||||||||
| 431 | 37 | ▶ | init_where { unshift @{&ARGS}, 0 if @{&ARGS} == 1; } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | 8 | ▶ | where { A <= length($_) && length($_) <= B }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | 8 | subtype "NumLike", as &Num | &Object & Overload(["0+"]); | |||||||||||||||||||||||||||||||||||||||||
| 435 | 5 | ▶ | sub Opened($) { Aion::Type::Lim->from(ref $_[0] eq "ARRAY"? $_[0][0]: $_[0]) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Opened: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 436 | subtype "Range[from, to]", as &NumLike, | ||||||||||||||||||||||||||||||||||||||||||
| 437 | 141 | ▶ | init_where { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | 141 | ▶ | SELF->{args}[0] = A->inc if UNIVERSAL::isa(A, 'Aion::Type::Lim'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 439 | 141 | ▶ | SELF->{args}[1] = B->dec if UNIVERSAL::isa(B, 'Aion::Type::Lim'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||
| 441 | 8 | ▶ | where { A <= $_ && $_ <= B }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | 8 | subtype "Float", as Range([-(POSIX::FLT_MAX), POSIX::FLT_MAX]); | |||||||||||||||||||||||||||||||||||||||||
| 443 | 8 | subtype "Double", as Range([-(DBL_MAX), DBL_MAX]); | |||||||||||||||||||||||||||||||||||||||||
| 444 | subtype "Bytes[n]", as Range([]), | ||||||||||||||||||||||||||||||||||||||||||
| 445 | 12 | ▶ | init_where { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 446 | 12 | ▶ | my $_8bits = A < 8? 8: _8BITS; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | 12 | my $N = 1 << ($_8bits * A - 1); | |||||||||||||||||||||||||||||||||||||||||
| 448 | 12 | SELF->{as} = Range([-$N, $N-1]); | |||||||||||||||||||||||||||||||||||||||||
| 449 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 450 | subtype "PositiveBytes[n]", as Range([]), | ||||||||||||||||||||||||||||||||||||||||||
| 451 | 11 | ▶ | init_where { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | 11 | ▶ | my $_8bits = A < 8? 8: _8BITS; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 453 | 11 | my $M = 1 << ($_8bits*A); | |||||||||||||||||||||||||||||||||||||||||
| 454 | 11 | SELF->{as} = Range([0, $M-1]); | |||||||||||||||||||||||||||||||||||||||||
| 455 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||
| 457 | 8 | ▶ | coerce &Str => from &Undef => via { "" }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 458 | 8 | ▶ | coerce &Int => from &Num => via { int($_+($_ < 0? -.5: .5)) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 459 | 8 | ▶ | coerce &Bool => from &Any => via { !!$_ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | 8 | subtype 'Join[separator]', as &Str; | |||||||||||||||||||||||||||||||||||||||||
| 462 | 8 | ▶ | coerce &Join, from &ArrayRef, via { join A, @$_ }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | 8 | subtype 'Split[separator]', as &ArrayRef; | |||||||||||||||||||||||||||||||||||||||||
| 465 | 8 | ▶ | coerce &Split, from &Str, via { [split A, $_] }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | coerce &Rat => from &StrRat => via { Math::BigRat->new($_) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | 8 | subtype "PositiveNum", as &Num & Range([0, 'Inf']); | |||||||||||||||||||||||||||||||||||||||||
| 470 | 8 | subtype "PositiveInt", as &Int & Range([0, 'Inf']); | |||||||||||||||||||||||||||||||||||||||||
| 471 | 8 | subtype "Nat", as &Int & Range([1, 'Inf']); | |||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | 8 | my $_none = ~&Any; | |||||||||||||||||||||||||||||||||||||||||
| 474 | 4180 | ▶ | sub None() { $_none } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
None: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 475 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 8 | $_->keyfn(\&Aion::Type::typed_sorted_args_key) for Union[], Intersection[]; | |||||||||||||||||||||||||||||||||||||||||
| 478 | 8 | (Enum[])->keyfn(\&Aion::Type::sorted_args_key); | |||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | 8 | ▶ | %Aion::Type::range_lbound = map { (Scalar::Util::refaddr $_->{coerce} => $_->{name} eq 'Range'? '-Inf': 0) } Range[], Lim[], LimKeys[], Len[]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||
| 482 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | __END__ | ||||||||||||||||||||||||||||||||||||||||||