line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
12
|
use v5.12.0; |
|
1
|
|
|
|
|
3
|
|
2
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
3
|
|
|
|
|
|
|
package Data::Rx::CoreType::any 0.200008; |
4
|
|
|
|
|
|
|
# ABSTRACT: the Rx //any type |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use parent 'Data::Rx::CoreType'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
171
|
use Scalar::Util (); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
365
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub guts_from_arg { |
11
|
6
|
|
|
6
|
0
|
16
|
my ($class, $arg, $rx, $type) = @_; |
12
|
|
|
|
|
|
|
|
13
|
6
|
100
|
|
|
|
30
|
Carp::croak("unknown arguments to new") |
14
|
|
|
|
|
|
|
unless Data::Rx::Util->_x_subset_keys_y($arg, { of => 1}); |
15
|
|
|
|
|
|
|
|
16
|
5
|
|
|
|
|
16
|
my $guts = {}; |
17
|
|
|
|
|
|
|
|
18
|
5
|
100
|
|
|
|
15
|
if (my $of = $arg->{of}) { |
19
|
2
|
100
|
66
|
|
|
150
|
Carp::croak("invalid 'of' argument to //any") unless |
20
|
|
|
|
|
|
|
Scalar::Util::reftype $of eq 'ARRAY' and @$of; |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
4
|
$guts->{of} = [ map {; $rx->make_schema($_) } @$of ]; |
|
2
|
|
|
|
|
8
|
|
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
|
|
10
|
return $guts; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub assert_valid { |
29
|
120
|
100
|
|
120
|
0
|
23576
|
return 1 unless $_[0]->{of}; |
30
|
|
|
|
|
|
|
|
31
|
54
|
|
|
|
|
106
|
my ($self, $value) = @_; |
32
|
|
|
|
|
|
|
|
33
|
54
|
|
|
|
|
73
|
my @failures; |
34
|
54
|
|
|
|
|
83
|
for my $i (0 .. $#{ $self->{of} }) { |
|
54
|
|
|
|
|
154
|
|
35
|
106
|
|
|
|
|
204
|
my $check = $self->{of}[ $i ]; |
36
|
106
|
100
|
|
|
|
155
|
return 1 if eval { $check->assert_valid($value) }; |
|
106
|
|
|
|
|
292
|
|
37
|
|
|
|
|
|
|
|
38
|
103
|
|
|
|
|
255
|
my $failure = $@; |
39
|
103
|
|
|
|
|
249
|
$failure->contextualize({ |
40
|
|
|
|
|
|
|
type => $self->type, |
41
|
|
|
|
|
|
|
check_path => [ [ 'of', 'key'], [ $i, 'index' ] ], |
42
|
|
|
|
|
|
|
}); |
43
|
|
|
|
|
|
|
|
44
|
103
|
|
|
|
|
229
|
push @failures, $failure; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$self->fail({ |
48
|
51
|
|
|
|
|
227
|
error => [ qw(none) ], |
49
|
|
|
|
|
|
|
message => "matched none of the available alternatives", |
50
|
|
|
|
|
|
|
value => $value, |
51
|
|
|
|
|
|
|
failures => \@failures, |
52
|
|
|
|
|
|
|
}); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
70
|
|
|
70
|
0
|
199
|
sub subname { 'any' } |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |