Corvus.pm

filter: Statementstmt 100% 196 / 196 Branchbran 71.7% 56 / 78 Conditioncond 46.1% 18 / 39 MC/DCmcdc 21.7% 5 / 23 Subroutinesub 97.6% 42 / 43 Podpod 66.6% 2 / 3 totaltotal 83.5% 319 / 382 CC 59 SCAR 23.8
CC
59
Cov
86%
_options
28.1
_v92
16.4
assemble
8.1
CRAP 10.8
« Corvus/Uri.pm ↑ Summary Corvus/Regex/Unicode.pm »
1 package JSON::Schema::Corvus;
2  
3 4 ▶use 5.026;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use JSON::Schema::Corvus::Collecting ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use JSON::Schema::Corvus::Compiler ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use JSON::Schema::Corvus::Dialect ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use JSON::Schema::Corvus::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use JSON::Schema::Corvus::Json ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use JSON::Schema::Corvus::ResultsCollector;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 5 our $VERSION = 'v0.1.0';
14  
15 5 my %OPTIONS = map { $_ => 1 } qw(
16 default_dialect assert_format assert_format_in_legacy_drafts assert_content formats resolve_document base_uri
17 entry_point max_depth pattern_match_limit
18 );
19  
20 5 ▶sub _usage { JSON::Schema::Corvus::Error->throw_usage($_[0]) }
Subroutine _usage: called CC=1 SCAR=0.0
21  
22 # The compile options, checked, with their defaults.
23 48 ▶sub _options {
Subroutine _options: called CC=27 SCAR=33.4
24 49 my (%given) = @_;
25 49 for my $name (sort keys %given) {
26 37 ▶ _usage("unknown option $name") unless $OPTIONS{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless $OPTIONS{$name} 1 35 36
27 }
28 48 my %options = (
29 default_dialect => JSON::Schema::Corvus::Dialect::DRAFT202012,
30 assert_format => undef,
31 assert_format_in_legacy_drafts => 0,
32 assert_content => 1,
33 formats => {},
34 resolve_document => undef,
35 base_uri => undef,
36 entry_point => undef,
37 max_depth => 128,
38 pattern_match_limit => 1.0,
39 );
40 48 ▶ if (defined $given{default_dialect}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $given{"default_dialect"}) 6 41 47
41 $options{default_dialect} = JSON::Schema::Corvus::Dialect::dialect_by_name($given{default_dialect})
42 7 ▶ // _usage('default_dialect is not one of draft2019-09, draft2020-12, draft4, draft6, draft7');
Condition66%2/3
JSON::Schema::Corvus::Dialect::dialect_by_name($given{"default_dialect"}) // _usage("default_dialect is not one of draft2019-09, draft2020-12, draft4, draft6, draft7")
l!l&&r!l&&!r
510
MC/DC0%0/2
JSON::Schema::Corvus::Dialect::dialect_by_name($given{"default_dialect"}) // _usage("default_dialect is not one of draft2019-09, draft2020-12, draft4, draft6, draft7")
JSON::Schema::Corvus::Dialect::dialect_by_name($given{"default_dialect"}) _usage("default_dialect is not one of draft2019-09, draft2020-12, draft4, draft6, draft7")
Truth table33%1/3
A // B
A= JSON::Schema::Corvus::Dialect::dialect_by_name($given{"default_dialect"})B= _usage("default_dialect is not one of draft2019-09, draft2020-12, draft4, draft6, draft7")
ABresult
1X1
011
000
43 }
44 47 ▶ $options{assert_format} = $given{assert_format} ? 1 : 0 if defined $given{assert_format};
Branch: 2 branches
BranchTrueFalseTotal
if defined $given{"assert_format"} 6 40 46
$given{'assert_format'} ? : 6 0 6
45 47 for my $flag (qw(assert_format_in_legacy_drafts assert_content)) {
46 93 ▶ $options{$flag} = $given{$flag} ? 1 : 0 if defined $given{$flag};
Branch: 2 branches
BranchTrueFalseTotal
if defined $given{$flag} 2 90 92
$given{$flag} ? : 1 1 2
47 }
48 47 for my $text (qw(base_uri entry_point)) {
49 93 ▶ $options{$text} = "$given{$text}" if defined $given{$text};
Branch: 1 branch
BranchTrueFalseTotal
if defined $given{$text} 2 90 92
50 }
51 47 ▶ if (defined $given{max_depth}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $given{"max_depth"}) 2 44 46
52 3 ▶ _usage('max_depth is not a whole number from 1') unless $given{max_depth} =~ /\A[0-9]+\z/ && $given{max_depth} > 0;
Branch: 1 branch
BranchTrueFalseTotal
unless $given{"max_depth"} =~ /\A[0-9]+\z/u and $given{"max_depth"} > 0 1 1 2
Condition66%2/3
$given{"max_depth"} =~ /\A[0-9]+\z/u and $given{"max_depth"} > 0
!ll&&!rl&&r
101
MC/DC50%1/2
$given{"max_depth"} =~ /\A[0-9]+\z/u and $given{"max_depth"} > 0
$given{"max_depth"} =~ /\A[0-9]+\z/u $given{"max_depth"} > 0
Truth table66%2/3
A and B
A= $given{"max_depth"} =~ /\A[0-9]+\z/uB= $given{"max_depth"} > 0
ABresult
0X0
100
111
53 2 $options{max_depth} = 0 + $given{max_depth};
54 }
55 46 ▶ if (exists $given{pattern_match_limit}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $given{"pattern_match_limit"}) 3 42 45
56 # Seconds, as the other packages have it; undef, 0 or less turns the limit off.
57 4 my $seconds = $given{pattern_match_limit};
58 4 ▶ _usage('pattern_match_limit is not a number of seconds')
Branch: 1 branch
BranchTrueFalseTotal
if defined $seconds and not JSON::Schema::Corvus::Json::is_number($seconds) and not $seconds =~ /\A[0-9.eE+-]+\z/u 0 3 3
Condition50%3/6
defined $seconds and not JSON::Schema::Corvus::Json::is_number($seconds) and not $seconds =~ /\A[0-9.eE+-]+\z/u
!ll&&!rl&&r
300
defined $seconds and not JSON::Schema::Corvus::Json::is_number($seconds)
!ll&&!rl&&r
120
MC/DC0%0/3
defined $seconds and not JSON::Schema::Corvus::Json::is_number($seconds) and not $seconds =~ /\A[0-9.eE+-]+\z/u
defined $seconds not JSON::Schema::Corvus::Json::is_number($seconds) not $seconds =~ /\A[0-9.eE+-]+\z/u
Truth table50%2/4
A and not(B) and not(C)
A= defined $secondsB= not JSON::Schema::Corvus::Json::is_number($seconds)C= not $seconds =~ /\A[0-9.eE+-]+\z/u
ABCresult
0XX0
10X0
1100
1111
59 if defined $seconds && !JSON::Schema::Corvus::Json::is_number($seconds) && $seconds !~ /\A[0-9.eE+-]+\z/;
60 4 ▶ $options{pattern_match_limit} = defined $seconds && $seconds > 0 ? 0 + $seconds : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $seconds && $seconds > 0 ? : 1 2 3
Condition100%3/3
defined $seconds and $seconds > 0
!ll&&!rl&&r
111
MC/DC100%2/2
defined $seconds and $seconds > 0
defined $seconds $seconds > 0
Truth table100%3/3
A and B
A= defined $secondsB= $seconds > 0
ABresult
0X0
100
111
61 }
62 46 ▶ if (defined $given{formats}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $given{"formats"}) 6 39 45
63 7 ▶ _usage('formats is not a hash of code references') unless ref $given{formats} eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $given{"formats"} eq "HASH" 0 6 6
64 7 for my $name (keys %{ $given{formats} }) {
65 7 ▶ _usage("format $name is not a code reference") unless ref $given{formats}{$name} eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $given{"formats"}{$name} eq "CODE" 1 5 6
66 }
67 6 $options{formats} = { %{ $given{formats} } };
68 }
69 45 ▶ if (defined $given{resolve_document}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $given{"resolve_document"}) 7 37 44
70 8 ▶ _usage('resolve_document is not a code reference') unless ref $given{resolve_document} eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $given{"resolve_document"} eq "CODE" 0 7 7
71 8 $options{resolve_document} = $given{resolve_document};
72 }
73 45 return \%options;
74 }
75  
76 42 ▶sub _is_data {
Subroutine _is_data: called CC=4 SCAR=14.3
77 43 my ($value) = @_;
78 43 ▶ return 1 if ref $value;
Branch: 1 branch
BranchTrueFalseTotal
if ref $value 7 35 42
79 4 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
80 36 ▶ return defined &builtin::is_bool && builtin::is_bool($value) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined &builtin::is_bool && builtin::is_bool($value) ? : 0 35 35
Condition33%1/3
defined &builtin::is_bool and builtin::is_bool($value)
!ll&&!rl&&r
0350
MC/DC0%0/2
defined &builtin::is_bool and builtin::is_bool($value)
defined &builtin::is_bool builtin::is_bool($value)
Truth table33%1/3
A and B
A= defined &builtin::is_boolB= builtin::is_bool($value)
ABresult
0X0
100
111
81 }
82  
83 # A schema as a JSON value: JSON text parsed (keeping the order of names), or Perl data converted.
84 42 ▶sub _schema_value {
Subroutine _schema_value: called CC=2 SCAR=6.9
85 43 my ($schema) = @_;
86 43 ▶ return JSON::Schema::Corvus::Json::from_data($schema) if _is_data($schema);
Branch: 1 branch
BranchTrueFalseTotal
if _is_data($schema) 7 35 42
87 36 return JSON::Schema::Corvus::Json::decode($schema, 1);
88 }
89  
90 46 ▶sub compile {
Subroutine compile: called CC=1 SCAR=0.0
Pod documented
91 47 my ($class, $schema, %options) = @_;
92 47 my $options = _options(%options);
93 43 my $program = JSON::Schema::Corvus::Compiler->compile(_schema_value($schema), $options);
94 36 return JSON::Schema::Corvus::Validator->_new($program);
95 }
96  
97 2 ▶sub compile_uri {
Subroutine compile_uri: called CC=2 SCAR=7.0
Pod documented
98 3 my ($class, $uri, %options) = @_;
99 3 ▶ _usage('the URI is undef') unless defined $uri;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $uri 0 2 2
100 3 my $program = JSON::Schema::Corvus::Compiler->compile_from_uri("$uri", _options(%options));
101 3 return JSON::Schema::Corvus::Validator->_new($program);
102 }
103  
104 # The JSON text (UTF-8 bytes) that Perl data is validated as.
105 25 ▶sub encode_json {
Subroutine encode_json: called CC=1 SCAR=0.0
Pod undocumented
106 26 my ($data) = @_;
107 26 my $text = JSON::Schema::Corvus::Json::encode(JSON::Schema::Corvus::Json::from_data($data));
108 21 utf8::encode($text);
109 21 return $text;
110 }
111  
112 package JSON::Schema::Corvus::Validator;
113  
114 4 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
115 4 ▶use Symbol ();
Subroutine BEGIN: called CC=1 SCAR=0.0
116  
117 5 my $PACKAGES = 0;
118  
119 37 ▶sub _new {
Subroutine _new: called CC=1 SCAR=0.0
120 38 my ($class, $program) = @_;
121 38 my $self = bless { program => $program, collecting => undef }, $class;
122 38 $self->_generate;
123 38 return $self;
124 }
125  
126 # Generates the validator's Perl and compiles it into a package of its own, which DESTROY deletes.
127 37 ▶sub _generate {
Subroutine _generate: called CC=2 SCAR=7.3
128 38 my ($self) = @_;
129 38 require JSON::Schema::Corvus::CodeGen;
130 38 require JSON::Schema::Corvus::Runtime;
131 38 my $g = JSON::Schema::Corvus::CodeGen->new($self->{program})->generate;
132 38 my $package = 'JSON::Schema::Corvus::Generated::G' . ++$PACKAGES;
133 38 my $source = $self->{source} = assemble($g, $package);
134 38 my $validate = do {
135 4 ▶ no strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
136 4 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
137 38 local $@;
138 2 ▶ my $code = eval $source;
Subroutine __ANON__: called CC=1 SCAR=0.6
Subroutine _bv1: called CC=2 SCAR=8.1
Subroutine _v1: called CC=2 SCAR=8.1
Subroutine _v92: called CC=10 SCAR=28.0
Branch: 7 branches
BranchTrueFalseTotal
unless _v1($x) 0 0 0
if ++$JSON::Schema::Corvus::Generated::G16::depth > $JSON::Schema::Corvus::Generated::G16::MAXDEPTH 1 16 17
unless $tx eq "ARRAY" 1 0 1
if $n0 < 1 0 0 0
unless ref $v eq "" and defined $v and not &builtin::created_as_number($v) and exists $JSON::Schema::Corvus::Generated::G24::C3->{$v} 0 0 0
if ($n0 > 1) 0 0 0
if keys %s1 != $n0 0 0 0
Condition0%0/9
ref $v eq "" and defined $v and not &builtin::created_as_number($v) and exists $JSON::Schema::Corvus::Generated::G24::C3->{$v}
!ll&&!rl&&r
000
ref $v eq "" and defined $v and not &builtin::created_as_number($v)
!ll&&!rl&&r
000
ref $v eq "" and defined $v
!ll&&!rl&&r
000
MC/DC0%0/4
ref $v eq "" and defined $v and not &builtin::created_as_number($v) and exists $JSON::Schema::Corvus::Generated::G24::C3->{$v}
ref $v eq "" defined $v not &builtin::created_as_number($v) exists $JSON::Schema::Corvus::Generated::G24::C3->{$v}
Truth table0%0/5
A and B and not(C) and D
A= ref $v eq ""B= defined $vC= not &builtin::created_as_number($v)D= exists $JSON::Schema::Corvus::Generated::G24::C3->{$v}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
139 38 ▶ die JSON::Schema::Corvus::Error::Compilation->_new("The schema produced invalid code: $@") unless $code;
Branch: 1 branch
BranchTrueFalseTotal
unless $code 0 37 37
140 38 $code;
141 };
142 {
143 4 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
144 38 ${"${package}::F"} = $g->{custom_formats};
145 }
146 38 $self->{package} = $package;
147 38 $self->{validate} = $validate;
148 }
149  
150 # The package's source: its subs, the constants (after the subs, as a dispatch table names them), and the sub that
151 # validates, which keeps the dynamic scope and the depth count of one evaluation when the program has them.
152 37 ▶sub assemble {
Subroutine assemble: called CC=8 SCAR=20.9
153 38 my ($g, $package) = @_;
154 38 my @s = ("package $package;", 'use strict;', 'no warnings;', 'our ($F, @DS, $depth, $MAXDEPTH);');
155 38 ▶ push @s, 'our (' . join(', ', map { $_->[0] } @{ $g->{constants} }) . ');' if @{ $g->{constants} };
Branch: 1 branch
BranchTrueFalseTotal
if @{$g->{"constants"};} 8 29 37
156 38 push @s, map { $_->[1] } @{ $g->{functions} };
157 38 push @s, "$_->[0] = $_->[1];" for @{ $g->{constants} };
158 38 ▶ push @s, "\$MAXDEPTH = $g->{max_depth};" if $g->{uses_depth};
Branch: 1 branch
BranchTrueFalseTotal
if $g->{"uses_depth"} 1 36 37
159 38 ▶ if ($g->{uses_dynamic_scope} || $g->{uses_depth}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($g->{'uses_dynamic_scope'} or $g->{'uses_depth'}) { } 1 36 37
Condition66%2/3
$g->{"uses_dynamic_scope"} or $g->{"uses_depth"}
l!l&&r!l&&!r
0136
MC/DC50%1/2
$g->{"uses_dynamic_scope"} or $g->{"uses_depth"}
$g->{"uses_dynamic_scope"} $g->{"uses_depth"}
Truth table66%2/3
A or B
A= $g->{"uses_dynamic_scope"}B= $g->{"uses_depth"}
ABresult
1X1
011
000
160 2 push @s, 'sub validate {';
161 2 ▶ push @s, " local \@DS = ($g->{root_resource});" if $g->{uses_dynamic_scope};
Branch: 1 branch
BranchTrueFalseTotal
if $g->{"uses_dynamic_scope"} 0 1 1
162 2 ▶ push @s, ' local $depth = 0;' if $g->{uses_depth};
Branch: 1 branch
BranchTrueFalseTotal
if $g->{"uses_depth"} 1 0 1
163 2 push @s, " return $g->{root}(\$_[0]);", '}', '\&validate;';
164 }
165 else {
166 37 push @s, "\\&$g->{root};";
167 }
168 38 return join "\n", @s, '';
169 }
170  
171 37 ▶sub DESTROY {
Subroutine DESTROY: called CC=2 SCAR=7.2
172 38 my ($self) = @_;
173 38 ▶ Symbol::delete_package($self->{package}) if $self->{package};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"package"} 37 0 37
174 }
175  
176 # The generated Perl of the validator.
177 1 ▶sub source { $_[0]{source} }
Subroutine source: not called CC=1 SCAR=0.0
178  
179 # The program for evaluation with a collector, with its annotations (built on first use).
180 5 ▶sub _collecting {
Subroutine _collecting: called CC=2 SCAR=7.0
181 6 my ($self) = @_;
182 6 ▶ return $self->{collecting} //= do {
Condition66%2/3
$self->{"collecting"} //= do { JSON::Schema::Corvus::Compiler::resolve_annotations($self->{"program"}); my $p = $self->{"program"}; +{"nodes", $p->{"nodes"}, "root", $p->{"root"}, "uses_dynamic_scope", $p->{"uses_dynamic_scope"}, "max_depth", $p->{"options"}{"max_depth"}, "formats", $p->{"options"}{"formats"}, "pattern_match_limit", $p->{"options"}{"pattern_match_limit"}} }
l!l&&r!l&&!r
230
MC/DC0%0/2
$self->{"collecting"} //= do { JSON::Schema::Corvus::Compiler::resolve_annotations($self->{"program"}); my $p = $self->{"program"}; +{"nodes", $p->{"nodes"}, "root", $p->{"root"}, "uses_dynamic_scope", $p->{"uses_dynamic_scope"}, "max_depth", $p->{"options"}{"max_depth"}, "formats", $p->{"options"}{"formats"}, "pattern_match_limit", $p->{"options"}{"pattern_match_limit"}} }
$self->{"collecting"} do { JSON::Schema::Corvus::Compiler::resolve_annotations($self->{"program"}); my $p = $self->{"program"}; +{"nodes", $p->{"nodes"}, "root", $p->{"root"}, "uses_dynamic_scope", $p->{"uses_dynamic_scope"}, "max_depth", $p->{"options"}{"max_depth"}, "formats", $p->{"options"}{"formats"}, "pattern_match_limit", $p->{"options"}{"pattern_match_limit"}} }
Truth table66%2/3
A //= B
A= $self->{"collecting"}B= do { JSON::Schema::Corvus::Compiler::resolve_annotations($self->{"program"}); my $p = $self->{"program"}; +{"nodes", $p->{"nodes"}, "root", $p->{"root"}, "uses_dynamic_scope", $p->{"uses_dynamic_scope"}, "max_depth", $p->{"options"}{"max_depth"}, "formats", $p->{"options"}{"formats"}, "pattern_match_limit", $p->{"options"}{"pattern_match_limit"}} }
ABresult
1X1
011
000
183 4 JSON::Schema::Corvus::Compiler::resolve_annotations($self->{program});
184 4 my $p = $self->{program};
185 {
186 nodes => $p->{nodes},
187 root => $p->{root},
188 uses_dynamic_scope => $p->{uses_dynamic_scope},
189 max_depth => $p->{options}{max_depth},
190 formats => $p->{options}{formats},
191 pattern_match_limit => $p->{options}{pattern_match_limit},
192 4 };
193 };
194 }
195  
196 62 ▶sub _self {
Subroutine _self: called CC=3 SCAR=11.1
197 63 ▶ JSON::Schema::Corvus::Error->throw_usage('expected a JSON::Schema::Corvus::Validator')
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($_[0]) and $_[0]->isa("JSON::Schema::Corvus::Validator") 1 61 62
Condition66%2/3
builtin::blessed($_[0]) and $_[0]->isa("JSON::Schema::Corvus::Validator")
!ll&&!rl&&r
1061
MC/DC50%1/2
builtin::blessed($_[0]) and $_[0]->isa("JSON::Schema::Corvus::Validator")
builtin::blessed($_[0]) $_[0]->isa("JSON::Schema::Corvus::Validator")
Truth table66%2/3
A and B
A= builtin::blessed($_[0])B= $_[0]->isa("JSON::Schema::Corvus::Validator")
ABresult
0X0
100
111
198 unless Scalar::Util::blessed($_[0]) && $_[0]->isa('JSON::Schema::Corvus::Validator');
199 }
200  
201 58 ▶sub _validate {
Subroutine _validate: called CC=2 SCAR=6.9
202 59 my ($self, $value) = @_;
203 59 ▶ return $self->{validate}->($value) ? 1 : '';
Branch: 1 branch
BranchTrueFalseTotal
$self->{'validate'}->($value) ? : 28 26 54
204 }
205  
206 54 ▶sub is_valid_json {
Subroutine is_valid_json: called CC=1 SCAR=0.0
207 55 my ($self, $json) = @_;
208 55 _self($self);
209 54 return $self->_validate(JSON::Schema::Corvus::Json::decode($json));
210 }
211  
212 6 ▶sub is_valid {
Subroutine is_valid: called CC=1 SCAR=0.0
213 7 my ($self, $data) = @_;
214 7 _self($self);
215 7 return $self->_validate(JSON::Schema::Corvus::Json::from_data($data));
216 }
217  
218 2 ▶sub is_valid_document {
Subroutine is_valid_document: called CC=1 SCAR=0.0
219 3 my ($self, $document) = @_;
220 3 _self($self);
221 3 return $self->_validate($document->{value});
222 }
223  
224 5 ▶sub _evaluate {
Subroutine _evaluate: called CC=4 SCAR=14.6
225 6 my ($self, $value, $collector) = @_;
226 6 ▶ JSON::Schema::Corvus::Error->throw_usage('expected a JSON::Schema::Corvus::ResultsCollector')
Branch: 1 branch
BranchTrueFalseTotal
unless ref $collector and $collector->isa("JSON::Schema::Corvus::ResultsCollector") 0 5 5
Condition33%1/3
ref $collector and $collector->isa("JSON::Schema::Corvus::ResultsCollector")
!ll&&!rl&&r
005
MC/DC0%0/2
ref $collector and $collector->isa("JSON::Schema::Corvus::ResultsCollector")
ref $collector $collector->isa("JSON::Schema::Corvus::ResultsCollector")
Truth table33%1/3
A and B
A= ref $collectorB= $collector->isa("JSON::Schema::Corvus::ResultsCollector")
ABresult
0X0
100
111
227 unless ref $collector && $collector->isa('JSON::Schema::Corvus::ResultsCollector');
228 6 $collector->_reset;
229 6 ▶ return JSON::Schema::Corvus::Collecting::evaluate_with_collector($self->_collecting, $value, $collector) ? 1 : '';
Branch: 1 branch
BranchTrueFalseTotal
JSON::Schema::Corvus::Collecting::evaluate_with_collector($self->_collecting, $value, $collector) ? : 3 2 5
230 }
231  
232 3 ▶sub evaluate_json {
Subroutine evaluate_json: called CC=1 SCAR=0.0
233 4 my ($self, $json, $collector) = @_;
234 4 return $self->_evaluate(JSON::Schema::Corvus::Json::decode($json, 1), $collector);
235 }
236  
237 1 ▶sub evaluate {
Subroutine evaluate: called CC=1 SCAR=0.0
238 2 my ($self, $data, $collector) = @_;
239 2 return $self->_evaluate(JSON::Schema::Corvus::Json::from_data($data), $collector);
240 }
241  
242 1 ▶sub evaluate_document {
Subroutine evaluate_document: called CC=1 SCAR=0.0
243 2 my ($self, $document, $collector) = @_;
244 2 return $self->_evaluate($document->{value}, $collector);
245 }
246  
247 package JSON::Schema::Corvus::Document;
248  
249 # JSON parsed once, for an instance validated more than once.
250 2 ▶sub parse {
Subroutine parse: called CC=1 SCAR=0.0
251 3 my ($class, $json) = @_;
252 3 return bless { value => JSON::Schema::Corvus::Json::decode($json, 1) }, $class;
253 }
254  
255 1 ▶sub from_data {
Subroutine from_data: called CC=1 SCAR=0.0
256 2 my ($class, $data) = @_;
257 2 return bless { value => JSON::Schema::Corvus::Json::from_data($data) }, $class;
258 }
259  
260 5 1;
261  
262 __END__
« Corvus/Uri.pm ↑ Summary Corvus/Regex/Unicode.pm »