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