blib/lib/JSONLD.pm

filter: Statementstmt 15.1% 419 / 2771 Branchbran 5.9% 167 / 2786 Conditioncond 7.1% 57 / 793 MC/DCmcdc 1.3% 6 / 455 Subroutinesub 43.6% 45 / 103 Podpod 81.2% 13 / 16 totaltotal 10.2% 707 / 6924 CC 1728 SCAR 102.6
CC
1728
Cov
10%
_5_1_2_expansion_step_13
68671.0
_6_1_2_compaction
55795.5
_4_2_2_create_term_definition
45582.0
CRAP 28473.2
↑ Summary
1 =head1 NAME
2  
3 JSONLD - A toolkit for transforming JSON-LD data.
4  
5 =head1 VERSION
6  
7 This document describes JSONLD version 0.006.
8  
9 =head1 SYNOPSIS
10  
11 use v5.14;
12 use JSON;
13 use JSONLD;
14
15 my $infile = 'test.jsonld';
16 open(my $fh, '<', $infile) or die $!;
17 my $content = do { local($/); <$fh> };
18 my $data = JSON->new()->boolean_values(0, 1)->decode($content);
19
20 my $jld = JSONLD->new();
21 my $expanded = $jld->expand($data);
22  
23 =head1 DESCRIPTION
24  
25 This module implements part of the JSON-LD 1.1 standard for manipulating JSON
26 data as linked data.
27  
28 This version provides full support for the JSON-LD 1.1 "Expansion" and
29 "toRdf" transformations (the latter primarily being useful through a subclass
30 of JSON-LD, such as that provided by L<AtteanX::Parser::JSONLD>).
31 Partial support for the "Compaction" transformation is provided, but it
32 contains many known deficiencies. Full support for "Compaction" may be
33 forthcoming in a future release.
34 No other JSON-LD transformation are supported at this time.
35  
36 =head1 METHODS
37  
38 =over 4
39  
40 =cut
41  
42 2 package JSONLD {
43 2 ▶ use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
44 2 ▶ use autodie;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 2 our $VERSION = '0.006';
46 2 ▶ use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 2 ▶ use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 2 ▶ use LWP;
Subroutine BEGIN: called CC=1 SCAR=0.0
49 2 ▶ use List::Util qw(all any);
Subroutine BEGIN: called CC=1 SCAR=0.0
50 2 ▶ use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
51 2 ▶ use JSON qw(decode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
52 2 ▶ use IRI;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 2 ▶ use FindBin qw($Bin);
Subroutine BEGIN: called CC=1 SCAR=0.0
54 2 ▶ use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
55 2 ▶ use File::Glob qw(bsd_glob);
Subroutine BEGIN: called CC=1 SCAR=0.0
56 2 ▶ use Encode qw(encode decode_utf8);
Subroutine BEGIN: called CC=1 SCAR=0.0
57 2 ▶ use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
58 2 ▶ use Clone 'clone';
Subroutine BEGIN: called CC=1 SCAR=0.0
59 2 ▶ use Carp qw(confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
60 2 ▶ use B qw(svref_2object SVf_IOK SVf_POK SVf_NOK SVf_IOK);
Subroutine BEGIN: called CC=1 SCAR=0.0
61 2 ▶ use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 # use Debug::ShowStuff qw(indent println);
63 0 ▶ sub println ($) {}
Subroutine println: not called CC=1 SCAR=0.0
Pod undocumented
64 15 ▶ sub indent {}
Subroutine indent: called CC=1 SCAR=0.0
Pod undocumented
65
66 1 ▶ has 'base_iri' => (is => 'rw', required => 0, default => sub { IRI->new('http://example.org/') });
Subroutine __ANON__: called CC=1 SCAR=0.0
67 2 has 'processing_mode' => (is => 'ro', default => 'json-ld-1.1');
68 2 has 'max_remote_contexts' => (is => 'rw', default => 10);
69 1 ▶ has 'parsed_remote_contexts' => (is => 'rw', default => sub { +{} });
Subroutine __ANON__: called CC=1 SCAR=0.0
70 2 has 'rdf_direction' => (is => 'rw');
71 1 ▶ has 'identifier_map' => (is => 'rw', default => sub { +{} });
Subroutine __ANON__: called CC=1 SCAR=0.0
72 2 has 'next_identifier_id' => (is => 'rw', default => 0);
73 2 has 'default_language' => (is => 'rw');
74 2 has 'default_base_direction' => (is => 'rw');
75
76 2 our $debug = 0;
77 2 my %keywords = map { $_ => 1 } qw(: @base @container @context @direction @graph @id @import @included @index @json @language @list @nest @none @prefix @propagate @protected @reverse @set @type @value @version @vocab);
78
79 =item C<< compact( $data, [$context] ) >>
80  
81 Returns the JSON-LD compaction of C<< $data >>, using the optionally supplied
82 C<< $context >>.
83  
84 NOTE: Support for JSON-LD Compaction is not fully supported in this version.
85  
86 =cut
87  
88 0 ▶ sub compact {
Subroutine compact: not called CC=11 SCAR=48.8
Pod documented
89 0 my $self = shift;
90 0 my $d = shift;
91 0 ▶ my $context = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
92 0 my %args = $self->_default_options(@_);
93
94
95 0 my $expanded_input = do {
96 0 local($debug) = 0;
97 0 $self->expand($d, ordered => 0);
98 };
99 0 ▶ println(Data::Dumper->Dump([$context, $expanded_input], [qw(context expanded_input)])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $JSONLD::debug 0 0 0
100
101 0 my $ctx = {
102 '@base' => $self->base_iri->abs, # TODO: not sure this follows the spec, but it's what makes test t0089 pass
103 };
104 0 ▶ if (ref($context) eq 'HASH' and exists $context->{'@context'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $context eq "HASH" and exists $context->{"\@context"}) 0 0 0
Condition0%0/3
ref $context eq "HASH" and exists $context->{"\@context"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $context eq "HASH" and exists $context->{"\@context"}
ref $context eq "HASH" exists $context->{"\@context"}
Truth table0%0/3
A and B
A= ref $context eq "HASH"B= exists $context->{"\@context"}
ABresult
0X0
100
111
105 0 local($debug) = 0;
106 0 $ctx = $self->_4_1_2_ctx_processing($ctx, $context->{'@context'});
107 }
108 0 ▶ println(Data::Dumper->Dump([$ctx], ['activeCtx'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $JSONLD::debug 0 0 0
109 0 my $inverseCtx = $self->_4_3_inverse_context_creation($ctx);
110
111 # warn "Compacting...";
112 0 my $c = $self->_compact($ctx, $inverseCtx, undef, $expanded_input, %args);
113  
114 0 ▶ my $out_ctx = $context->{'@context'} || {};
Condition0%0/2
$context->{'@context'} || {}
l!l
00
MC/DC0%0/1
$context->{'@context'} || {}
$context->{'@context'}
Truth table0%0/2
A
A= $context->{'@context'}
Aresult
11
00
115 0 ▶ if ((ref($out_ctx) eq 'HASH' and scalar(@{[keys %$out_ctx]})) or (ref($out_ctx) eq 'ARRAY' and scalar(@$out_ctx))) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $out_ctx eq "HASH" and scalar @{[keys %$out_ctx];} or ref $out_ctx eq "ARRAY" and scalar @$out_ctx) 0 0 0
Condition0%0/7
ref $out_ctx eq "HASH" and scalar @{[keys %$out_ctx];} or ref $out_ctx eq "ARRAY" and scalar @$out_ctx
l!l&&r!l&&!r
000
ref $out_ctx eq "HASH" and scalar @{[keys %$out_ctx];}
!ll
00
ref $out_ctx eq "ARRAY" and scalar @$out_ctx
!ll
00
MC/DC0%0/2
ref $out_ctx eq "HASH" and scalar @{[keys %$out_ctx];} or ref $out_ctx eq "ARRAY" and scalar @$out_ctx
ref $out_ctx eq "HASH" ref $out_ctx eq "ARRAY"
Truth table0%0/3
A or B
A= ref $out_ctx eq "HASH"B= ref $out_ctx eq "ARRAY"
ABresult
1X1
011
000
116 0 $c->{'@context'} = $context->{'@context'};
117 }
118 0 return $c;
119 }
120
121 =item C<< expand( $data, [expandContext => $ctx] ) >>
122  
123 Returns the JSON-LD expansion of C<< $data >>.
124  
125 If an C<< expandContext >> value is supplied, it is used to construct the
126 initial active context for the expansion process.
127  
128 =cut
129  
130 1 ▶ sub expand {
Subroutine expand: called CC=4 SCAR=19.2
Pod documented
131 1 my $self = shift;
132 1 my $d = shift;
133 1 my %args = @_;
134
135 1 my $ctx = {
136 '@base' => $self->base_iri->abs, # TODO: not sure this follows the spec, but it's what makes test t0089 pass
137 };
138 1 ▶ if (my $ec = $args{expandContext}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ec = $args{"expandContext"}) 0 1 1
139 0 ▶ if (ref($ec) eq 'HASH' and exists $ec->{'@context'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ec eq "HASH" and exists $ec->{"\@context"}) 0 0 0
Condition0%0/3
ref $ec eq "HASH" and exists $ec->{"\@context"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $ec eq "HASH" and exists $ec->{"\@context"}
ref $ec eq "HASH" exists $ec->{"\@context"}
Truth table0%0/3
A and B
A= ref $ec eq "HASH"B= exists $ec->{"\@context"}
ABresult
0X0
100
111
140 0 $ec = $ec->{'@context'};
141 }
142 0 $ctx = $self->_4_1_2_ctx_processing($ctx, $ec);
143 }
144 # warn "Expanding...";
145 1 return $self->_expand($ctx, undef, $d);
146 }
147
148 =item C<< to_rdf( $data, [expandContext => $ctx] ) >>
149  
150 Returns the dataset generated by turning the JSON-LD expansion of C<< $data >>
151 into RDF.
152  
153 If an C<< expandContext >> value is supplied, it is passed to the C<< expand >>
154 function call that takes place internally prior to generating RDF.
155  
156 Note: this method must be called on a C<< JSONLD >> subclass which implements
157 the RDF-related methods:
158  
159 =over 4
160  
161 =item * C<< default_graph() >>
162
163 =item * C<< new_dataset() >>
164
165 =item * C<< new_triple($s, $p, $o) >>
166
167 =item * C<< new_quad($s, $p, $o, $g) >>
168
169 =item * C<< new_iri($value) >>
170  
171 =item * C<< new_graphname($value) >>
172
173 =item * C<< new_blank( [$id] ) >>
174
175 =item * C<< new_lang_literal($value, $lang) >>
176
177 =item * C<< new_dt_literal($value, $datatype) >>
178  
179 =item * C<< add_quad($quad, $dataset) >>
180  
181 =back
182  
183 See L<AtteanX::Parser::JSONLD> for an API that provides this functionality.
184  
185 =cut
186  
187 0 ▶ sub to_rdf {
Subroutine to_rdf: not called CC=3 SCAR=24.8
Pod documented
188 0 my $self = shift;
189 0 my $obj = shift;
190 0 my $expandedInput = do {
191 0 local($debug) = 0;
192 0 $self->expand($obj, @_);
193 };
194 0 ▶ println "to rdf " . Data::Dumper->Dump([$expandedInput], ['expandedInput']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
195 0 my $dataset = $self->new_dataset;
196 0 my $map = {};
197 0 $self->identifier_map({});
198 0 $self->next_identifier_id(0);
199 0 $self->_7_2_2_nodemap_generation($expandedInput, $map);
200 0 ▶ println(Data::Dumper->Dump([$map], ['node_map'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
201 0 $self->_8_1_2_to_rdf($map, $dataset);
202 0 return $dataset;
203 }
204  
205 0 ▶ sub _compact {
Subroutine _compact: not called CC=3 SCAR=24.8
206 0 my $self = shift;
207 0 my $activeCtx = shift;
208 0 my $inverseCtx = shift;
209 0 my $activeProp = shift;
210 0 my $element = shift;
211 0 my $result = $self->_6_1_2_compaction($activeCtx, $inverseCtx, $activeProp, $element, @_);
212  
213 0 ▶ if (ref($result) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $result eq "ARRAY") 0 0 0
214 # https://github.com/w3c/json-ld-api/issues/318
215 0 ▶ if (scalar(@$result) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$result == 0) { } 0 0 0
216 0 $result = {};
217 } else {
218 0 my $key = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, '@graph');
219 0 $result = { $key => $result };
220 }
221 }
222
223 0 return $result;
224 }
225  
226 1 ▶ sub _expand {
Subroutine _expand: called CC=10 SCAR=29.3
227 1 my $self = shift;
228 1 ▶ my $ctx = shift // {};
Condition50%1/2
shift() // {}
l!l
10
MC/DC0%0/1
shift() // {}
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
229 1 my $prop = shift;
230 1 my $d = shift;
231 1 my $expanded_output = $self->_5_1_2_expansion($ctx, $prop, $d, @_);
232 1 ▶ if (ref($expanded_output) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $expanded_output eq "HASH") 1 0 1
233 1 my @keys = keys %$expanded_output;
234 1 ▶ if (scalar(@keys) == 1 and $keys[0] eq '@graph') {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @keys == 1 and $keys[0] eq "\@graph") 0 1 1
Condition33%1/3
scalar @keys == 1 and $keys[0] eq "\@graph"
!ll&&!rl&&r
010
MC/DC0%0/2
scalar @keys == 1 and $keys[0] eq "\@graph"
scalar @keys == 1 $keys[0] eq "\@graph"
Truth table33%1/3
A and B
A= scalar @keys == 1B= $keys[0] eq "\@graph"
ABresult
0X0
100
111
235 0 ▶ println "_expand 7.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
236 0 $expanded_output = $expanded_output->{'@graph'};
237 }
238 }
239
240 1 ▶ unless (defined($expanded_output)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $expanded_output) 0 1 1
241 0 ▶ println "_expand 7.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
242 0 $expanded_output = [];
243 }
244
245 1 ▶ if (ref($expanded_output) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $expanded_output ne "ARRAY") 1 0 1
246 1 ▶ println "_expand 7.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
247 1 $expanded_output = [$expanded_output];
248 }
249
250 1 return $expanded_output;
251 }
252
253 0 ▶ sub _default_options {
Subroutine _default_options: not called CC=4 SCAR=30.0
254 0 my $self = shift;
255 0 my %args = @_;
256 0 ▶ $args{compactArrays} //= 1;
Condition0%0/2
$args{"compactArrays"} //= 1
l!l
00
MC/DC0%0/1
$args{"compactArrays"} //= 1
$args{"compactArrays"}
Truth table0%0/2
A
A= $args{"compactArrays"}
Aresult
11
00
257 0 ▶ $args{compactToRelative} //= 1;
Condition0%0/2
$args{"compactToRelative"} //= 1
l!l
00
MC/DC0%0/1
$args{"compactToRelative"} //= 1
$args{"compactToRelative"}
Truth table0%0/2
A
A= $args{"compactToRelative"}
Aresult
11
00
258 0 ▶ $args{ordered} //= 0;
Condition0%0/2
$args{"ordered"} //= 0
l!l
00
MC/DC0%0/1
$args{"ordered"} //= 0
$args{"ordered"}
Truth table0%0/2
A
A= $args{"ordered"}
Aresult
11
00
259
260 0 return %args;
261 }
262
263 0 ▶ sub _values_from_scalar_or_array {
Subroutine _values_from_scalar_or_array: not called CC=2 SCAR=17.9
264 0 my $value = shift;
265 0 ▶ if (ref($value) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq 'ARRAY') { } 0 0 0
266 0 return @$value;
267 } else {
268 0 return $value;
269 }
270 }
271
272 0 ▶ sub _is_prefix_of {
Subroutine _is_prefix_of: not called CC=4 SCAR=30.0
273 0 my $v = shift;
274 0 my $big = shift;
275 0 ▶ return 0 unless defined($v);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v 0 0 0
276 0 ▶ return 0 unless defined($big);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $big 0 0 0
277 0 ▶ return 0 if (length($v) > length($big));
Branch: 1 branch
BranchTrueFalseTotal
if length $v > length $big 0 0 0
278 0 return (substr($big, 0, length($v)) eq $v);
279 }
280  
281 2 ▶ sub _is_scalar {
Subroutine _is_scalar: called CC=3 SCAR=11.0
282 2 my $v = shift;
283 2 ▶ return 1 unless (ref($v));
Branch: 1 branch
BranchTrueFalseTotal
unless ref $v 1 1 2
284 1 ▶ return 1 if JSON::is_bool($v);
Branch: 1 branch
BranchTrueFalseTotal
if &JSON::is_bool($v) 0 1 1
285 1 return 0;
286 }
287
288 5 ▶ sub _is_string {
Subroutine _is_string: called CC=5 SCAR=17.1
289 5 my $v = shift;
290 5 ▶ return 0 unless defined($v);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v 0 5 5
291 5 ▶ return 0 if ref($v);
Branch: 1 branch
BranchTrueFalseTotal
if ref $v 2 3 5
292 3 my $sv = svref_2object(\$v);
293 3 my $flags = $sv->FLAGS;
294 3 my $is_str = $flags & SVf_POK;
295 3 ▶ my $is_num = (($flags & SVf_NOK) or ($flags & SVf_IOK));
Condition33%1/3
$flags & 512 || $flags & 256
l!l&&r!l&&!r
003
MC/DC0%0/2
$flags & 512 || $flags & 256
$flags & 512 $flags & 256
Truth table33%1/3
A || B
A= $flags & 512B= $flags & 256
ABresult
1X1
011
000
296 3 ▶ return ($is_str and not($is_num));
Condition33%1/3
$is_str && !$is_num
!ll&&!rl&&r
003
MC/DC0%0/2
$is_str && !$is_num
$is_str !$is_num
Truth table33%1/3
A && not(B)
A= $is_strB= !$is_num
ABresult
0X0
100
111
297 }
298
299 0 ▶ sub _is_integer {
Subroutine _is_integer: not called CC=2 SCAR=17.9
300 0 my $v = shift;
301 0 ▶ return 0 unless (_is_numeric($v));
Branch: 1 branch
BranchTrueFalseTotal
unless _is_numeric($v) 0 0 0
302 0 my $i = int($v);
303 0 my $f = $v - $i;
304 0 return ($f == 0);
305 }
306  
307 0 ▶ sub _is_numeric {
Subroutine _is_numeric: not called CC=4 SCAR=30.0
308 0 my $v = shift;
309 0 ▶ return 0 unless defined($v);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v 0 0 0
310 0 ▶ return 0 if ref($v);
Branch: 1 branch
BranchTrueFalseTotal
if ref $v 0 0 0
311 0 my $sv = svref_2object(\$v);
312 0 my $flags = $sv->FLAGS;
313 0 ▶ my $is_num = (($flags & SVf_NOK) or ($flags & SVf_IOK));
Condition0%0/3
$flags & 512 || $flags & 256
l!l&&r!l&&!r
000
MC/DC0%0/2
$flags & 512 || $flags & 256
$flags & 512 $flags & 256
Truth table0%0/3
A || B
A= $flags & 512B= $flags & 256
ABresult
1X1
011
000
314 0 return $is_num;
315 }
316
317 0 ▶ sub _is_abs_iri {
Subroutine _is_abs_iri: not called CC=4 SCAR=30.0
318 0 my $self = shift;
319 0 my $value = shift;
320 0 ▶ return 0 unless (length($value));
Branch: 1 branch
BranchTrueFalseTotal
unless length $value 0 0 0
321 0 my $i = eval { IRI->new($value) };
322 0 ▶ unless ($i) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($i) 0 0 0
323 0 return 0;
324 }
325 0 ▶ my $is_abs = (defined($i->scheme) and $value eq $i->abs);
Condition0%0/3
defined $i->scheme && $value eq $i->abs
!ll&&!rl&&r
000
MC/DC0%0/2
defined $i->scheme && $value eq $i->abs
defined $i->scheme $value eq $i->abs
Truth table0%0/3
A && B
A= defined $i->schemeB= $value eq $i->abs
ABresult
0X0
100
111
326 0 return $is_abs;
327 }
328
329 1 ▶ sub _is_iri {
Subroutine _is_iri: called CC=1 SCAR=0.0
330 1 my $self = shift;
331 1 my $value = shift;
332 1 my $i = eval { IRI->new(value => $value) };
333 1 my $err = $@;
334 1 my $is_iri = not($@);
335 1 return $is_iri;
336 }
337  
338 0 ▶ sub _make_relative_iri {
Subroutine _make_relative_iri: not called CC=2 SCAR=17.9
339 0 my $base = shift;
340 0 my $rel = shift;
341 0 ▶ println "Make relative IRI from: " . Data::Dumper->Dump([$base->abs, $rel->abs], [qw(base rel)]) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
342 0 my $r = $rel->rel($base)->abs;
343 0 return $r;
344 }
345
346 0 ▶ sub _load_document {
Subroutine _load_document: not called CC=1 SCAR=6.9
347 0 my $self = shift;
348 0 my $url = shift;
349 0 my $profile = shift;
350 0 my $req_profile = shift;
351 0 my $ua = LWP::UserAgent->new();
352 0 my $resp = $ua->get($url);
353 0 return $resp;
354 }
355
356 6 ▶ sub _cm_contains {
Subroutine _cm_contains: called CC=6 SCAR=25.9
357 6 my $self = shift;
358 6 my $container_mapping = shift;
359 6 my $value = shift;
360 6 ▶ if (ref($container_mapping)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $container_mapping) { } 0 6 6
361 0 ▶ Carp::cluck unless (ref($container_mapping) eq 'ARRAY');
Branch: 1 branch
BranchTrueFalseTotal
unless ref $container_mapping eq "ARRAY" 0 0 0
362 0 foreach my $m (@$container_mapping) {
363 0 ▶ return 1 if ($m eq $value);
Branch: 1 branch
BranchTrueFalseTotal
if $m eq $value 0 0 0
364 }
365 } else {
366 6 ▶ return (defined($container_mapping) and $container_mapping eq $value);
Condition33%1/3
defined $container_mapping && $container_mapping eq $value
!ll&&!rl&&r
600
MC/DC0%0/2
defined $container_mapping && $container_mapping eq $value
defined $container_mapping $container_mapping eq $value
Truth table33%1/3
A && B
A= defined $container_mappingB= $container_mapping eq $value
ABresult
0X0
100
111
367 }
368 }
369  
370 1 ▶ sub _cm_contains_any {
Subroutine _cm_contains_any: called CC=3 SCAR=11.0
371 1 my $self = shift;
372 1 my $container_mapping = shift;
373 1 my @values = @_;
374 1 foreach my $value (@values) {
375 3 ▶ return 1 if ($self->_cm_contains($container_mapping, $value));
Branch: 1 branch
BranchTrueFalseTotal
if $self->_cm_contains($container_mapping, $value) 0 3 3
376 }
377 1 return 0;
378 }
379
380 12 ▶ sub _ctx_term_defn {
Subroutine _ctx_term_defn: called CC=2 SCAR=7.0
381 12 my $self = shift;
382 12 my $ctx = shift;
383 12 my $term = shift;
384 12 ▶ confess "Bad context type in _ctx_term_defn: " . ref($ctx) unless (ref($ctx) eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
unless ref $ctx eq "HASH" 0 12 12
385 2 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
386 12 return $ctx->{'terms'}{$term};
387 }
388  
389 0 ▶ sub _ctx_contains_protected_terms {
Subroutine _ctx_contains_protected_terms: not called CC=1 SCAR=6.9
390 0 my $self = shift;
391 0 my $ctx = shift;
392 0 my @prot = $self->_ctx_protected_terms($ctx);
393 0 return scalar(@prot);
394 }
395
396 0 ▶ sub _ctx_protected_terms {
Subroutine _ctx_protected_terms: not called CC=3 SCAR=24.8
397 0 my $self = shift;
398 0 my $ctx = shift;
399 0 my @protected;
400 0 foreach my $term (keys %{ $ctx->{'terms'} }) {
401 0 ▶ push(@protected, $term) if $ctx->{'terms'}{$term}{'protected'};
Branch: 1 branch
BranchTrueFalseTotal
if $ctx->{"terms"}{$term}{"protected"} 0 0 0
402 }
403 0 return @protected;
404 }
405
406 0 ▶ sub _is_node_object {
Subroutine _is_node_object: not called CC=4 SCAR=30.0
407 0 my $self = shift;
408 0 my $value = shift;
409 0 ▶ return 0 unless (ref($value) eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value eq "HASH" 0 0 0
410 0 foreach my $p (qw(@value @list @set)) {
411 0 ▶ return 0 if (exists $value->{$p});
Branch: 1 branch
BranchTrueFalseTotal
if exists $value->{$p} 0 0 0
412 }
413 # TODO: check that value "is not the top-most map in the JSON-LD document consisting of no other entries than @graph and @context."
414 0 return 1;
415 }
416
417 0 ▶ sub _is_value_object {
Subroutine _is_value_object: not called CC=2 SCAR=17.9
418 0 my $self = shift;
419 0 my $value = shift;
420 0 ▶ return 0 unless (ref($value) eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value eq "HASH" 0 0 0
421 0 return (exists $value->{'@value'});
422 }
423  
424 0 ▶ sub _is_default_object {
Subroutine _is_default_object: not called CC=2 SCAR=17.9
425 0 my $self = shift;
426 0 my $value = shift;
427 0 ▶ return 0 unless (ref($value) eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value eq "HASH" 0 0 0
428 0 return (exists $value->{'@default'});
429 }
430  
431 0 ▶ sub _is_list_object {
Subroutine _is_list_object: not called CC=2 SCAR=17.9
432 0 my $self = shift;
433 0 my $value = shift;
434 0 ▶ return 0 unless (ref($value) eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value eq "HASH" 0 0 0
435 0 return (exists $value->{'@list'});
436 }
437
438 0 ▶ sub _is_graph_object {
Subroutine _is_graph_object: not called CC=2 SCAR=17.9
439 0 my $self = shift;
440 0 my $value = shift;
441 0 ▶ return 0 unless (ref($value) eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value eq "HASH" 0 0 0
442 0 return (exists $value->{'@graph'});
443 }
444
445 0 ▶ sub _is_simple_graph_object {
Subroutine _is_simple_graph_object: not called CC=2 SCAR=17.9
446 0 my $self = shift;
447 0 my $value = shift;
448 0 ▶ return 0 unless ($self->_is_graph_object($value));
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_is_graph_object($value) 0 0 0
449 0 return (not exists $value->{'@id'});
450 }
451
452 0 ▶ sub _add_value {
Subroutine _add_value: not called CC=8 SCAR=42.8
453 0 my $self = shift;
454 0 my $object = shift;
455 0 my $key = shift;
456 0 my $value = shift;
457 0 ▶ unless (defined($value)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $value) 0 0 0
458 0 Carp::cluck "undefined value in add_value";
459 }
460 0 my %args = @_;
461 0 ▶ my $as_array = $args{'as_array'} // 0;
Condition0%0/2
$args{"as_array"} // 0
l!l
00
MC/DC0%0/1
$args{"as_array"} // 0
$args{"as_array"}
Truth table0%0/2
A
A= $args{"as_array"}
Aresult
11
00
462 0 ▶ if ($as_array and ref($value) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if ($as_array and ref $value ne "ARRAY") 0 0 0
Condition0%0/3
$as_array and ref $value ne "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
$as_array and ref $value ne "ARRAY"
$as_array ref $value ne "ARRAY"
Truth table0%0/3
A and B
A= $as_arrayB= ref $value ne "ARRAY"
ABresult
0X0
100
111
463 0 $value = [$value];
464 }
465
466 0 ▶ if (not exists $object->{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $object->{$key}) { } 0 0 0
467 0 $object->{$key} = $value;
468 } else {
469 0 ▶ if (ref($object->{$key}) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $object->{$key} ne "ARRAY") 0 0 0
470 0 $object->{$key} = [$object->{$key}];
471 }
472
473 0 ▶ if (ref($value) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq 'ARRAY') { } 0 0 0
474 0 push(@{ $object->{$key} }, @$value);
475 } else {
476 0 push(@{ $object->{$key} }, $value);
477 }
478 }
479 }
480
481 0 ▶ sub _is_well_formed_graph_node {
Subroutine _is_well_formed_graph_node: not called CC=3 SCAR=24.8
482 0 my $self = shift;
483 0 my $value = shift;
484 0 ▶ return 1 if $self->_is_well_formed_iri($value);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_is_well_formed_iri($value) 0 0 0
485 0 ▶ return 1 if ($value =~ /^_:/);
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /^_:/u 0 0 0
486 0 return 0;
487 }
488
489 0 ▶ sub _is_well_formed_language {
Subroutine _is_well_formed_language: not called CC=3 SCAR=24.8
490 0 my $self = shift;
491 0 my $value = shift;
492 0 my $ok = ($value =~ m/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/);
493 0 ▶ if (not $ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 0 0 0
494 0 ▶ println "not a well-formed language: $value\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
495 }
496 0 return $ok;
497 }
498
499 0 ▶ sub _is_well_formed_datatype {
Subroutine _is_well_formed_datatype: not called CC=3 SCAR=24.8
500 0 my $self = shift;
501 0 my $value = shift;
502 0 ▶ return 1 if ($value eq '@json');
Branch: 1 branch
BranchTrueFalseTotal
if $value eq "\@json" 0 0 0
503 0 ▶ return 1 if $self->_is_well_formed_iri($value);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_is_well_formed_iri($value) 0 0 0
504 0 return 0;
505 }
506
507 0 ▶ sub _is_well_formed_iri {
Subroutine _is_well_formed_iri: not called CC=3 SCAR=24.8
508 0 my $self = shift;
509 0 my $value = shift;
510 0 my $ok = ($self->_is_abs_iri($value));
511 0 ▶ if (not $ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 0 0 0
512 0 ▶ println "not a well-formed IRI: $value\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
513 }
514 0 return $ok;
515 }
516
517 0 ▶ sub _is_well_formed_graphname {
Subroutine _is_well_formed_graphname: not called CC=5 SCAR=34.0
518 0 my $self = shift;
519 0 my $value = shift;
520 0 ▶ my $ok = ($self->_is_abs_iri($value) or ($value eq '@default') or ($value =~ /^_:(\w+)$/));
Condition0%0/6
$self->_is_abs_iri($value) || $value eq '@default' || $value =~ /^_:(\w+)$/u
l!l&&r!l&&!r
000
$self->_is_abs_iri($value) or $value eq "\@default"
l!l&&r!l&&!r
000
MC/DC0%0/3
$self->_is_abs_iri($value) || $value eq '@default' || $value =~ /^_:(\w+)$/u
$self->_is_abs_iri($value) $value eq "\@default" $value =~ /^_:(\w+)$/u
Truth table0%0/4
A or B || C
A= $self->_is_abs_iri($value)B= $value eq "\@default"C= $value =~ /^_:(\w+)$/u
ABCresult
1XX1
01X1
0011
0000
521 0 ▶ if (not $ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 0 0 0
522 0 ▶ println "not a well-formed graph name: $value\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
523 }
524 0 return $ok;
525 }
526
527 0 ▶ sub _is_well_formed {
Subroutine _is_well_formed: not called CC=2 SCAR=17.9
528 0 my $self = shift;
529 0 my $value = shift;
530 0 ▶ println "TODO: _is_well_formed: $value" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
531 0 return 1;
532 }
533  
534 1 ▶ sub _4_1_2_ctx_processing {
Subroutine _4_1_2_ctx_processing: called CC=131 SCAR=90.7
535 1 ▶ println "ENTER =================> _4_1_2_ctx_processing" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
536 1 my $__indent = indent();
537 1 my $self = shift;
538 1 my $activeCtx = shift;
539 1 my $localCtx = shift;
540 1 local($Data::Dumper::Indent) = 0;
541 1 ▶ println(Data::Dumper->Dump([$activeCtx], ['*activeCtx'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
542 1 ▶ println(Data::Dumper->Dump([$localCtx], ['*localCtx'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
543 1 my %args = @_;
544 1 ▶ my $propagate = $args{propagate} // 1;
Condition50%1/2
$args{"propagate"} // 1
l!l
01
MC/DC0%0/1
$args{"propagate"} // 1
$args{"propagate"}
Truth table50%1/2
A
A= $args{"propagate"}
Aresult
11
00
545 1 ▶ my $remote_contexts = $args{remote_contexts} // [];
Condition50%1/2
$args{"remote_contexts"} // []
l!l
01
MC/DC0%0/1
$args{"remote_contexts"} // []
$args{"remote_contexts"}
Truth table50%1/2
A
A= $args{"remote_contexts"}
Aresult
11
00
546 1 ▶ my $validate_scoped_context = $args{validate_scoped_context} // 1;
Condition50%1/2
$args{"validate_scoped_context"} // 1
l!l
01
MC/DC0%0/1
$args{"validate_scoped_context"} // 1
$args{"validate_scoped_context"}
Truth table50%1/2
A
A= $args{"validate_scoped_context"}
Aresult
11
00
547 1 ▶ my $override_protected = $args{override_protected} // 0;
Condition50%1/2
$args{"override_protected"} // 0
l!l
01
MC/DC0%0/1
$args{"override_protected"} // 0
$args{"override_protected"}
Truth table50%1/2
A
A= $args{"override_protected"}
Aresult
11
00
548 1 ▶ my $base_iri = $args{base_iri} // $self->base_iri->abs;
Condition33%1/3
$args{"base_iri"} // $self->base_iri->abs
l!l&&r!l&&!r
010
MC/DC0%0/2
$args{"base_iri"} // $self->base_iri->abs
$args{"base_iri"} $self->base_iri->abs
Truth table33%1/3
A // B
A= $args{"base_iri"}B= $self->base_iri->abs
ABresult
1X1
011
000
549  
550 1 ▶ println "1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
551 1 my $result = clone($activeCtx); # 1
552 1 ▶ confess "Bad active context type in _4_1_2_ctx_processing: " . Dumper($activeCtx) unless (ref($activeCtx) eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
unless ref $activeCtx eq "HASH" 0 1 1
553 1 ▶ if (ref($localCtx) eq 'HASH' and exists $localCtx->{'@propagate'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $localCtx eq "HASH" and exists $localCtx->{"\@propagate"}) 0 1 1
Condition33%1/3
ref $localCtx eq "HASH" and exists $localCtx->{"\@propagate"}
!ll&&!rl&&r
010
MC/DC0%0/2
ref $localCtx eq "HASH" and exists $localCtx->{"\@propagate"}
ref $localCtx eq "HASH" exists $localCtx->{"\@propagate"}
Truth table33%1/3
A and B
A= ref $localCtx eq "HASH"B= exists $localCtx->{"\@propagate"}
ABresult
0X0
100
111
554 0 ▶ println "2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
555 0 $propagate = (!!$localCtx->{'@propagate'}); # 2
556 }
557
558 1 ▶ if (not($propagate) and not exists $result->{'previous_context'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($propagate or exists $result->{"previous_context"}) 0 1 1
Condition33%1/3
$propagate or exists $result->{"previous_context"}
l!l&&r!l&&!r
100
MC/DC0%0/2
$propagate or exists $result->{"previous_context"}
$propagate exists $result->{"previous_context"}
Truth table33%1/3
A or B
A= $propagateB= exists $result->{"previous_context"}
ABresult
1X1
011
000
559 0 ▶ println "3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
560 0 $result->{'previous_context'} = $activeCtx; # 3
561 }
562
563 1 ▶ if (ref($localCtx) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $localCtx ne "ARRAY") 1 0 1
564 1 ▶ println "4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
565 1 $localCtx = [$localCtx]; # 4
566 }
567
568 1 ▶ println "5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
569 1 foreach my $context (@$localCtx) {
570 1 my $__indent = indent();
571 1 ▶ println '-----------------------------------------------------------------' if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
572 1 ▶ println "5 loop for each local context item" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
573 1 ▶ println(Data::Dumper->Dump([$context], ['*context'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
574 1 ▶ if (not(defined($context))) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $context) 0 1 1
575 # 5.1
576 0 ▶ println "5.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
577 0 ▶ if (not($override_protected) and $self->_ctx_contains_protected_terms($activeCtx)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $override_protected and $self->_ctx_contains_protected_terms($activeCtx)) { } 0 0 0
Condition0%0/3
not $override_protected and $self->_ctx_contains_protected_terms($activeCtx)
!ll&&!rl&&r
000
MC/DC0%0/2
not $override_protected and $self->_ctx_contains_protected_terms($activeCtx)
not $override_protected $self->_ctx_contains_protected_terms($activeCtx)
Truth table0%0/3
not(A) and B
A= not $override_protectedB= $self->_ctx_contains_protected_terms($activeCtx)
ABresult
0X0
100
111
578 0 my @prot = $self->_ctx_protected_terms($activeCtx);
579 0 ▶ println "5.1.1 " . Data::Dumper->Dump([\@prot], ['protected_terms']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
580 0 die 'invalid context nullification'; # 5.1.1
581 } else {
582 0 ▶ println "5.1.2 moving to next context" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
583 0 my $prev = $result;
584 0 $result = {
585 '@base' => $self->base_iri->abs, # TODO: not sure this follows the spec, but it's what makes test t0089 pass
586 };
587 0 ▶ if ($propagate) {
Branch: 1 branch
BranchTrueFalseTotal
if ($propagate) 0 0 0
588 0 $result->{'previous_context'} = $prev;
589 }
590 0 next;
591 }
592 }
593  
594 1 ▶ if (not(ref($context))) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $context) 0 1 1
595 0 ▶ println "5.2 $context" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
596
597 0 ▶ println "5.2.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
598 0 $context = IRI->new(value => $context, base => $base_iri)->abs;
599
600 0 ▶ if (scalar(@$remote_contexts) > $self->max_remote_contexts) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$remote_contexts > $self->max_remote_contexts) 0 0 0
601 0 ▶ println "5.2.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
602 0 die 'context overflow';
603 }
604
605 0 my %already = map { $_ => 1 } @$remote_contexts;
606 0 ▶ if (not($validate_scoped_context) and $already{$context}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $validate_scoped_context and $already{$context}) 0 0 0
Condition0%0/3
not $validate_scoped_context and $already{$context}
!ll&&!rl&&r
000
MC/DC0%0/2
not $validate_scoped_context and $already{$context}
not $validate_scoped_context $already{$context}
Truth table0%0/3
not(A) and B
A= not $validate_scoped_contextB= $already{$context}
ABresult
0X0
100
111
607 0 next;
608 }
609
610 0 ▶ unless ($already{$context}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($already{$context}) 0 0 0
611 0 push(@$remote_contexts, $context);
612 }
613  
614 0 my $context_url = $context;
615 0 ▶ if (my $c = $self->parsed_remote_contexts->{$context}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $c = $self->parsed_remote_contexts->{$context}) { } 0 0 0
616 0 ▶ println "5.2.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
617 0 $context = $c;
618 } else {
619 0 ▶ println "5.2.4 loading context from: $context_url" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
620 0 my $resp = $self->_load_document($context_url, 'http://www.w3.org/ns/json-ld#context', 'http://www.w3.org/ns/json-ld#context');
621 0 ▶ if (not $resp->is_success) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($resp->is_success) 0 0 0
622 0 ▶ println "5.2.5 " . $resp->status_line if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
623 0 die 'loading remote context failed';
624 }
625 0 ▶ my $content = $resp->content_is_text ? $resp->decoded_content : decode_utf8($resp->decoded_content);
Branch: 1 branch
BranchTrueFalseTotal
$resp->content_is_text ? : 0 0 0
626 0 $context = eval { decode_json(encode('UTF-8', $content))->{'@context'} };
627 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
628 0 ▶ println "5.2.5 $@" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
629 0 die 'loading remote context failed';
630 }
631 0 $self->parsed_remote_contexts->{$context_url} = $context;
632 }
633  
634 0 ▶ println "5.2.6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
635 0 $result = $self->_4_1_2_ctx_processing($result, $context, remote_contexts => clone($remote_contexts), validate_scoped_context => $validate_scoped_context, base_iri => $context_url);
636  
637 0 ▶ println "5.2.7 moving to next context" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
638 0 next;
639 }
640  
641 1 ▶ if (ref($context) ne 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $context ne "HASH") 0 1 1
642 0 ▶ println "5.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
643 0 die "invalid_local_context"; # 5.3
644 }
645
646 1 ▶ println "5.4" if $debug; # no-op
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
647  
648 1 ▶ if (exists $context->{'@version'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $context->{"\@version"}) 0 1 1
649 0 ▶ println "5.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
650 0 my $v = $context->{'@version'};
651 0 ▶ if ($v ne '1.1') {
Branch: 1 branch
BranchTrueFalseTotal
if ($v ne "1.1") 0 0 0
652 0 ▶ println "5.5.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
653 0 die 'invalid @version value'; # 5.5.1
654 }
655 0 ▶ if ($self->processing_mode eq 'json-ld-1.0') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->processing_mode eq "json-ld-1.0") 0 0 0
656 0 ▶ println "5.5.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
657 0 die 'processing mode conflict';
658 }
659 }
660  
661 1 ▶ if (exists $context->{'@import'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $context->{"\@import"}) 0 1 1
662 0 ▶ println "5.6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
663 0 ▶ if ($self->processing_mode eq 'json-ld-1.0') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->processing_mode eq "json-ld-1.0") 0 0 0
664 0 ▶ println "5.6.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
665 0 die 'invalid context entry';
666 }
667
668 0 my $value = $context->{'@import'};
669 0 ▶ if (ref($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value) 0 0 0
670 0 ▶ println "5.6.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
671 0 die 'invalid @import value';
672 }
673
674 0 ▶ println "5.6.3 resolving \@import $value" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
675 0 my $import = IRI->new(value => $value, base => $self->base_iri)->abs;
676
677 0 ▶ println "5.6.4 loading $import" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
678 0 my $resp = $self->_load_document($import, 'http://www.w3.org/ns/json-ld#context', 'http://www.w3.org/ns/json-ld#context');
679
680 0 ▶ if (not $resp->is_success) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($resp->is_success) 0 0 0
681 0 ▶ println "5.6.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
682 0 die 'loading remote context failed';
683 }
684
685 0 ▶ my $content = $resp->content_is_text ? $resp->decoded_content : decode_utf8($resp->decoded_content);
Branch: 1 branch
BranchTrueFalseTotal
$resp->content_is_text ? : 0 0 0
686 0 my $j = eval { decode_json(encode('UTF-8', $content))->{'@context'} };
687 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
688 0 ▶ println "5.6.5 $@" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
689 0 die 'loading remote context failed';
690 }
691
692 0 ▶ unless (ref($j) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $j eq "HASH") 0 0 0
693 0 ▶ println "5.6.6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
694 0 die 'invalid remote context';
695 }
696 0 my $import_context = $j;
697
698 0 ▶ if (exists $import_context->{'@import'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $import_context->{"\@import"}) 0 0 0
699 0 ▶ println "5.6.7" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
700 0 die 'invalid context entry';
701 }
702
703 0 ▶ println "5.6.8" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
704 0 %$context = (%$import_context, %$context);
705 0 ▶ println(Data::Dumper->Dump([$context], ['context'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
706 }
707
708 1 ▶ if (exists $context->{'@base'} and scalar(@$remote_contexts) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $context->{"\@base"} and scalar @$remote_contexts == 0) 0 1 1
Condition33%1/3
exists $context->{"\@base"} and scalar @$remote_contexts == 0
!ll&&!rl&&r
100
MC/DC0%0/2
exists $context->{"\@base"} and scalar @$remote_contexts == 0
exists $context->{"\@base"} scalar @$remote_contexts == 0
Truth table33%1/3
A and B
A= exists $context->{"\@base"}B= scalar @$remote_contexts == 0
ABresult
0X0
100
111
709 0 ▶ println "5.7" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
710 0 ▶ println "5.7.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
711 0 my $value = $context->{'@base'};
712 0 ▶ println(Data::Dumper->Dump([$result], ['result'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
713
714 0 ▶ if (not defined($value)) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $value) { } 0 0 0
elsif ($self->_is_abs_iri($value)) { } 0 0 0
elsif ($self->_is_iri($value) and defined $result->{'@base'}) { } 0 0 0
715 0 ▶ println "5.7.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
716 0 delete $result->{'@base'};
717 } elsif ($self->_is_abs_iri($value)) {
718 0 ▶ println "5.7.3 " . Data::Dumper->Dump([$value], ['base']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
719 0 $result->{'@base'} = $value;
720 ▶ } elsif ($self->_is_iri($value) and defined($result->{'@base'})) {
Condition0%0/3
$self->_is_iri($value) and defined $result->{"\@base"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_is_iri($value) and defined $result->{"\@base"}
$self->_is_iri($value) defined $result->{"\@base"}
Truth table0%0/3
A and B
A= $self->_is_iri($value)B= defined $result->{"\@base"}
ABresult
0X0
100
111
721 0 ▶ println "5.7.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
722 0 my $base = IRI->new($result->{'@base'});
723 0 my $i = IRI->new(value => $value, base => $base);
724 0 $result->{'@base'} = $i->abs;
725 } else {
726 0 ▶ println "5.7.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
727 0 die 'invalid base IRI';
728 }
729 }
730
731 1 ▶ if (exists $context->{'@vocab'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $context->{"\@vocab"}) 1 0 1
732 1 ▶ println "5.8" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
733 1 ▶ println "5.8.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
734 1 my $value = $context->{'@vocab'}; # 5.8.1
735 1 ▶ if (not defined($value)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $value) { } 0 1 1
elsif ($value =~ /^_/u or $self->_is_iri($value)) { } 1 0 1
736 0 ▶ println "5.8.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
737 0 delete $result->{'@vocab'}; # 5.8.2
738 ▶ } elsif ($value =~ /^_/ or $self->_is_iri($value)) {
Condition33%1/3
$value =~ /^_/u or $self->_is_iri($value)
l!l&&r!l&&!r
010
MC/DC0%0/2
$value =~ /^_/u or $self->_is_iri($value)
$value =~ /^_/u $self->_is_iri($value)
Truth table33%1/3
A or B
A= $value =~ /^_/uB= $self->_is_iri($value)
ABresult
1X1
011
000
739 1 ▶ println "5.8.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
740 1 my $iri = $self->_5_2_2_iri_expansion($result, $value, vocab => 1, documentRelative => 1);
741 1 $result->{'@vocab'} = $iri;
742 } else {
743 0 die 'invalid vocab mapping';
744 }
745 }
746
747 1 ▶ if (exists $context->{'@language'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $context->{"\@language"}) 0 1 1
748 0 ▶ println "5.9" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
749 0 ▶ println "5.9.1 language = " . $context->{'@language'} if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
750 0 my $value = $context->{'@language'};
751
752 0 ▶ if (not defined($value)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $value) { } 0 0 0
elsif (_is_string($value)) { } 0 0 0
753 0 ▶ println "5.9.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
754 0 delete $result->{'@language'};
755 } elsif (_is_string($value)) {
756 0 ▶ println "5.9.3 value is a string" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
757 0 $result->{'@language'} = $value;
758 # TODO: validate language tag against BCP47
759 } else {
760 0 ▶ println "5.9.3 value is NOT a string" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
761 0 die 'invalid default language';
762 }
763 }
764
765 1 ▶ if (exists $context->{'@direction'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $context->{"\@direction"}) 0 1 1
766 0 ▶ println "5.10" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
767 0 ▶ if ($self->processing_mode eq 'json-ld-1.0') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->processing_mode eq "json-ld-1.0") 0 0 0
768 0 ▶ println "5.10.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
769 0 die 'invalid context entry';
770 }
771
772 0 ▶ println "5.10.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
773 0 my $value = $context->{'@direction'};
774
775 0 ▶ if (not defined($value)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $value) { } 0 0 0
elsif (_is_string($value)) { } 0 0 0
776 0 ▶ println "5.10.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
777 0 delete $result->{'@direction'};
778 } elsif (_is_string($value)) {
779 0 ▶ println "5.10.4 \@direction = $value" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
780 0 ▶ if ($value ne 'ltr' and $value ne 'rtl') {
Branch: 1 branch
BranchTrueFalseTotal
if ($value ne "ltr" and $value ne "rtl") 0 0 0
Condition0%0/3
$value ne "ltr" and $value ne "rtl"
!ll&&!rl&&r
000
MC/DC0%0/2
$value ne "ltr" and $value ne "rtl"
$value ne "ltr" $value ne "rtl"
Truth table0%0/3
A and B
A= $value ne "ltr"B= $value ne "rtl"
ABresult
0X0
100
111
781 0 die 'invalid base direction';
782 }
783 0 $result->{'@direction'} = $value;
784 }
785 }
786
787 1 ▶ if (exists $context->{'@propagate'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $context->{"\@propagate"}) 0 1 1
788 0 ▶ println "5.11" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
789 0 ▶ if ($self->processing_mode eq 'json-ld-1.0') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->processing_mode eq "json-ld-1.0") 0 0 0
790 0 ▶ println "5.11.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
791 0 die 'invalid context entry';
792 }
793
794 0 my $p = $context->{'@propagate'};
795 0 ▶ if ($p ne '1' and $p ne '0' and ref($p) ne 'JSON::PP::Boolean') { # boolean true or false
Branch: 1 branch
BranchTrueFalseTotal
if ($p ne 1 and $p ne 0 and ref $p ne "JSON::PP::Boolean") 0 0 0
Condition0%0/6
$p ne 1 and $p ne 0 and ref $p ne "JSON::PP::Boolean"
!ll&&!rl&&r
000
$p ne 1 and $p ne 0
!ll&&!rl&&r
000
MC/DC0%0/3
$p ne 1 and $p ne 0 and ref $p ne "JSON::PP::Boolean"
$p ne 1 $p ne 0 ref $p ne "JSON::PP::Boolean"
Truth table0%0/4
A and B and C
A= $p ne 1B= $p ne 0C= ref $p ne "JSON::PP::Boolean"
ABCresult
0XX0
10X0
1100
1111
796 0 ▶ println "5.11.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
797 0 die 'invalid @propagate value';
798 }
799
800 0 ▶ println "5.11.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
801 }
802
803 1 ▶ println "5.12" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
804 1 my $defined = {}; # 5.12
805
806 1 my @keys = reverse sort grep { $_ !~ /^[@](base|direction|import|language|propagate|protected|version|vocab)$/ } keys %$context;
807 1 ▶ println "5.13" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
808 1 foreach my $key (@keys) {
809 0 my $__indent = indent();
810 0 ▶ println "5.13 [$key]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
811 0 my $value = $context->{$key};
812 0 $self->_4_2_2_create_term_definition($result, $context, $key, $defined, protected => $context->{'@protected'}, override_protected => $override_protected, remote_contexts => clone($remote_contexts), validate_scoped_context => $validate_scoped_context, base_iri => $base_iri); # 5.13
813 }
814 }
815  
816 1 local($Data::Dumper::Indent) = 1;
817 1 ▶ println "6 returning from _4_1_2_ctx_processing with " . Data::Dumper->Dump([$result], ['final_context']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
818 1 return $result; # 6
819 }
820
821 0 ▶ sub _4_2_2_create_term_definition {
Subroutine _4_2_2_create_term_definition: not called CC=213 SCAR=107.3
822 0 my $self = shift;
823 0 my $activeCtx = shift;
824 0 my $localCtx = shift;
825 0 my $term = shift;
826 0 ▶ my $defined = shift // {};
Condition0%0/2
shift() // {}
l!l
00
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
827 0 ▶ println "ENTER =================> _4_2_2_create_term_definition('$term')" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
828 0 my $__indent = indent();
829 0 local($Data::Dumper::Indent) = 0;
830 0 ▶ println(Data::Dumper->Dump([$activeCtx], ['*activeCtx'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
831 0 ▶ println(Data::Dumper->Dump([$localCtx], ['*localCtx'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
832 0 ▶ println(Data::Dumper->Dump([$defined], ['*defined'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
833 0 my %args = @_;
834 0 ▶ my $protected = $args{protected} // 0;
Condition0%0/2
$args{"protected"} // 0
l!l
00
MC/DC0%0/1
$args{"protected"} // 0
$args{"protected"}
Truth table0%0/2
A
A= $args{"protected"}
Aresult
11
00
835 0 ▶ my $override_protected = $args{override_protected} // 0;
Condition0%0/2
$args{"override_protected"} // 0
l!l
00
MC/DC0%0/1
$args{"override_protected"} // 0
$args{"override_protected"}
Truth table0%0/2
A
A= $args{"override_protected"}
Aresult
11
00
836 0 ▶ my $remote_contexts = $args{remote_contexts} // [];
Condition0%0/2
$args{"remote_contexts"} // []
l!l
00
MC/DC0%0/1
$args{"remote_contexts"} // []
$args{"remote_contexts"}
Truth table0%0/2
A
A= $args{"remote_contexts"}
Aresult
11
00
837 0 ▶ my $validate_scoped_context = $args{validate_scoped_context} // 1;
Condition0%0/2
$args{"validate_scoped_context"} // 1
l!l
00
MC/DC0%0/1
$args{"validate_scoped_context"} // 1
$args{"validate_scoped_context"}
Truth table0%0/2
A
A= $args{"validate_scoped_context"}
Aresult
11
00
838 0 ▶ my $base_iri = $args{base_iri} // $self->base_iri->abs;
Condition0%0/3
$args{"base_iri"} // $self->base_iri->abs
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"base_iri"} // $self->base_iri->abs
$args{"base_iri"} $self->base_iri->abs
Truth table0%0/3
A // B
A= $args{"base_iri"}B= $self->base_iri->abs
ABresult
1X1
011
000
839
840 # 4.2.2
841 0 ▶ if (exists ($defined->{$term})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $defined->{$term}) 0 0 0
842 # 1
843 0 ▶ println "1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
844 0 ▶ if ($defined->{$term}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($defined->{$term}) { } 0 0 0
elsif (exists $defined->{$term}) { } 0 0 0
845 0 ▶ println "returning from _4_2_2_create_term_definition: term definition has already been created\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
846 0 return;
847 } elsif (exists $defined->{$term}) {
848 0 die "cyclic IRI mapping";
849 }
850 }
851
852 0 ▶ println "2 [setting defined{$term} = 0]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
853 0 my $term_copy = $term;
854 0 ▶ if ($term_copy eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($term_copy eq '') { } 0 0 0
855 0 die 'invalid term definition';
856 } else {
857 0 $defined->{$term} = 0; # 2
858 }
859
860 0 ▶ println "3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
861 0 my $value = clone($localCtx->{$term}); # 3
862 0 ▶ println "3 " . Data::Dumper->Dump([$value], ['value']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
863
864 # NOTE: the language interaction between 4 and 5 here is a mess. Unclear what "Otherwise" applies to. Similarly with the "Otherwise" that begins 7 below.
865 0 ▶ if ($self->processing_mode eq 'json-ld-1.1' and $term eq '@type') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->processing_mode eq 'json-ld-1.1' and $term eq '@type') { } 0 0 0
Condition0%0/3
$self->processing_mode eq "json-ld-1.1" and $term eq "\@type"
!ll&&!rl&&r
000
MC/DC0%0/2
$self->processing_mode eq "json-ld-1.1" and $term eq "\@type"
$self->processing_mode eq "json-ld-1.1" $term eq "\@type"
Truth table0%0/3
A and B
A= $self->processing_mode eq "json-ld-1.1"B= $term eq "\@type"
ABresult
0X0
100
111
866 # 4
867 0 ▶ println "4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
868 0 ▶ unless (ref($value) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $value eq "HASH") 0 0 0
869 0 die 'keyword redefinition';
870 }
871 0 my @keys = grep { $_ ne '@protected' } keys %$value;
872 0 ▶ die 'keyword redefinition' unless (scalar(@keys) == 1 and $keys[0] eq '@container');
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @keys == 1 and $keys[0] eq "\@container" 0 0 0
Condition0%0/3
scalar @keys == 1 and $keys[0] eq "\@container"
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @keys == 1 and $keys[0] eq "\@container"
scalar @keys == 1 $keys[0] eq "\@container"
Truth table0%0/3
A and B
A= scalar @keys == 1B= $keys[0] eq "\@container"
ABresult
0X0
100
111
873 0 ▶ die 'keyword redefinition' unless ($value->{'@container'} eq '@set');
Branch: 1 branch
BranchTrueFalseTotal
unless $value->{"\@container"} eq "\@set" 0 0 0
874 } else {
875 # 5
876 0 ▶ println "5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
877 0 ▶ if (exists $keywords{$term}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $keywords{$term}) 0 0 0
878 0 ▶ println "5 keyword redefinition: $term" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
879 0 die 'keyword redefinition';
880 }
881 0 ▶ if ($term =~ /^@[A-Za-z]+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term =~ /^\@[A-Za-z]+$/u) 0 0 0
882 # https://www.w3.org/2018/json-ld-wg/Meetings/Minutes/2019/2019-09-20-json-ld#section5-2
883 0 warn "create term definition attempted on a term that looks like a keyword: $term\n";
884 0 ▶ println "5 returning so as to ignore a term that has the form of a keyword: $term" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
885 0 return;
886 }
887 }
888
889 0 ▶ println "6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
890 0 my $previous_defn = $self->_ctx_term_defn($activeCtx, $term); # 6
891 0 delete $activeCtx->{'terms'}{$term}; # https://github.com/w3c/json-ld-api/issues/176#issuecomment-545167708
892  
893 0 my $simple_term;
894 0 ▶ if (not(defined($value))) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $value) { } 0 0 0
elsif (_is_string($value)) { } 0 0 0
elsif (ref $value eq 'HASH') { } 0 0 0
895 0 ▶ println "7" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
896 0 $value = {'@id' => undef}; # 7
897 } elsif (_is_string($value)) {
898 # 8
899 0 ▶ println "8 value = {'\@id' => $value}" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
900 0 $value = {'@id' => $value};
901 0 $simple_term = 1;
902 } elsif (ref($value) eq 'HASH') {
903 0 ▶ println "9" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
904 0 $simple_term = 0; # 9
905 } else {
906 0 ▶ println "9" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
907 0 die "invalid_term_definition"; # 9
908 }
909
910 0 ▶ println "10" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
911 0 my $definition = {'__source_base_iri' => $base_iri}; # 10
912
913 0 ▶ if ($value->{'@protected'}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($value->{'@protected'}) { } 0 0 0
elsif (not exists $value->{'@protected'} and $protected) { } 0 0 0
914 0 ▶ println "11" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
915 0 $definition->{'protected'} = 1; # 11
916 0 ▶ println "11 TODO processing mode of json-ld-1.0" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
917 ▶ } elsif (not exists $value->{'@protected'} and $protected) {
Condition0%0/3
not exists $value->{"\@protected"} and $protected
!ll&&!rl&&r
000
MC/DC0%0/2
not exists $value->{"\@protected"} and $protected
not exists $value->{"\@protected"} $protected
Truth table0%0/3
not(A) and B
A= not exists $value->{"\@protected"}B= $protected
ABresult
0X0
100
111
918 0 ▶ println "12" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
919 0 $definition->{'protected'} = 1; # 12
920 }
921  
922 0 ▶ if (exists $value->{'@type'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $value->{"\@type"}) 0 0 0
923 # 13
924 0 ▶ println "13" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
925 0 my $type = $value->{'@type'}; # 13.1
926 0 ▶ if (ref($type)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $type) 0 0 0
927 0 ▶ println "13.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
928 0 die "invalid_type_mapping"; # 13.1
929 }
930
931 0 ▶ println "13.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
932 0 $type = $self->_5_2_2_iri_expansion($activeCtx, $type, vocab => 1, localCtx => $localCtx, 'defined' => $defined); # 13.2
933 0 ▶ println(Data::Dumper->Dump([$type], ['type'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
934  
935 0 ▶ if (($type eq '@json' or $type eq '@none') and $self->processing_mode eq 'json-ld-1.0') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "\@json" || $type eq "\@none" and $self->processing_mode eq "json-ld-1.0") 0 0 0
Condition0%0/6
$type eq "\@json" || $type eq "\@none" and $self->processing_mode eq "json-ld-1.0"
!ll&&!rl&&r
000
$type eq "\@json" or $type eq "\@none"
l!l&&r!l&&!r
000
MC/DC0%0/3
$type eq "\@json" || $type eq "\@none" and $self->processing_mode eq "json-ld-1.0"
$type eq "\@json" $type eq "\@none" $self->processing_mode eq "json-ld-1.0"
Truth table0%0/5
A or B and C
A= $type eq "\@json"B= $type eq "\@none"C= $self->processing_mode eq "json-ld-1.0"
ABCresult
00X0
1X00
0100
1X11
0111
936 # https://github.com/w3c/json-ld-api/issues/259
937 0 ▶ println "13.3 " . Data::Dumper->Dump([$type], ['*type']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
938 0 die 'invalid type mapping';
939 }
940
941 0 ▶ if ($type ne '@id' and $type ne '@vocab' and $type ne '@none' and $type ne '@json' and not($self->_is_abs_iri($type))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type ne "\@id" and $type ne "\@vocab" and $type ne "\@none" and $type ne "\@json" and not $self->_is_abs_iri($type)) 0 0 0
Condition0%0/12
$type ne "\@id" and $type ne "\@vocab" and $type ne "\@none" and $type ne "\@json" and not $self->_is_abs_iri($type)
!ll&&!rl&&r
000
$type ne "\@id" and $type ne "\@vocab" and $type ne "\@none" and $type ne "\@json"
!ll&&!rl&&r
000
$type ne "\@id" and $type ne "\@vocab" and $type ne "\@none"
!ll&&!rl&&r
000
$type ne "\@id" and $type ne "\@vocab"
!ll&&!rl&&r
000
MC/DC0%0/5
$type ne "\@id" and $type ne "\@vocab" and $type ne "\@none" and $type ne "\@json" and not $self->_is_abs_iri($type)
$type ne "\@id" $type ne "\@vocab" $type ne "\@none" $type ne "\@json" not $self->_is_abs_iri($type)
Truth table0%0/6
A and B and C and D and not(E)
A= $type ne "\@id"B= $type ne "\@vocab"C= $type ne "\@none"D= $type ne "\@json"E= not $self->_is_abs_iri($type)
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
942 # TODO: handle case "nor, if processing mode is json-ld-1.1, @json nor @none"
943 0 ▶ println "13.4 " . Data::Dumper->Dump([$type], ['*type']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
944 0 die 'invalid type mapping'; # 13.4
945 }
946
947 0 ▶ println "13.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
948 0 $definition->{'type_mapping'} = $type; # 13.5
949 }
950
951 0 ▶ if (exists $value->{'@reverse'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $value->{"\@reverse"}) 0 0 0
952 # 14
953 0 ▶ println "14" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
954 0 ▶ if (exists $value->{'@id'} or exists $value->{'@nest'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $value->{"\@id"} or exists $value->{"\@nest"}) 0 0 0
Condition0%0/3
exists $value->{"\@id"} or exists $value->{"\@nest"}
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $value->{"\@id"} or exists $value->{"\@nest"}
exists $value->{"\@id"} exists $value->{"\@nest"}
Truth table0%0/3
A or B
A= exists $value->{"\@id"}B= exists $value->{"\@nest"}
ABresult
1X1
011
000
955 0 ▶ println "14.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
956 0 die 'invalid reverse property'; # 14.1
957 }
958 0 my $reverse = $value->{'@reverse'};
959 0 ▶ if (ref($reverse)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $reverse) 0 0 0
960 0 ▶ println "14.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
961 0 die 'invalid IRI mapping'; # 14.2
962 }
963 0 ▶ if ($reverse =~ /^@[A-Za-z]+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($reverse =~ /^\@[A-Za-z]+$/u) { } 0 0 0
964 0 ▶ println "14.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
965 0 warn '@reverse value looks like a keyword: ' . $reverse; # 14.3
966 0 return;
967 } else {
968 # 14.4
969 0 ▶ println "14.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
970 0 my $m = $self->_5_2_2_iri_expansion($activeCtx, $reverse, vocab => 1, localCtx => $localCtx, 'defined' => $defined);
971 0 ▶ if (not($self->_is_abs_iri($m)) and $m !~ /^:/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_is_abs_iri($m) or $m =~ /^:/u) 0 0 0
Condition0%0/3
$self->_is_abs_iri($m) or $m =~ /^:/u
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->_is_abs_iri($m) or $m =~ /^:/u
$self->_is_abs_iri($m) $m =~ /^:/u
Truth table0%0/3
A or B
A= $self->_is_abs_iri($m)B= $m =~ /^:/u
ABresult
1X1
011
000
972 0 die 'invalid IRI mapping';
973 }
974 0 $definition->{'iri_mapping'} = $m;
975 }
976
977 0 ▶ if (exists $value->{'@container'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $value->{"\@container"}) 0 0 0
978 # 14.5
979 0 ▶ println "14.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
980 0 my $c = $value->{'@container'};
981 0 ▶ if ($c ne '@set' and $c ne '@index' and defined($c)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c ne "\@set" and $c ne "\@index" and defined $c) 0 0 0
Condition0%0/6
$c ne "\@set" and $c ne "\@index" and defined $c
!ll&&!rl&&r
000
$c ne "\@set" and $c ne "\@index"
!ll&&!rl&&r
000
MC/DC0%0/3
$c ne "\@set" and $c ne "\@index" and defined $c
$c ne "\@set" $c ne "\@index" defined $c
Truth table0%0/4
A and B and C
A= $c ne "\@set"B= $c ne "\@index"C= defined $c
ABCresult
0XX0
10X0
1100
1111
982 0 die 'invalid reverse property';
983 }
984 0 $definition->{'container_mapping'} = [$c];
985 }
986
987 0 ▶ println "14.6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
988 0 $definition->{'reverse'} = 1; # 14.6
989
990 # 14.7
991 0 ▶ println "14.7 [setting defined{$term} = 1]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
992 0 $activeCtx->{'terms'}{$term} = $definition;
993 0 $defined->{$term} = 1;
994 0 local($Data::Dumper::Indent) = 0;
995 0 ▶ println "returning from _4_2_2_create_term_definition: " . Dumper($activeCtx->{'terms'}{$term}) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
996 0 return;
997 }
998  
999 0 ▶ println "15" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1000 0 $definition->{'reverse'} = 0; # 15
1001
1002 0 ▶ if (exists $value->{'@id'} and (not(defined($value->{'@id'})) or $value->{'@id'} ne $term)) {
Branch: 4 branches
BranchTrueFalseTotal
if (exists $value->{'@id'} and !defined($value->{'@id'}) || $value->{'@id'} ne $term) { } 0 0 0
elsif ($term =~ /.:/u) { } 0 0 0
elsif ($term =~ m[/]u) { } 0 0 0
elsif ($term eq '@type') { } 0 0 0
Condition0%0/6
exists $value->{"\@id"} and !defined($value->{"\@id"}) || $value->{"\@id"} ne $term
!ll&&!rl&&r
000
not defined $value->{"\@id"} or $value->{"\@id"} ne $term
l!l&&r!l&&!r
000
MC/DC0%0/3
exists $value->{"\@id"} and !defined($value->{"\@id"}) || $value->{"\@id"} ne $term
exists $value->{"\@id"} not defined $value->{"\@id"} $value->{"\@id"} ne $term
Truth table0%0/4
A and not(B) or C
A= exists $value->{"\@id"}B= not defined $value->{"\@id"}C= $value->{"\@id"} ne $term
ABCresult
0XX0
1000
11X1
1011
1003 # 16
1004 0 ▶ println "16" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1005 0 ▶ if (not defined($value->{'@id'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $value->{'@id'}) { } 0 0 0
1006 0 ▶ println "16.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1007 } else {
1008 0 ▶ println "16.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1009 0 my $id = $value->{'@id'};
1010 0 ▶ if (not _is_string($id)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (_is_string($id)) 0 0 0
1011 0 ▶ println "16.2.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1012 0 die 'invalid IRI mapping'; # 16.2
1013 }
1014
1015 0 ▶ if (defined($id) and not exists $keywords{$id} and $id =~ /^@[A-Za-z]+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $id and not exists $keywords{$id} and $id =~ /^\@[A-Za-z]+$/u) { } 0 0 0
Condition0%0/6
defined $id and not exists $keywords{$id} and $id =~ /^\@[A-Za-z]+$/u
!ll&&!rl&&r
000
defined $id and not exists $keywords{$id}
!ll&&!rl&&r
000
MC/DC0%0/3
defined $id and not exists $keywords{$id} and $id =~ /^\@[A-Za-z]+$/u
defined $id not exists $keywords{$id} $id =~ /^\@[A-Za-z]+$/u
Truth table0%0/4
A and not(B) and C
A= defined $idB= not exists $keywords{$id}C= $id =~ /^\@[A-Za-z]+$/u
ABCresult
0XX0
10X0
1100
1111
1016 0 ▶ println "16.2.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1017 0 warn "create term definition encountered an \@id that looks like a keyword: $id\n";
1018 0 return;
1019 } else {
1020 0 ▶ println "16.2.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1021 0 my $iri = $self->_5_2_2_iri_expansion($activeCtx, $id, vocab => 1, localCtx => $localCtx, 'defined' => $defined);
1022 0 ▶ if (not exists $keywords{$iri} and not $self->_is_abs_iri($iri) and $iri !~ /:/) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $keywords{$iri} or $self->_is_abs_iri($iri) or $iri =~ /:/u) 0 0 0
Condition0%0/6
exists $keywords{$iri} or $self->_is_abs_iri($iri) or $iri =~ /:/u
l!l&&r!l&&!r
000
exists $keywords{$iri} or $self->_is_abs_iri($iri)
l!l&&r!l&&!r
000
MC/DC0%0/3
exists $keywords{$iri} or $self->_is_abs_iri($iri) or $iri =~ /:/u
exists $keywords{$iri} $self->_is_abs_iri($iri) $iri =~ /:/u
Truth table0%0/4
A or B or C
A= exists $keywords{$iri}B= $self->_is_abs_iri($iri)C= $iri =~ /:/u
ABCresult
1XX1
01X1
0011
0000
1023 0 die 'invalid IRI mapping';
1024 }
1025 0 ▶ if ($iri eq '@context') {
Branch: 1 branch
BranchTrueFalseTotal
if ($iri eq "\@context") 0 0 0
1026 0 die 'invalid keyword alias';
1027 }
1028 0 $definition->{'iri_mapping'} = $iri;
1029 }
1030 0 ▶ if ($term =~ /.:./ or index($term, '/') >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term =~ /.:./u or index($term, "/") != -1) 0 0 0
Condition0%0/3
$term =~ /.:./u or index($term, "/") != -1
l!l&&r!l&&!r
000
MC/DC0%0/2
$term =~ /.:./u or index($term, "/") != -1
$term =~ /.:./u index($term, "/") != -1
Truth table0%0/3
A or B
A= $term =~ /.:./uB= index($term, "/") != -1
ABresult
1X1
011
000
1031 0 ▶ println "16.2.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1032 0 ▶ println "16.2.4.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1033 0 $defined->{$term} = 1;
1034  
1035 0 my $iri = $self->_5_2_2_iri_expansion($activeCtx, $term, vocab => 1, localCtx => $localCtx, 'defined' => $defined);
1036 0 ▶ if ($iri ne $definition->{'iri_mapping'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($iri ne $definition->{"iri_mapping"}) 0 0 0
1037 0 ▶ println "16.2.4.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1038 0 die 'invalid IRI mapping'; # 16.5 ; NOTE: the text here doesn't discuss what parameters to pass to IRI expansion
1039 }
1040 }
1041
1042 0 ▶ if ($term !~ m{[:/]} and $simple_term and $definition->{'iri_mapping'} =~ m{[][:/?#@]$}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $term =~ m[[:/]]u and $simple_term and $definition->{"iri_mapping"} =~ m[[][:/?#@]$]u) 0 0 0
Condition0%0/6
not $term =~ m[[:/]]u and $simple_term and $definition->{"iri_mapping"} =~ m[[][:/?#@]$]u
!ll&&!rl&&r
000
not $term =~ m[[:/]]u and $simple_term
!ll&&!rl&&r
000
MC/DC0%0/3
not $term =~ m[[:/]]u and $simple_term and $definition->{"iri_mapping"} =~ m[[][:/?#@]$]u
not $term =~ m[[:/]]u $simple_term $definition->{"iri_mapping"} =~ m[[][:/?#@]$]u
Truth table0%0/4
not(A) and B and C
A= not $term =~ m[[:/]]uB= $simple_termC= $definition->{"iri_mapping"} =~ m[[][:/?#@]$]u
ABCresult
0XX0
10X0
1100
1111
1043 0 ▶ println "16.2.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1044 0 $definition->{'prefix_flag'} = 1;
1045 }
1046 # }
1047 }
1048 } elsif ($term =~ /.:/) {
1049 # 17
1050 0 ▶ println "17" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1051 0 my ($prefix, $suffix) = split(/:/, $term, 2);
1052 0 ▶ if (exists $localCtx->{$prefix}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $localCtx->{$prefix}) 0 0 0
1053 0 ▶ println "17.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1054 0 $self->_4_2_2_create_term_definition($activeCtx, $localCtx, $prefix, $defined); # 17.1
1055 }
1056 0 ▶ if (exists $activeCtx->{'terms'}{$prefix}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $activeCtx->{'terms'}{$prefix}) { } 0 0 0
1057 0 ▶ println "17.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1058 0 $definition->{'iri_mapping'} = $activeCtx->{'terms'}{$prefix}{'iri_mapping'} . $suffix; # 17.2
1059 } else {
1060 0 ▶ println "17.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1061 0 $definition->{'iri_mapping'} = $term; # 17.3
1062 }
1063 } elsif ($term =~ m{/}) {
1064 0 ▶ println "18" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1065 0 println "18.1"; # if $debug;
1066
1067 0 ▶ println "18.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1068 0 $definition->{'iri_mapping'} = $self->_5_2_2_iri_expansion($activeCtx, $term, vocab => 1);
1069 0 ▶ unless ($self->_is_iri($definition->{'iri_mapping'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_is_iri($definition->{"iri_mapping"})) 0 0 0
1070 0 println "18.2 invalid IRI: " . $definition->{'iri_mapping'};
1071 0 die 'invalid IRI mapping';
1072 }
1073 } elsif ($term eq '@type') {
1074 0 ▶ println "19" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1075 0 $definition->{'iri_mapping'} = '@type'; # 19
1076 } else {
1077 # 20 ; NOTE: this section uses a passive voice "the IRI mapping of definition is set to ..." cf. 18 where it's active: "set the IRI mapping of definition to @type"
1078 0 ▶ if (exists $activeCtx->{'@vocab'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $activeCtx->{'@vocab'}) { } 0 0 0
1079 0 ▶ println "20" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1080 0 $definition->{'iri_mapping'} = $activeCtx->{'@vocab'} . $term;
1081 } else {
1082 0 ▶ println "20" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1083 0 die 'invalid IRI mapping';
1084 }
1085 }
1086
1087 0 ▶ if (exists $value->{'@container'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $value->{"\@container"}) 0 0 0
1088 # TODO: 21
1089 0 ▶ println "21" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1090  
1091 0 ▶ println "21.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1092 0 my $container = $value->{'@container'}; # 21.1
1093  
1094 # 21.1 error checking
1095 0 my %acceptable = map { $_ => 1 } qw(@graph @id @index @language @list @set @type);
1096 0 ▶ if (exists $acceptable{$container}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $acceptable{$container}) { } 0 0 0
elsif (ref $container eq 'ARRAY') { } 0 0 0
1097 } elsif (ref($container) eq 'ARRAY') {
1098 0 ▶ if (scalar(@$container) == 1) {
Branch: 3 branches
BranchTrueFalseTotal
if (scalar @$container == 1) { } 0 0 0
elsif (&any(sub { $_ =~ /^[\@](id|index)$/u; } , @$container)) { } 0 0 0
elsif (&any(sub { $_ eq '@set'; } , @$container) and &any(sub { $_ =~ /^[\@](index|graph|id|type|language)$/u; } , @$container)) { } 0 0 0
1099 0 my ($c) = @$container;
1100 0 ▶ unless (exists $acceptable{$c}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $acceptable{$c}) 0 0 0
1101 0 ▶ println "21.1(a)" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1102 0 die 'invalid container mapping';
1103 }
1104 0 ▶ } elsif (any { $_ =~ /^[@](id|index)$/ } @$container) { # any { $_ eq '@graph' } @$container
Subroutine __ANON__: not called CC=1 SCAR=6.9
1105
1106 0 ▶ } elsif (any { $_ eq '@set' } @$container and any { $_ =~ /^[@](index|graph|id|type|language)$/ } @$container) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
&any(sub { $_ eq "\@set"; } , @$container) and &any(sub { $_ =~ /^[\@](index|graph|id|type|language)$/u; } , @$container)
!ll&&!rl&&r
000
MC/DC0%0/2
&any(sub { $_ eq "\@set"; } , @$container) and &any(sub { $_ =~ /^[\@](index|graph|id|type|language)$/u; } , @$container)
&any(sub { $_ eq "\@set"; } , @$container) &any(sub { $_ =~ /^[\@](index|graph|id|type|language)$/u; } , @$container)
Truth table0%0/3
A and B
A= &any(sub { $_ eq "\@set"; } , @$container)B= &any(sub { $_ =~ /^[\@](index|graph|id|type|language)$/u; } , @$container)
ABresult
0X0
100
111
1107
1108 } else {
1109 0 ▶ println "21.1(b)" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1110 0 die 'invalid container mapping';
1111 }
1112 } else {
1113 0 ▶ println "21.1(c)" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1114 0 die 'invalid container mapping';
1115 }
1116
1117 0 ▶ if ($self->processing_mode eq 'json-ld-1.0') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->processing_mode eq "json-ld-1.0") 0 0 0
1118 0 ▶ if (any { $container eq $_ } qw(@graph @id @type) or ref($container)) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if (&any(sub { $container eq $_; } , "\@graph", "\@id", "\@type") or ref $container) 0 0 0
Condition0%0/3
&any(sub { $container eq $_; } , "\@graph", "\@id", "\@type") or ref $container
l!l&&r!l&&!r
000
MC/DC0%0/2
&any(sub { $container eq $_; } , "\@graph", "\@id", "\@type") or ref $container
&any(sub { $container eq $_; } , "\@graph", "\@id", "\@type") ref $container
Truth table0%0/3
A or B
A= &any(sub { $container eq $_; } , "\@graph", "\@id", "\@type")B= ref $container
ABresult
1X1
011
000
1119 0 ▶ println "21.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1120 0 die 'invalid container mapping';
1121 }
1122 }
1123
1124 0 ▶ println "21.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1125 0 ▶ if (ref($container) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $container eq 'ARRAY') { } 0 0 0
1126 0 $definition->{'container_mapping'} = $container; # 21.3
1127 } else {
1128 0 $definition->{'container_mapping'} = [$container]; # 21.3
1129 }
1130
1131 0 ▶ if ($container eq '@type') {
Branch: 1 branch
BranchTrueFalseTotal
if ($container eq "\@type") 0 0 0
1132 0 ▶ println "21.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1133 0 ▶ if (not defined($definition->{'type_mapping'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $definition->{"type_mapping"}) 0 0 0
1134 0 ▶ println "21.4.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1135 0 $definition->{'type_mapping'} = '@id';
1136 }
1137
1138 0 my $tm = $definition->{'type_mapping'};
1139 0 ▶ if ($tm ne '@id' and $tm ne '@vocab') {
Branch: 1 branch
BranchTrueFalseTotal
if ($tm ne "\@id" and $tm ne "\@vocab") 0 0 0
Condition0%0/3
$tm ne "\@id" and $tm ne "\@vocab"
!ll&&!rl&&r
000
MC/DC0%0/2
$tm ne "\@id" and $tm ne "\@vocab"
$tm ne "\@id" $tm ne "\@vocab"
Truth table0%0/3
A and B
A= $tm ne "\@id"B= $tm ne "\@vocab"
ABresult
0X0
100
111
1140 0 ▶ println "21.4.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1141 0 die 'invalid type mapping';
1142 }
1143 }
1144 }
1145  
1146 0 ▶ if (exists $value->{'@index'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $value->{"\@index"}) 0 0 0
1147 0 ▶ println "22" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1148 0 my $container_mapping = $definition->{'container_mapping'};
1149 0 ▶ if ($self->processing_mode eq 'json-ld-1.0' or not $self->_cm_contains($container_mapping, '@index')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->processing_mode eq "json-ld-1.0" or not $self->_cm_contains($container_mapping, "\@index")) 0 0 0
Condition0%0/3
$self->processing_mode eq "json-ld-1.0" or not $self->_cm_contains($container_mapping, "\@index")
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->processing_mode eq "json-ld-1.0" or not $self->_cm_contains($container_mapping, "\@index")
$self->processing_mode eq "json-ld-1.0" not $self->_cm_contains($container_mapping, "\@index")
Truth table0%0/3
A or not(B)
A= $self->processing_mode eq "json-ld-1.0"B= not $self->_cm_contains($container_mapping, "\@index")
ABresult
1X1
011
000
1150 0 ▶ println "22.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1151 0 die 'invalid term definition';
1152 }
1153  
1154 0 ▶ println "22.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1155 0 my $index = $value->{'@index'};
1156 0 my $expanded = $self->_5_2_2_iri_expansion($activeCtx, $index, vocab => 1);
1157 0 ▶ unless ($self->_is_abs_iri($expanded)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_is_abs_iri($expanded)) 0 0 0
1158 0 die 'invalid term definition';
1159 }
1160
1161 0 ▶ println "22.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1162 0 $definition->{'index_mapping'} = $index;
1163 }
1164  
1165 0 ▶ if (exists $value->{'@context'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $value->{"\@context"}) 0 0 0
1166 0 ▶ println "23" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1167 0 ▶ if ($self->processing_mode eq 'json-ld-1.0') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->processing_mode eq "json-ld-1.0") 0 0 0
1168 0 ▶ println "23.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1169 0 die 'invalid term definition';
1170 }
1171  
1172 0 ▶ println "23.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1173 0 my $context = $value->{'@context'};
1174  
1175 0 ▶ println "23.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1176 # $self->_4_1_2_ctx_processing($activeCtx, $context, override_protected => 1, remote_contexts => clone($remote_contexts), validate_scoped_context => $validate_scoped_context, base_iri => $base_iri); # discard result
1177 0 $self->_4_1_2_ctx_processing($activeCtx, $context, override_protected => 1, remote_contexts => clone($remote_contexts), validate_scoped_context => 0, base_iri => $base_iri); # discard result
1178 # $self->_4_1_2_ctx_processing($activeCtx, $context, override_protected => 1); # discard result
1179
1180 0 $definition->{'@context'} = $context; # Note: not sure about the spec text wording here: "Set the local context of definition to context." What is the "local context" of a definition?
1181 }
1182  
1183 0 ▶ if (exists $value->{'@language'} and not exists $value->{'@type'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $value->{"\@language"} and not exists $value->{"\@type"}) 0 0 0
Condition0%0/3
exists $value->{"\@language"} and not exists $value->{"\@type"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $value->{"\@language"} and not exists $value->{"\@type"}
exists $value->{"\@language"} not exists $value->{"\@type"}
Truth table0%0/3
A and not(B)
A= exists $value->{"\@language"}B= not exists $value->{"\@type"}
ABresult
0X0
100
111
1184 0 ▶ println "24" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1185 0 ▶ println "24.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1186 0 my $language = $value->{'@language'};
1187 0 ▶ if (defined($language) and ref($language)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $language and ref $language) 0 0 0
Condition0%0/3
defined $language and ref $language
!ll&&!rl&&r
000
MC/DC0%0/2
defined $language and ref $language
defined $language ref $language
Truth table0%0/3
A and B
A= defined $languageB= ref $language
ABresult
0X0
100
111
1188 0 die 'invalid language mapping';
1189 }
1190 # TODO: validate language tag against BCP47
1191  
1192 0 ▶ println "24.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1193 # TODO: normalize language tag
1194 0 $definition->{'language_mapping'} = $language;
1195 }
1196  
1197 0 ▶ if (exists $value->{'@direction'} and not exists $value->{'@type'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $value->{"\@direction"} and not exists $value->{"\@type"}) 0 0 0
Condition0%0/3
exists $value->{"\@direction"} and not exists $value->{"\@type"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $value->{"\@direction"} and not exists $value->{"\@type"}
exists $value->{"\@direction"} not exists $value->{"\@type"}
Truth table0%0/3
A and not(B)
A= exists $value->{"\@direction"}B= not exists $value->{"\@type"}
ABresult
0X0
100
111
1198 0 ▶ println "25" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1199 0 my $direction = $value->{'@direction'};
1200  
1201 0 ▶ println "25.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1202 0 ▶ if (not(defined($direction))) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $direction) { } 0 0 0
elsif ($direction ne 'ltr' and $direction ne 'rtl') { } 0 0 0
1203 ▶ } elsif ($direction ne 'ltr' and $direction ne 'rtl') {
Condition0%0/3
$direction ne "ltr" and $direction ne "rtl"
!ll&&!rl&&r
000
MC/DC0%0/2
$direction ne "ltr" and $direction ne "rtl"
$direction ne "ltr" $direction ne "rtl"
Truth table0%0/3
A and B
A= $direction ne "ltr"B= $direction ne "rtl"
ABresult
0X0
100
111
1204 0 die 'invalid base direction';
1205 }
1206
1207 0 $definition->{'direction_mapping'} = $direction;
1208 }
1209  
1210 0 ▶ if (exists $value->{'@nest'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $value->{"\@nest"}) 0 0 0
1211 0 ▶ println "26" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1212 0 ▶ if ($self->processing_mode eq 'json-ld-1.0') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->processing_mode eq "json-ld-1.0") 0 0 0
1213 0 ▶ println "26.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1214 0 die 'invalid term definition';
1215 }
1216
1217 0 ▶ println "26.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1218 0 my $nv = $value->{'@nest'};
1219 0 ▶ if (not(defined($nv)) or ref($nv)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $nv or ref $nv) { } 0 0 0
elsif (exists $keywords{$nv} and $nv ne '@nest') { } 0 0 0
Condition0%0/3
not defined $nv or ref $nv
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $nv or ref $nv
not defined $nv ref $nv
Truth table0%0/3
not(A) or B
A= not defined $nvB= ref $nv
ABresult
1X1
011
000
1220 0 die 'invalid @nest value';
1221 ▶ } elsif (exists $keywords{$nv} and $nv ne '@nest') {
Condition0%0/3
exists $keywords{$nv} and $nv ne "\@nest"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $keywords{$nv} and $nv ne "\@nest"
exists $keywords{$nv} $nv ne "\@nest"
Truth table0%0/3
A and B
A= exists $keywords{$nv}B= $nv ne "\@nest"
ABresult
0X0
100
111
1222 0 die 'invalid @nest value';
1223 }
1224 0 $definition->{'nest_value'} = $nv;
1225 }
1226  
1227 0 ▶ if (exists $value->{'@prefix'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $value->{"\@prefix"}) 0 0 0
1228 0 ▶ println "27" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1229 0 ▶ if ($self->processing_mode eq 'json-ld-1.0' or $term =~ m{[:/]}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->processing_mode eq "json-ld-1.0" or $term =~ m[[:/]]u) 0 0 0
Condition0%0/3
$self->processing_mode eq "json-ld-1.0" or $term =~ m[[:/]]u
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->processing_mode eq "json-ld-1.0" or $term =~ m[[:/]]u
$self->processing_mode eq "json-ld-1.0" $term =~ m[[:/]]u
Truth table0%0/3
A or B
A= $self->processing_mode eq "json-ld-1.0"B= $term =~ m[[:/]]u
ABresult
1X1
011
000
1230 0 ▶ println "27.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1231 0 die 'invalid term definition'; # 27.1
1232 }
1233
1234 0 ▶ println "27.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1235 0 $definition->{'prefix_flag'} = $value->{'@prefix'};
1236 0 ▶ unless (JSON::is_bool($value->{'@prefix'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (&JSON::is_bool($value->{"\@prefix"})) 0 0 0
1237 0 die 'invalid @prefix value';
1238 }
1239
1240 0 ▶ if ($definition->{'prefix_flag'} and exists $keywords{$definition->{'iri_mapping'}}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($definition->{"prefix_flag"} and exists $keywords{$definition->{"iri_mapping"}}) 0 0 0
Condition0%0/3
$definition->{"prefix_flag"} and exists $keywords{$definition->{"iri_mapping"}}
!ll&&!rl&&r
000
MC/DC0%0/2
$definition->{"prefix_flag"} and exists $keywords{$definition->{"iri_mapping"}}
$definition->{"prefix_flag"} exists $keywords{$definition->{"iri_mapping"}}
Truth table0%0/3
A and B
A= $definition->{"prefix_flag"}B= exists $keywords{$definition->{"iri_mapping"}}
ABresult
0X0
100
111
1241 0 ▶ println "27.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1242 0 die 'invalid term definition';
1243 }
1244 }
1245  
1246 0 my @keys = grep { not m/^[@](id|reverse|container|context|language|nest|prefix|type|direction|protected|index)$/ } keys %$value;
1247 0 ▶ if (scalar(@keys)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @keys) 0 0 0
1248 0 ▶ println "28 " . Data::Dumper->Dump([\@keys, $value], ['invalid_keys', 'value']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1249 0 die 'invalid term definition'; # 28
1250 }
1251
1252 0 ▶ if (not($override_protected) and $previous_defn->{'protected'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $override_protected and $previous_defn->{"protected"}) 0 0 0
Condition0%0/3
not $override_protected and $previous_defn->{"protected"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $override_protected and $previous_defn->{"protected"}
not $override_protected $previous_defn->{"protected"}
Truth table0%0/3
not(A) and B
A= not $override_protectedB= $previous_defn->{"protected"}
ABresult
0X0
100
111
1253 # 29
1254 0 ▶ println "29" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1255 0 my %cmp_a = map { $_ => $definition->{$_} } grep { $_ ne 'protected' } keys %$definition;
1256 0 my %cmp_b = map { $_ => $previous_defn->{$_} } grep { $_ ne 'protected' } keys %$previous_defn;
1257 0 my $j = JSON->new->canonical(1);
1258 0 ▶ if ($j->encode(\%cmp_a) ne $j->encode(\%cmp_b)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j->encode(\%cmp_a) ne $j->encode(\%cmp_b)) 0 0 0
1259 0 ▶ println "29.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1260 0 die 'protected term redefinition'; # 29.1
1261 }
1262 0 ▶ println "29.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1263 0 $definition = $previous_defn; # 29.2
1264 }
1265
1266 0 ▶ println "30 [setting defined{$term} = 1]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1267 0 ▶ println "30 setting term definition " . Data::Dumper->Dump([$definition], [$term]) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1268 0 $activeCtx->{'terms'}{$term} = $definition; # 30
1269 0 $defined->{$term} = 1; # 30
1270 0 local($Data::Dumper::Indent) = 0;
1271 0 ▶ println "returning from _4_2_2_create_term_definition: " . Dumper($activeCtx->{'terms'}{$term}) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1272 0 return;
1273 }
1274  
1275 0 ▶ sub _4_3_inverse_context_creation {
Subroutine _4_3_inverse_context_creation: not called CC=82 SCAR=87.9
1276 0 my $self = shift;
1277 0 my $activeCtx = shift;
1278 {
1279 0 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.2
1280 0 ▶ println "ENTER =================> _4_3_inverse_context_creation" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1281 }
1282 0 my $__indent = indent();
1283 0 ▶ println "1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1284 0 my $result = {};
1285
1286 0 ▶ println "2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1287 0 my $default_language = '@none';
1288 0 ▶ if (exists $activeCtx->{'@language'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $activeCtx->{"\@language"}) 0 0 0
1289 0 $default_language = lc($activeCtx->{'@language'});
1290 }
1291
1292 0 ▶ println "3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1293 0 ▶ foreach my $term (sort { length($a) <=> length($b) || $a cmp $b } keys %{ $activeCtx->{'terms'} }) {
Condition0%0/3
length $a <=> length $b || $a cmp $b
l!l&&r!l&&!r
000
MC/DC0%0/2
length $a <=> length $b || $a cmp $b
length $a <=> length $b $a cmp $b
Truth table0%0/3
A || B
A= length $a <=> length $bB= $a cmp $b
ABresult
1X1
011
000
1294 0 my $__indent = indent();
1295 0 ▶ println "3 [$term]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1296 0 my $tdef = $self->_ctx_term_defn($activeCtx, $term);
1297 0 ▶ if (not defined($tdef)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $tdef) 0 0 0
1298 0 ▶ println "3.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1299 0 next;
1300 }
1301
1302 0 ▶ println "3.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1303 0 my $container = '@none';
1304 0 ▶ my $container_mapping = $tdef->{'container_mapping'} || [];
Condition0%0/2
$tdef->{'container_mapping'} || []
l!l
00
MC/DC0%0/1
$tdef->{'container_mapping'} || []
$tdef->{'container_mapping'}
Truth table0%0/2
A
A= $tdef->{'container_mapping'}
Aresult
11
00
1305 0 ▶ if (scalar(@$container_mapping)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$container_mapping) 0 0 0
1306 0 $container = join('', sort @$container_mapping);
1307 }
1308
1309 0 ▶ println "3.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1310 0 my $var = $tdef->{'iri_mapping'};
1311
1312 0 ▶ if (not exists $result->{$var}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $result->{$var}) 0 0 0
1313 0 ▶ println "3.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1314 0 $result->{$var} = {};
1315 }
1316
1317 0 ▶ println "3.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1318 0 my $container_map = $result->{$var};
1319
1320 0 ▶ if (not exists $container_map->{$container}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $container_map->{$container}) 0 0 0
1321 0 ▶ println "3.6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1322 0 $container_map->{$container} = {
1323 '@language' => {},
1324 '@type' => {},
1325 '@any' => {
1326 '@none' => $term
1327 }
1328 };
1329 }
1330
1331 0 ▶ println "3.7" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1332 0 my $type_language_map = $container_map->{$container};
1333
1334 0 ▶ println "3.8" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1335 0 my $type_map = $type_language_map->{'@type'};
1336
1337 0 ▶ if ($tdef->{'reverse'}) {
Branch: 3 branches
BranchTrueFalseTotal
if ($tdef->{'reverse'}) { } 0 0 0
elsif (($tdef->{'type_mapping'} // '') eq '@none') { } 0 0 0
elsif (exists $tdef->{'type_mapping'}) { } 0 0 0
1338 0 ▶ println "3.9" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1339 0 ▶ if (not exists $type_map->{'@reverse'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $type_map->{"\@reverse"}) 0 0 0
1340 0 ▶ println "3.9.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1341 0 $type_map->{'@reverse'} = $term;
1342 }
1343 ▶ } elsif (($tdef->{'type_mapping'} // '') eq '@none') {
Condition0%0/2
$tdef->{"type_mapping"} // ""
l!l
00
MC/DC0%0/1
$tdef->{"type_mapping"} // ""
$tdef->{"type_mapping"}
Truth table0%0/2
A
A= $tdef->{"type_mapping"}
Aresult
11
00
1344 0 ▶ println "3.10" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1345 0 ▶ println "3.10.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1346 0 my $language_map = $type_language_map->{'@language'};
1347
1348 0 ▶ if (not exists $language_map->{'@any'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $language_map->{"\@any"}) 0 0 0
1349 0 ▶ println "3.10.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1350 0 $language_map->{'@any'} = $term;
1351 }
1352
1353 0 ▶ if (not exists $type_map->{'@any'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $type_map->{"\@any"}) 0 0 0
1354 0 ▶ println "3.10.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1355 0 $type_map->{'@any'} = $term;
1356 }
1357 } elsif (exists $tdef->{'type_mapping'}) {
1358 0 ▶ println "3.11" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1359 0 ▶ if (not exists $type_map->{$tdef->{'type_mapping'}}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $$type_map{$tdef->{"type_mapping"}}) 0 0 0
1360 0 ▶ println "3.11.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1361 0 $type_map->{$tdef->{'type_mapping'}} = $term;
1362 }
1363 }
1364
1365 0 ▶ println "3.12" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1366 0 my $language_map = $type_language_map->{'@language'};
1367
1368 0 my $lang_dir; # TODO: the spec says to create this in 3.13.1, but it's used at this level
1369 0 ▶ if (exists $tdef->{'language_mapping'} and exists $tdef->{'direction_mapping'}) {
Branch: 4 branches
BranchTrueFalseTotal
if (exists $tdef->{'language_mapping'} and exists $tdef->{'direction_mapping'}) { } 0 0 0
elsif (exists $tdef->{'language_mapping'}) { } 0 0 0
elsif (exists $tdef->{'direction_mapping'}) { } 0 0 0
elsif (exists $activeCtx->{'@direction'}) { } 0 0 0
Condition0%0/3
exists $tdef->{"language_mapping"} and exists $tdef->{"direction_mapping"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $tdef->{"language_mapping"} and exists $tdef->{"direction_mapping"}
exists $tdef->{"language_mapping"} exists $tdef->{"direction_mapping"}
Truth table0%0/3
A and B
A= exists $tdef->{"language_mapping"}B= exists $tdef->{"direction_mapping"}
ABresult
0X0
100
111
1370 0 ▶ println "3.13" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1371 0 ▶ println "3.13.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1372 # my $lang_dir;
1373  
1374 0 ▶ if (defined($tdef->{'language_mapping'}) and defined($tdef->{'direction_mapping'})) {
Branch: 3 branches
BranchTrueFalseTotal
if (defined $tdef->{'language_mapping'} and defined $tdef->{'direction_mapping'}) { } 0 0 0
elsif (defined $tdef->{'language_mapping'}) { } 0 0 0
elsif (defined $tdef->{'direction_mapping'}) { } 0 0 0
Condition0%0/3
defined $tdef->{"language_mapping"} and defined $tdef->{"direction_mapping"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $tdef->{"language_mapping"} and defined $tdef->{"direction_mapping"}
defined $tdef->{"language_mapping"} defined $tdef->{"direction_mapping"}
Truth table0%0/3
A and B
A= defined $tdef->{"language_mapping"}B= defined $tdef->{"direction_mapping"}
ABresult
0X0
100
111
1375 0 ▶ println "3.13.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1376 0 $lang_dir = lc(join('_', @{ $tdef }{qw(language_mapping direction_mapping)}));
1377 } elsif (defined($tdef->{'language_mapping'})) {
1378 0 ▶ println "3.13.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1379 0 $lang_dir = lc($tdef->{'language_mapping'});
1380 } elsif (defined($tdef->{'direction_mapping'})) {
1381 0 ▶ println "3.13.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1382 0 $lang_dir = '_' . lc($tdef->{'direction_mapping'});
1383 } else {
1384 0 ▶ println "3.13.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1385 0 $lang_dir = '@null';
1386 }
1387 0 ▶ if (not exists $language_map->{$lang_dir}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $language_map->{$lang_dir}) 0 0 0
1388 0 ▶ println "3.13.6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1389 0 $language_map->{$lang_dir} = $term;
1390 }
1391 } elsif (exists $tdef->{'language_mapping'}) {
1392 0 ▶ println "3.14" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1393 0 ▶ println "3.14.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1394 0 ▶ my $language = (not defined($tdef->{'language_mapping'})) ? '@null' : lc($tdef->{'language_mapping'});
Branch: 1 branch
BranchTrueFalseTotal
!defined($tdef->{'language_mapping'}) ? : 0 0 0
1395  
1396 0 ▶ if (not exists $language_map->{$language}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $language_map->{$language}) 0 0 0
1397 0 ▶ println "3.14.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1398 0 $language_map->{$language} = $term;
1399 }
1400 } elsif (exists $tdef->{'direction_mapping'}) {
1401 0 ▶ println "3.15" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1402 0 ▶ println "3.15.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1403 0 ▶ my $direction = (not defined $tdef->{'direction_mapping'}) ? '@none' : '_' . $tdef->{'direction_mapping'};
Branch: 1 branch
BranchTrueFalseTotal
!defined($tdef->{'direction_mapping'}) ? : 0 0 0
1404  
1405 0 ▶ if (not exists $language_map->{$direction}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $language_map->{$direction}) 0 0 0
1406 0 ▶ println "3.15.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1407 0 $language_map->{$direction} = $term;
1408 }
1409 } elsif (exists $activeCtx->{'@direction'}) {
1410 0 ▶ println "3.16" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1411 0 ▶ println "3.16.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1412 0 my $lang_dir = lc(join('_', $self->default_language, $self->default_base_direction));
1413
1414 0 ▶ if (not exists $language_map->{$lang_dir}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $language_map->{$lang_dir}) 0 0 0
1415 0 ▶ println "3.16.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1416 0 $language_map->{$lang_dir} = $term;
1417 }
1418
1419 0 ▶ if (not exists $language_map->{'@none'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $language_map->{"\@none"}) 0 0 0
1420 0 ▶ println "3.16.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1421 0 $language_map->{'@none'} = $term;
1422 }
1423
1424 0 ▶ if (not exists $type_map->{'@none'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $type_map->{"\@none"}) 0 0 0
1425 0 ▶ println "3.16.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1426 0 $type_map->{'@none'} = $term;
1427 }
1428 } else {
1429 0 ▶ println "3.17" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1430 0 ▶ if (not exists $language_map->{lc $default_language}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $$language_map{lc $default_language}) 0 0 0
1431 0 ▶ println "3.17.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1432 0 $language_map->{lc $default_language} = $term;
1433 }
1434
1435 0 ▶ if (not exists $language_map->{'@none'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $language_map->{"\@none"}) 0 0 0
1436 0 ▶ println "3.17.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1437 0 $language_map->{'@none'} = $term;
1438 }
1439  
1440 0 ▶ if (not exists $type_map->{'@none'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $type_map->{"\@none"}) 0 0 0
1441 0 ▶ println "3.17.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1442 0 $type_map->{'@none'} = $term;
1443 }
1444 }
1445 }
1446  
1447 0 ▶ println "4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1448 0 return $result;
1449 }
1450  
1451 0 ▶ sub _4_4_2_term_selection {
Subroutine _4_4_2_term_selection: not called CC=16 SCAR=56.1
1452 0 my $self = shift;
1453 0 my $inverseCtx = shift;
1454 0 my $var = shift;
1455 0 my $containers = shift;
1456 0 my $type_language = shift;
1457 0 my $preferred_values = shift;
1458 0 ▶ println "ENTER =================> _4_4_2_term_selection" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1459 0 my $__indent = indent();
1460 0 ▶ println "1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1461 0 my $container_map = $inverseCtx->{$var};
1462
1463 0 ▶ println "2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1464 0 foreach my $container (@$containers) {
1465 0 ▶ println "2 [$container]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1466 0 ▶ if (not exists $container_map->{$container}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $container_map->{$container}) 0 0 0
1467 0 ▶ println "2.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1468 0 next;
1469 }
1470 0 ▶ println "2.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1471 0 my $type_language_map = $container_map->{$container};
1472
1473 0 ▶ println "2.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1474 0 my $value_map = $type_language_map->{$type_language};
1475
1476 0 ▶ println "2.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1477 0 foreach my $item (@$preferred_values) {
1478 0 ▶ if (not exists $value_map->{$item}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $value_map->{$item}) 0 0 0
1479 0 ▶ println "2.4.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1480 0 next;
1481 }
1482
1483 0 ▶ println "2.4.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1484 0 return $value_map->{$item};
1485 }
1486 }
1487  
1488 0 ▶ println "3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1489 0 return;
1490 }
1491  
1492 2 ▶ sub _5_1_2_expansion {
Subroutine _5_1_2_expansion: called CC=137 SCAR=86.1
1493 2 my $self = shift;
1494 2 my $activeCtx = shift;
1495 2 my $activeProp = shift;
1496 2 my $element = shift;
1497 {
1498 2 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
1499 2 ▶ println "ENTER =================> _5_1_2_expansion('$activeProp')" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 2 2
1500 }
1501 2 my $__indent = indent();
1502 2 local($Data::Dumper::Indent) = 0;
1503 2 ▶ println(Data::Dumper->Dump([$activeCtx], ['activeCtx'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 2 2
1504 2 ▶ println(Data::Dumper->Dump([$activeProp], ['activeProp'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 2 2
1505 2 ▶ println(Data::Dumper->Dump([$element], ['element'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 2 2
1506 2 my %args = @_;
1507 2 ▶ my $frameExpansion = $args{frameExpansion} // 0;
Condition100%2/2
$args{"frameExpansion"} // 0
l!l
11
MC/DC100%1/1
$args{"frameExpansion"} // 0
$args{"frameExpansion"}
Truth table100%2/2
A
A= $args{"frameExpansion"}
Aresult
11
00
1508 2 ▶ my $ordered = $args{ordered} // 0;
Condition100%2/2
$args{"ordered"} // 0
l!l
11
MC/DC100%1/1
$args{"ordered"} // 0
$args{"ordered"}
Truth table100%2/2
A
A= $args{"ordered"}
Aresult
11
00
1509 2 ▶ my $fromMap = $args{fromMap} // 0;
Condition50%1/2
$args{"fromMap"} // 0
l!l
02
MC/DC0%0/1
$args{"fromMap"} // 0
$args{"fromMap"}
Truth table50%1/2
A
A= $args{"fromMap"}
Aresult
11
00
1510
1511 2 ▶ unless (defined($element)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $element) 0 2 2
1512 0 ▶ println "1 returning from _5_1_2_expansion: undefined element" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1513 0 return; # 1
1514 }
1515 2 ▶ if (defined($activeProp) and $activeProp eq '@default') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $activeProp and $activeProp eq "\@default") 0 2 2
Condition66%2/3
defined $activeProp and $activeProp eq "\@default"
!ll&&!rl&&r
110
MC/DC0%0/2
defined $activeProp and $activeProp eq "\@default"
defined $activeProp $activeProp eq "\@default"
Truth table66%2/3
A and B
A= defined $activePropB= $activeProp eq "\@default"
ABresult
0X0
100
111
1516 0 ▶ println "2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1517 0 $frameExpansion = 0; # 2
1518 }
1519
1520 2 my $property_scoped_ctx;
1521 2 my $property_scoped_ctx_defined = 0;
1522 2 my $tdef = $self->_ctx_term_defn($activeCtx, $activeProp);
1523 2 ▶ if ($tdef and exists $tdef->{'@context'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tdef and exists $tdef->{"\@context"}) 0 2 2
Condition33%1/3
$tdef and exists $tdef->{"\@context"}
!ll&&!rl&&r
200
MC/DC0%0/2
$tdef and exists $tdef->{"\@context"}
$tdef exists $tdef->{"\@context"}
Truth table33%1/3
A and B
A= $tdefB= exists $tdef->{"\@context"}
ABresult
0X0
100
111
1524 0 $property_scoped_ctx_defined = 1;
1525 0 my $lctx = $tdef->{'@context'};
1526 0 $property_scoped_ctx = $lctx; # 3
1527 0 ▶ println "3 property-scoped context for property $activeProp: " . Data::Dumper->Dump([$property_scoped_ctx], [qw(context)]) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1528 }
1529
1530 2 ▶ if (_is_scalar($element)) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_scalar($element)) 1 1 2
1531 # 4
1532 1 ▶ println "4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1533 1 ▶ if (not(defined($activeProp)) or $activeProp eq '@graph') {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $activeProp or $activeProp eq "\@graph") 0 1 1
Condition33%1/3
not defined $activeProp or $activeProp eq "\@graph"
l!l&&r!l&&!r
001
MC/DC0%0/2
not defined $activeProp or $activeProp eq "\@graph"
not defined $activeProp $activeProp eq "\@graph"
Truth table33%1/3
not(A) or B
A= not defined $activePropB= $activeProp eq "\@graph"
ABresult
1X1
011
000
1534 0 ▶ println "4.1 returning from _5_1_2_expansion: free floating scalar" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1535 0 return; # 4.1
1536 }
1537 1 ▶ if ($property_scoped_ctx_defined) {
Branch: 1 branch
BranchTrueFalseTotal
if ($property_scoped_ctx_defined) 0 1 1
1538 0 ▶ println "4.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1539 0 $activeCtx = $self->_4_1_2_ctx_processing($activeCtx, $property_scoped_ctx); # 4.2
1540 0 ▶ println "after 4.2: " . Data::Dumper->Dump([$activeCtx], ['activeCtx']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1541 }
1542
1543 1 ▶ println "4.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1544 1 my $v = $self->_5_3_2_value_expand($activeCtx, $activeProp, $element);
1545 1 local($Data::Dumper::Indent) = 1;
1546 1 ▶ println "4.3 returning from _5_1_2_expansion with " . Data::Dumper->Dump([$v], ['expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1547 1 return $v; # 4.3
1548 }
1549
1550 1 ▶ if (ref($element) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $element eq "ARRAY") 0 1 1
1551 # 5
1552 0 ▶ println "5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1553 0 my @result; # 5.1
1554 0 ▶ println "5.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1555 0 foreach my $item (@$element) {
1556 # 5.2
1557 0 ▶ println "5.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1558 0 ▶ println "5.2.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1559 0 my $expandedItem = $self->_5_1_2_expansion($activeCtx, $activeProp, $item, fromMap => $fromMap); # 5.2.1
1560 0 ▶ println "5.2.1 expanded item = " . Dumper($expandedItem) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1561
1562 # NOTE: 5.2.2 "container mapping" is in the term definition for active property, right? The text omits the term definition reference.
1563 0 my $container_mapping = $tdef->{'container_mapping'};
1564 # if (any { $_ eq '@list'} @$container_mapping and ref($expandedItem) eq 'ARRAY') {
1565 0 ▶ if ($self->_cm_contains($container_mapping, '@list') and ref($expandedItem) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_cm_contains($container_mapping, "\@list") and ref $expandedItem eq "ARRAY") 0 0 0
Condition0%0/3
$self->_cm_contains($container_mapping, "\@list") and ref $expandedItem eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_cm_contains($container_mapping, "\@list") and ref $expandedItem eq "ARRAY"
$self->_cm_contains($container_mapping, "\@list") ref $expandedItem eq "ARRAY"
Truth table0%0/3
A and B
A= $self->_cm_contains($container_mapping, "\@list")B= ref $expandedItem eq "ARRAY"
ABresult
0X0
100
111
1566 0 ▶ println "5.2.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1567 0 $expandedItem = { '@list' => $expandedItem }; # 5.2.2
1568 }
1569
1570 # 5.2.3
1571 0 ▶ println "5.2.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1572 0 ▶ if (ref($expandedItem) eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $expandedItem eq 'ARRAY') { } 0 0 0
elsif (defined $expandedItem) { } 0 0 0
1573 0 push(@result, @$expandedItem);
1574 } elsif (defined($expandedItem)) {
1575 0 push(@result, $expandedItem);
1576 }
1577 }
1578
1579 0 local($Data::Dumper::Indent) = 1;
1580 0 ▶ println "5.3 returning from _5_1_2_expansion with " . Data::Dumper->Dump([\@result], ['expanded_array_value']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1581 0 return \@result; # 5.3
1582 }
1583
1584 1 ▶ unless (ref($element) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $element eq "HASH") 0 1 1
1585 0 ▶ println "6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1586 0 die "Unexpected non-map encountered during expansion: $element";
1587 }
1588  
1589 1 ▶ if (my $prevCtx = $activeCtx->{'previous_context'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $prevCtx = $activeCtx->{"previous_context"}) 0 1 1
1590 0 ▶ unless ($fromMap) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($fromMap) 0 0 0
1591 0 my @keys = keys %$element;
1592 0 my %expandedKeys = map { $_ => 1 } map { $self->_5_2_2_iri_expansion($activeCtx, $_, vocab => 1) } @keys;
1593 0 ▶ unless (exists $expandedKeys{'@value'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $expandedKeys{"\@value"}) 0 0 0
1594 0 ▶ unless (scalar(@keys) == 1 and $self->_5_2_2_iri_expansion($activeCtx, $keys[0], vocab => 1) eq '@id') {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar @keys == 1 and $self->_5_2_2_iri_expansion($activeCtx, $keys[0], "vocab", 1) eq "\@id") 0 0 0
Condition0%0/3
scalar @keys == 1 and $self->_5_2_2_iri_expansion($activeCtx, $keys[0], "vocab", 1) eq "\@id"
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @keys == 1 and $self->_5_2_2_iri_expansion($activeCtx, $keys[0], "vocab", 1) eq "\@id"
scalar @keys == 1 $self->_5_2_2_iri_expansion($activeCtx, $keys[0], "vocab", 1) eq "\@id"
Truth table0%0/3
A and B
A= scalar @keys == 1B= $self->_5_2_2_iri_expansion($activeCtx, $keys[0], "vocab", 1) eq "\@id"
ABresult
0X0
100
111
1595 0 ▶ println "7" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1596 0 $activeCtx = $prevCtx; # 7
1597 }
1598 }
1599 }
1600 }
1601
1602 1 ▶ if ($property_scoped_ctx_defined) {
Branch: 1 branch
BranchTrueFalseTotal
if ($property_scoped_ctx_defined) 0 1 1
1603 0 ▶ println "8" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1604 0 my %args;
1605 0 ▶ if ($tdef and exists $tdef->{'__source_base_iri'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tdef and exists $tdef->{"__source_base_iri"}) 0 0 0
Condition0%0/3
$tdef and exists $tdef->{"__source_base_iri"}
!ll&&!rl&&r
000
MC/DC0%0/2
$tdef and exists $tdef->{"__source_base_iri"}
$tdef exists $tdef->{"__source_base_iri"}
Truth table0%0/3
A and B
A= $tdefB= exists $tdef->{"__source_base_iri"}
ABresult
0X0
100
111
1606 0 $args{base_iri} = $tdef->{'__source_base_iri'};
1607 }
1608 0 local($Data::Dumper::Indent) = 1;
1609 0 ▶ println "before 8: " . Data::Dumper->Dump([$activeCtx, $property_scoped_ctx], [qw'activeCtx property_scoped_ctx']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1610 0 $activeCtx = $self->_4_1_2_ctx_processing($activeCtx, $property_scoped_ctx, %args, override_protected => 1); # 8
1611 0 ▶ println "after 8: " . Data::Dumper->Dump([$activeCtx], ['activeCtx']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1612 }
1613
1614 1 ▶ if (exists $element->{'@context'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $element->{"\@context"}) 1 0 1
1615 1 ▶ println "9" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1616 1 my $c = $element->{'@context'};
1617 1 $activeCtx = $self->_4_1_2_ctx_processing($activeCtx, $c); # 9
1618 }
1619
1620 1 ▶ println "10" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1621 1 my $type_scoped_ctx = clone($activeCtx); # 10
1622
1623 1 ▶ println "11" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1624 1 foreach my $key (sort keys %$element) {
1625 2 my $__indent = indent();
1626 2 my $value = $element->{$key};
1627 # 11
1628 2 ▶ println "11 [$key]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 2 2
1629 {
1630 2 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
1631 2 ▶ unless ('@type' eq $self->_5_2_2_iri_expansion($activeCtx, $key, vocab => 1)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("\@type" eq $self->_5_2_2_iri_expansion($activeCtx, $key, "vocab", 1)) 2 0 2
1632 2 ▶ println "[skipping key $key in search of \@type]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 2 2
1633 2 next;
1634 }
1635 }
1636  
1637 2 ▶ println "11 body [$key]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 2 2
1638
1639 2 ▶ unless (ref($value) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $value eq "ARRAY") 2 0 2
1640 2 ▶ println "11.1 [$key]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 2 2
1641 2 $value = [$value]; # 11.1
1642 }
1643
1644 2 my %tdefs = map { $_ => $self->_ctx_term_defn($type_scoped_ctx, $_) } grep { _is_string($_) } @$value; # https://github.com/w3c/json-ld-api/issues/304
1645
1646 # the clone here is necessary, because the implicit lexicographic sort will add the POK flag to integer scalars that would otherwise be just IOK. this causes the resulting JSON serialization to treat the scalar as a string.
1647 2 foreach my $term (sort @{clone($value)}) {
1648 2 ▶ println "11.2 attempting with [$term]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 2 2
1649 2 ▶ if (_is_string($term)) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_string($term)) 1 1 2
1650 1 my $tdef = $tdefs{$term};
1651 1 ▶ if (exists $tdef->{'@context'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $tdef->{"\@context"}) 0 1 1
1652 0 ▶ println "11.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1653 0 my $c = $tdef->{'@context'};
1654 0 $activeCtx = $self->_4_1_2_ctx_processing($activeCtx, $c, propagate => 0);
1655 0 local($Data::Dumper::Indent) = 1;
1656 0 ▶ println "11.2 " . Data::Dumper->Dump([$activeCtx], ['activeCtx']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1657 }
1658 }
1659 }
1660
1661 }
1662 1 ▶ println "After 11, " . Data::Dumper->Dump([$element], ['element']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1663
1664 1 ▶ println "12" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1665 1 my $result = {}; # 12a
1666 1 my $nests = {}; # 12b
1667 1 my $input_type = '';
1668 1 foreach my $key (sort keys %$element) {
1669 2 my $expandedKey = $self->_5_2_2_iri_expansion($activeCtx, $key);
1670 2 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
1671 2 ▶ if ($expandedKey eq '@type') {
Branch: 1 branch
BranchTrueFalseTotal
if ($expandedKey eq "\@type") 0 2 2
1672 0 $input_type = $self->_5_2_2_iri_expansion($activeCtx, $element->{$key});
1673 0 last;
1674 }
1675 }
1676 1 ▶ println "12 " . Data::Dumper->Dump([$input_type], ['*input_type']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1677
1678 1 $self->_5_1_2_expansion_step_13($activeCtx, $type_scoped_ctx, $result, $activeProp, $input_type, $nests, $ordered, $frameExpansion, $element);
1679 1 ▶ println "after 13,14: " . Data::Dumper->Dump([$result], ['*result']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1680  
1681 1 ▶ if (exists $result->{'@value'}) {
Branch: 3 branches
BranchTrueFalseTotal
if (exists $result->{'@value'}) { } 0 1 1
elsif (exists $result->{'@type'} and ref $result->{'@type'} ne 'ARRAY') { } 0 1 1
elsif (exists $result->{'@set'} or exists $result->{'@list'}) { } 0 1 1
1682 # 15
1683 0 ▶ println "15" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1684 0 my @keys = keys %$result;
1685 0 my %acceptable = map { $_ => 1 } qw(@direction @index @language @type @value);
1686 0 foreach my $k (@keys) {
1687 0 ▶ unless ($acceptable{$k}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($acceptable{$k}) 0 0 0
1688 0 ▶ println "15.1 [$k]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1689 0 die 'invalid value object' ; # 15.1
1690 }
1691 }
1692 0 ▶ if (exists $result->{'@language'} or exists $result->{'@direction'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $result->{"\@language"} or exists $result->{"\@direction"}) 0 0 0
Condition0%0/3
exists $result->{"\@language"} or exists $result->{"\@direction"}
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $result->{"\@language"} or exists $result->{"\@direction"}
exists $result->{"\@language"} exists $result->{"\@direction"}
Truth table0%0/3
A or B
A= exists $result->{"\@language"}B= exists $result->{"\@direction"}
ABresult
1X1
011
000
1693 0 ▶ println "15.1 \@language handling" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1694 0 ▶ die 'invalid value object' if (exists $result->{'@type'}); # 15.1
Branch: 1 branch
BranchTrueFalseTotal
if exists $result->{"\@type"} 0 0 0
1695 }
1696
1697 # if (not(defined($result->{'@value'}))) {
1698 0 ▶ if (defined($result->{'@type'}) and $result->{'@type'} eq '@json') {
Branch: 4 branches
BranchTrueFalseTotal
if (defined $result->{'@type'} and $result->{'@type'} eq '@json') { } 0 0 0
elsif (not defined $result->{'@value'} or ref $result->{'@value'} eq 'ARRAY' and not scalar @{$result->{'@value'};}) { } 0 0 0
elsif (ref $result->{'@value'} and exists $result->{'@language'}) { } 0 0 0
elsif (exists $result->{'@type'} and not $self->_is_iri($result->{'@type'})) { } 0 0 0
Condition0%0/3
defined $result->{"\@type"} and $result->{"\@type"} eq "\@json"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $result->{"\@type"} and $result->{"\@type"} eq "\@json"
defined $result->{"\@type"} $result->{"\@type"} eq "\@json"
Truth table0%0/3
A and B
A= defined $result->{"\@type"}B= $result->{"\@type"} eq "\@json"
ABresult
0X0
100
111
1699 0 ▶ println "15.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1700 # TODO: treat $result->{'@value'} as a JSON literal
1701 0 ▶ } elsif (not(defined($result->{'@value'})) or (ref($result->{'@value'}) eq 'ARRAY' and not scalar(@{$result->{'@value'}}))) { # based on irc conversation with gkellog
Condition0%0/6
not defined $result->{"\@value"} or ref $result->{"\@value"} eq "ARRAY" and not scalar @{$result->{"\@value"};}
l!l&&r!l&&!r
000
ref $result->{"\@value"} eq "ARRAY" and not scalar @{$result->{"\@value"};}
!ll&&!rl&&r
000
MC/DC0%0/3
not defined $result->{"\@value"} or ref $result->{"\@value"} eq "ARRAY" and not scalar @{$result->{"\@value"};}
not defined $result->{"\@value"} ref $result->{"\@value"} eq "ARRAY" not scalar @{$result->{"\@value"};}
Truth table0%0/4
not(A) or B and not(C)
A= not defined $result->{"\@value"}B= ref $result->{"\@value"} eq "ARRAY"C= not scalar @{$result->{"\@value"};}
ABCresult
1XX1
0111
00X0
0100
1702 0 ▶ println "15.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1703 0 return undef;
1704 ▶ } elsif (ref($result->{'@value'}) and exists $result->{'@language'}) {
Condition0%0/3
ref $result->{"\@value"} and exists $result->{"\@language"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $result->{"\@value"} and exists $result->{"\@language"}
ref $result->{"\@value"} exists $result->{"\@language"}
Truth table0%0/3
A and B
A= ref $result->{"\@value"}B= exists $result->{"\@language"}
ABresult
0X0
100
111
1705 0 ▶ println "15.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1706 0 die 'invalid language-tagged value; ' . Dumper($result); # 15.4
1707 ▶ } elsif (exists $result->{'@type'} and not($self->_is_iri($result->{'@type'}))) {
Condition0%0/3
exists $result->{"\@type"} and not $self->_is_iri($result->{"\@type"})
!ll&&!rl&&r
000
MC/DC0%0/2
exists $result->{"\@type"} and not $self->_is_iri($result->{"\@type"})
exists $result->{"\@type"} not $self->_is_iri($result->{"\@type"})
Truth table0%0/3
A and not(B)
A= exists $result->{"\@type"}B= not $self->_is_iri($result->{"\@type"})
ABresult
0X0
100
111
1708 0 println "Not an IRI \@type: " . Dumper($result->{'@type'});
1709 0 ▶ println "15.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1710 0 die 'invalid typed value: ' . Dumper($result); # 15.5
1711 # } elsif (exists $result->{'@type'}) {
1712 # my $types = $result->{'@type'};
1713 # my @types = (ref($types) eq 'ARRAY') ? @$types : $types;
1714 # foreach my $t (@types) {
1715 # unless ($self->_is_iri($t)) {
1716 # warn "Not an IRI \@type: " . Dumper($result->{'@type'});
1717 # println "15.5" if $debug;
1718 # die 'invalid typed value: ' . Dumper($result); # 15.5
1719 # }
1720 # }
1721 }
1722 0 ▶ println "15 resulting in " . Data::Dumper->Dump([$result], ['*result']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1723 ▶ } elsif (exists $result->{'@type'} and ref($result->{'@type'}) ne 'ARRAY') {
Condition33%1/3
exists $result->{"\@type"} and ref $result->{"\@type"} ne "ARRAY"
!ll&&!rl&&r
100
MC/DC0%0/2
exists $result->{"\@type"} and ref $result->{"\@type"} ne "ARRAY"
exists $result->{"\@type"} ref $result->{"\@type"} ne "ARRAY"
Truth table33%1/3
A and B
A= exists $result->{"\@type"}B= ref $result->{"\@type"} ne "ARRAY"
ABresult
0X0
100
111
1724 0 ▶ println "16" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1725 0 $result->{'@type'} = [$result->{'@type'}]; # 16
1726 0 ▶ println "16 resulting in " . Data::Dumper->Dump([$result], ['*result']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1727 ▶ } elsif (exists $result->{'@set'} or exists $result->{'@list'}) {
Condition33%1/3
exists $result->{"\@set"} or exists $result->{"\@list"}
l!l&&r!l&&!r
001
MC/DC0%0/2
exists $result->{"\@set"} or exists $result->{"\@list"}
exists $result->{"\@set"} exists $result->{"\@list"}
Truth table33%1/3
A or B
A= exists $result->{"\@set"}B= exists $result->{"\@list"}
ABresult
1X1
011
000
1728 # 17
1729 0 ▶ println "17" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1730 0 ▶ my @keys = grep { $_ ne '@set' and $_ ne '@list' } keys %$result;
Condition0%0/3
$_ ne '@set' && $_ ne '@list'
!ll&&!rl&&r
000
MC/DC0%0/2
$_ ne '@set' && $_ ne '@list'
$_ ne '@set' $_ ne '@list'
Truth table0%0/3
A && B
A= $_ ne '@set'B= $_ ne '@list'
ABresult
0X0
100
111
1731 0 ▶ if (scalar(@keys)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @keys) 0 0 0
1732 0 ▶ println "17.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1733 0 ▶ die 'invalid set or list object' unless (scalar(@keys) == 1 and $keys[0] eq '@index'); # 17.1
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @keys == 1 and $keys[0] eq "\@index" 0 0 0
Condition0%0/3
scalar @keys == 1 and $keys[0] eq "\@index"
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @keys == 1 and $keys[0] eq "\@index"
scalar @keys == 1 $keys[0] eq "\@index"
Truth table0%0/3
A and B
A= scalar @keys == 1B= $keys[0] eq "\@index"
ABresult
0X0
100
111
1734 }
1735 0 ▶ if (exists $result->{'@set'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $result->{"\@set"}) 0 0 0
1736 0 ▶ println "17.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1737 0 $result = $result->{'@set'}; # 17.2
1738 }
1739 0 ▶ println "17 resulting in " . Data::Dumper->Dump([$result], ['*result']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1740 }
1741
1742 1 ▶ println "after 17 resulting in " . Data::Dumper->Dump([$result], ['*result']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1743 1 ▶ my @keys = (ref($result) eq 'HASH') ? keys %$result : ();
Branch: 1 branch
BranchTrueFalseTotal
ref $result eq 'HASH' ? : 1 0 1
1744 1 ▶ if (ref($result) eq 'HASH') { # NOTE: assuming based on the effects of 16.2 that this condition is necessary to guard against cases where $result is not a hashref.
Branch: 1 branch
BranchTrueFalseTotal
if (ref $result eq "HASH") 1 0 1
1745 1 ▶ if (scalar(@keys) == 1 and $keys[0] eq '@language') {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @keys == 1 and $keys[0] eq "\@language") 0 1 1
Condition33%1/3
scalar @keys == 1 and $keys[0] eq "\@language"
!ll&&!rl&&r
010
MC/DC0%0/2
scalar @keys == 1 and $keys[0] eq "\@language"
scalar @keys == 1 $keys[0] eq "\@language"
Truth table33%1/3
A and B
A= scalar @keys == 1B= $keys[0] eq "\@language"
ABresult
0X0
100
111
1746 0 ▶ println "18" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1747 0 return undef;
1748 }
1749
1750 1 ▶ println(Data::Dumper->Dump([$activeProp], ['activeProp'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1751 1 ▶ if (not(defined($activeProp)) or $activeProp eq '@graph') {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $activeProp or $activeProp eq "\@graph") 1 0 1
Condition33%1/3
not defined $activeProp or $activeProp eq "\@graph"
l!l&&r!l&&!r
100
MC/DC0%0/2
not defined $activeProp or $activeProp eq "\@graph"
not defined $activeProp $activeProp eq "\@graph"
Truth table33%1/3
not(A) or B
A= not defined $activePropB= $activeProp eq "\@graph"
ABresult
1X1
011
000
1752 # 19
1753 1 local($Data::Dumper::Indent) = 0;
1754 1 ▶ println "19 " . Data::Dumper->Dump([$result, \@keys], ['*result', '*keys']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1755 1 ▶ if (ref($result) eq 'HASH' and (scalar(@keys) == 0 or exists $result->{'@value'} or exists $result->{'@list'})) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $result eq 'HASH' and scalar @keys == 0 || exists $result->{'@value'} || exists $result->{'@list'}) { } 0 1 1
elsif (ref $result eq 'HASH' and scalar @keys == 1 and $keys[0] eq '@id') { } 0 1 1
Condition33%3/9
ref $result eq "HASH" and scalar @keys == 0 || exists $result->{"\@value"} || exists $result->{"\@list"}
!ll&&!rl&&r
010
scalar @keys == 0 or exists $result->{"\@value"} or exists $result->{"\@list"}
l!l&&r!l&&!r
001
scalar @keys == 0 or exists $result->{"\@value"}
l!l&&r!l&&!r
001
MC/DC0%0/4
ref $result eq "HASH" and scalar @keys == 0 || exists $result->{"\@value"} || exists $result->{"\@list"}
ref $result eq "HASH" scalar @keys == 0 exists $result->{"\@value"} exists $result->{"\@list"}
Truth table20%1/5
A and B or C or D
A= ref $result eq "HASH"B= scalar @keys == 0C= exists $result->{"\@value"}D= exists $result->{"\@list"}
ABCDresult
0XXX0
10000
11XX1
101X1
10011
1756 0 ▶ println "19.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1757 0 $result = undef; # 19.1
1758 ▶ } elsif (ref($result) eq 'HASH' and scalar(@keys) == 1 and $keys[0] eq '@id') {
Condition33%2/6
ref $result eq "HASH" and scalar @keys == 1 and $keys[0] eq "\@id"
!ll&&!rl&&r
010
ref $result eq "HASH" and scalar @keys == 1
!ll&&!rl&&r
001
MC/DC0%0/3
ref $result eq "HASH" and scalar @keys == 1 and $keys[0] eq "\@id"
ref $result eq "HASH" scalar @keys == 1 $keys[0] eq "\@id"
Truth table25%1/4
A and B and C
A= ref $result eq "HASH"B= scalar @keys == 1C= $keys[0] eq "\@id"
ABCresult
0XX0
10X0
1100
1111
1759 0 ▶ unless ($frameExpansion) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($frameExpansion) 0 0 0
1760 0 ▶ println "19.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1761 0 $result = undef; # 19.2
1762 }
1763 }
1764 }
1765 1 ▶ println "19 resulting in " . Data::Dumper->Dump([$result], ['*result']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1766 }
1767
1768 1 local($Data::Dumper::Indent) = 1;
1769 1 ▶ println "20 returning from _5_1_2_expansion with final value " . Data::Dumper->Dump([$result], ['*result']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1770 1 return $result; # 19
1771 }
1772
1773 1 ▶ sub _5_1_2_expansion_step_13 {
Subroutine _5_1_2_expansion_step_13: called CC=300 SCAR=111.4
1774 1 my $self = shift;
1775 1 my $activeCtx = shift;
1776 1 my $type_scoped_ctx = shift;
1777 1 my $result = shift;
1778 1 my $activeProp = shift;
1779 1 my $input_type = shift;
1780 1 my $nests = shift;
1781 1 my $ordered = shift;
1782 1 my $frameExpansion = shift;
1783 1 my $element = shift;
1784 1 ▶ println "13 --- processing " . Data::Dumper->Dump([$element], ['element']) if ($debug);
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1785 1 foreach my $key (sort keys %$element) {
1786 2 my $__indent = indent();
1787 2 my $value = $element->{$key};
1788 # 13
1789 2 ▶ println '-----------------------------------------------------------------' if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 2 2
1790 2 ▶ println "13 [$key] " . Data::Dumper->Dump([$value], ['value']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 2 2
1791 2 ▶ if ($key eq '@context') {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "\@context") 1 1 2
1792 1 ▶ println "13.1 going to next element key" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1793 1 next; # 13.1
1794 }
1795 1 local($Data::Dumper::Indent) = 1;
1796 1 ▶ println(Data::Dumper->Dump([$activeCtx], ['activeCtx'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1797
1798 1 ▶ println "13.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1799 1 my $expandedProperty = $self->_5_2_2_iri_expansion($activeCtx, $key, vocab => 1); # 13.2
1800 1 ▶ println "13.2 " . Data::Dumper->Dump([$expandedProperty], ['expandedProperty']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1801 1 ▶ println(Data::Dumper->Dump([$expandedProperty], ['expandedProperty'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
1802 1 ▶ if (not(defined($expandedProperty)) or ($expandedProperty !~ /:/ and not exists $keywords{$expandedProperty})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $expandedProperty and $expandedProperty =~ /:/u || exists $keywords{$expandedProperty}) 0 1 1
Condition33%2/6
defined $expandedProperty and $expandedProperty =~ /:/u || exists $keywords{$expandedProperty}
!ll&&!rl&&r
001
$expandedProperty =~ /:/u or exists $keywords{$expandedProperty}
l!l&&r!l&&!r
100
MC/DC0%0/3
defined $expandedProperty and $expandedProperty =~ /:/u || exists $keywords{$expandedProperty}
defined $expandedProperty $expandedProperty =~ /:/u exists $keywords{$expandedProperty}
Truth table25%1/4
A and B or C
A= defined $expandedPropertyB= $expandedProperty =~ /:/uC= exists $keywords{$expandedProperty}
ABCresult
0XX0
1000
11X1
1011
1803 0 ▶ println "13.3 going to next element key" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1804 0 next; # 13.3
1805 }
1806
1807 1 my $expandedValue;
1808 1 ▶ if (exists $keywords{$expandedProperty}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $keywords{$expandedProperty}) 0 1 1
1809 # 13.4
1810 0 ▶ println "13.4 keyword: $expandedProperty" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1811
1812 0 ▶ if (defined($activeProp) and $activeProp eq '@reverse') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $activeProp and $activeProp eq "\@reverse") 0 0 0
Condition0%0/3
defined $activeProp and $activeProp eq "\@reverse"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $activeProp and $activeProp eq "\@reverse"
defined $activeProp $activeProp eq "\@reverse"
Truth table0%0/3
A and B
A= defined $activePropB= $activeProp eq "\@reverse"
ABresult
0X0
100
111
1813 0 ▶ println "13.4.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1814 0 die 'invalid reverse property map'; # 13.4.1
1815 }
1816  
1817 0 ▶ if (exists $result->{$expandedProperty}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $result->{$expandedProperty}) 0 0 0
1818 0 my $p = $result->{$expandedProperty};
1819 0 ▶ if ($expandedProperty ne '@included' and $expandedProperty ne '@type') {
Branch: 1 branch
BranchTrueFalseTotal
if ($expandedProperty ne "\@included" and $expandedProperty ne "\@type") 0 0 0
Condition0%0/3
$expandedProperty ne "\@included" and $expandedProperty ne "\@type"
!ll&&!rl&&r
000
MC/DC0%0/2
$expandedProperty ne "\@included" and $expandedProperty ne "\@type"
$expandedProperty ne "\@included" $expandedProperty ne "\@type"
Truth table0%0/3
A and B
A= $expandedProperty ne "\@included"B= $expandedProperty ne "\@type"
ABresult
0X0
100
111
1820 0 ▶ println "13.4.2 colliding: $expandedProperty" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1821 0 die 'colliding keywords'; # 13.4.2
1822 }
1823 }
1824
1825 # NOTE: another case of an "Otherwise" applying to a partial conjunction
1826 0 ▶ if ($expandedProperty eq '@id') {
Branch: 1 branch
BranchTrueFalseTotal
if ($expandedProperty eq "\@id") 0 0 0
1827 0 ▶ println "13.4.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1828 0 ▶ if (ref($value) or not defined($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value or not defined $value) { } 0 0 0
Condition0%0/3
ref $value or not defined $value
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $value or not defined $value
ref $value not defined $value
Truth table0%0/3
A or not(B)
A= ref $valueB= not defined $value
ABresult
1X1
011
000
1829 0 ▶ println "13.4.3.1 invalid" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1830 0 die 'invalid @id value';
1831 } else {
1832 0 ▶ println "13.4.3.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1833 0 $expandedValue = $self->_5_2_2_iri_expansion($activeCtx, $value, documentRelative => 1);
1834 0 ▶ println "13.4.3.2 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1835 }
1836 }
1837  
1838 0 ▶ if ($expandedProperty eq '@type') {
Branch: 1 branch
BranchTrueFalseTotal
if ($expandedProperty eq "\@type") 0 0 0
1839 0 ▶ println "13.4.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1840 0 my $is_string = _is_string($value);
1841 0 my $is_array = ref($value) eq 'ARRAY';
1842 0 ▶ my $is_array_of_strings = ($is_array and all { _is_string($_) } @$value);
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$is_array && &all(sub { _is_string($_); } , @$value)
!ll&&!rl&&r
000
MC/DC0%0/2
$is_array && &all(sub { _is_string($_); } , @$value)
$is_array &all(sub { _is_string($_); } , @$value)
Truth table0%0/3
A && B
A= $is_arrayB= &all(sub { _is_string($_); } , @$value)
ABresult
0X0
100
111
1843 0 ▶ if (not($is_string) and not($is_array_of_strings)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($is_string or $is_array_of_strings) 0 0 0
Condition0%0/3
$is_string or $is_array_of_strings
l!l&&r!l&&!r
000
MC/DC0%0/2
$is_string or $is_array_of_strings
$is_string $is_array_of_strings
Truth table0%0/3
A or B
A= $is_stringB= $is_array_of_strings
ABresult
1X1
011
000
1844 0 ▶ println "13.4.4.1 invalid" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1845 0 die 'invalid type value';
1846 }
1847
1848 0 ▶ if (ref($value) eq 'HASH' and scalar(%$value) == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $value eq 'HASH' and scalar %$value == 0) { } 0 0 0
elsif ($self->_is_default_object($value)) { } 0 0 0
Condition0%0/3
ref $value eq "HASH" and scalar %$value == 0
!ll&&!rl&&r
000
MC/DC0%0/2
ref $value eq "HASH" and scalar %$value == 0
ref $value eq "HASH" scalar %$value == 0
Truth table0%0/3
A and B
A= ref $value eq "HASH"B= scalar %$value == 0
ABresult
0X0
100
111
1849 0 ▶ println "13.4.4.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1850 0 $expandedValue = $value;
1851 0 ▶ println "13.4.4.2 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1852 } elsif ($self->_is_default_object($value)) {
1853 0 ▶ println "13.4.4.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1854 0 $expandedValue = { '@default' => $self->_5_2_2_iri_expansion($type_scoped_ctx, $value, vocab => 1, documentRelative => 1) };
1855 0 ▶ println "13.4.4.3 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1856 } else {
1857 0 ▶ println "13.4.4.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1858 0 ▶ if (ref($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value) { } 0 0 0
1859 0 $expandedValue = [map {$self->_5_2_2_iri_expansion($type_scoped_ctx, $_, vocab => 1, documentRelative => 1)} @$value];
1860 } else {
1861 0 $expandedValue = $self->_5_2_2_iri_expansion($type_scoped_ctx, $value, vocab => 1, documentRelative => 1);
1862 }
1863 0 ▶ println "13.4.4.4 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1864 }
1865
1866 0 ▶ if (my $t = $result->{'@type'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $t = $result->{"\@type"}) 0 0 0
1867 0 ▶ println "13.4.4.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1868 0 ▶ if (ref($expandedValue) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $expandedValue ne "ARRAY") 0 0 0
1869 0 $expandedValue = [$expandedValue];
1870 }
1871 0 unshift(@$expandedValue, $t);
1872 0 ▶ println "13.4.4.5 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1873 }
1874 }
1875  
1876 0 ▶ if ($expandedProperty eq '@graph') {
Branch: 1 branch
BranchTrueFalseTotal
if ($expandedProperty eq "\@graph") 0 0 0
1877 0 ▶ println "13.4.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1878 0 my $v = $self->_5_1_2_expansion($activeCtx, '@graph', $value, frameExpansion => $frameExpansion, ordered => $ordered);
1879 0 ▶ $expandedValue = (ref($v) eq 'ARRAY') ? $v : [$v];
Branch: 1 branch
BranchTrueFalseTotal
ref $v eq 'ARRAY' ? : 0 0 0
1880 0 ▶ println("========================================================================") if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1881 0 ▶ println("========================================================================") if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1882 0 ▶ println("========================================================================") if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1883 0 ▶ println(Dumper($expandedValue)) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1884 0 ▶ println "13.4.5 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1885 }
1886  
1887 0 ▶ if ($expandedProperty eq '@included') {
Branch: 2 branches
BranchTrueFalseTotal
if ($expandedProperty eq '@included') { } 0 0 0
elsif ($expandedProperty eq '@value') { } 0 0 0
1888 0 ▶ println "13.4.6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1889 0 ▶ if ($self->processing_mode eq 'json-ld-1.0') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->processing_mode eq "json-ld-1.0") 0 0 0
1890 0 ▶ println "13.4.6.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1891 0 next;
1892 }
1893
1894 0 ▶ println "13.4.6.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1895 0 $expandedValue = $self->_5_1_2_expansion($activeCtx, $activeProp, $value, frameExpansion => $frameExpansion, ordered => $ordered);
1896 0 ▶ unless (ref($expandedValue) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $expandedValue eq "ARRAY") 0 0 0
1897 0 $expandedValue = [$expandedValue];
1898 }
1899
1900 0 foreach my $v (@$expandedValue) {
1901 0 ▶ unless ($self->_is_node_object($v)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_is_node_object($v)) 0 0 0
1902 0 ▶ println "13.4.6.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1903 0 die 'invalid @included value';
1904 }
1905 }
1906
1907 0 ▶ if (exists $result->{'@included'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $result->{"\@included"}) 0 0 0
1908 # https://github.com/w3c/json-ld-api/issues/333
1909 0 ▶ println "13.4.6.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1910 0 unshift(@$expandedValue, @{ $result->{'@included'} });
1911 }
1912 0 ▶ println "13.4.6 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1913 } elsif ($expandedProperty eq '@value') {
1914 0 ▶ println "13.4.7 " . Data::Dumper->Dump([$input_type], ['*input_type']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1915 0 ▶ if ($input_type eq '@json') {
Branch: 2 branches
BranchTrueFalseTotal
if ($input_type eq '@json') { } 0 0 0
elsif (not _is_scalar($value) || !defined($value)) { } 0 0 0
1916 0 ▶ println "13.4.7.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1917 0 $expandedValue = $value; # 13.4.7.1
1918 0 ▶ if ($self->processing_mode eq 'json-ld-1.0') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->processing_mode eq "json-ld-1.0") 0 0 0
1919 0 die 'invalid value object value';
1920 }
1921 ▶ } elsif (not (_is_scalar($value) or not defined($value))) { # "if value is not a scalar or null, an invalid value object value error has been detected"
Condition0%0/3
_is_scalar($value) || !defined($value)
l!l&&r!l&&!r
000
MC/DC0%0/2
_is_scalar($value) || !defined($value)
_is_scalar($value) !defined($value)
Truth table0%0/3
A || not(B)
A= _is_scalar($value)B= !defined($value)
ABresult
1X1
011
000
1922 0 ▶ println "13.4.7.2 " . Data::Dumper->Dump([$value], ['*value']) if $debug; # NOTE: the language here is ambiguous: "if value is not a scalar or null"
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1923 0 die 'invalid value object value';
1924 } else {
1925 0 ▶ println "13.4.7.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1926 0 $expandedValue = $value;
1927 }
1928
1929 0 ▶ unless (defined($expandedValue)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $expandedValue) 0 0 0
1930 0 ▶ println "13.4.7.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1931 0 $result->{'@value'} = undef;
1932 0 next;
1933 }
1934 0 ▶ println "13.4.7 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1935 }
1936  
1937 # NOTE: again with the "Otherwise" that seems to apply to only half the conjunction
1938 0 ▶ if ($expandedProperty eq '@language') {
Branch: 1 branch
BranchTrueFalseTotal
if ($expandedProperty eq "\@language") 0 0 0
1939 0 ▶ println "13.4.8" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1940 0 ▶ if (ref($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value) 0 0 0
1941 0 ▶ println "13.4.8.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1942 0 ▶ if ($frameExpansion) {
Branch: 1 branch
BranchTrueFalseTotal
if ($frameExpansion) 0 0 0
1943 0 println "13.4.8.1 TODO: frameExpansion support"; # if $debug;
1944 }
1945 0 die 'invalid language-tagged string';
1946 }
1947 0 ▶ println "13.4.8.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1948 0 $expandedValue = $value; # 13.4.8.2
1949 # TODO: validate language tag against BCP47
1950 0 ▶ println "13.4.8 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1951 }
1952  
1953 0 ▶ if ($expandedProperty eq '@direction') {
Branch: 1 branch
BranchTrueFalseTotal
if ($expandedProperty eq "\@direction") 0 0 0
1954 0 ▶ println "13.4.9" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1955 0 ▶ if ($self->processing_mode eq 'json-ld-1.0') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->processing_mode eq "json-ld-1.0") 0 0 0
1956 0 ▶ println "13.4.9.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1957 0 next;
1958 }
1959  
1960 0 ▶ if ($value ne 'ltr' and $value ne 'rtl') {
Branch: 1 branch
BranchTrueFalseTotal
if ($value ne "ltr" and $value ne "rtl") 0 0 0
Condition0%0/3
$value ne "ltr" and $value ne "rtl"
!ll&&!rl&&r
000
MC/DC0%0/2
$value ne "ltr" and $value ne "rtl"
$value ne "ltr" $value ne "rtl"
Truth table0%0/3
A and B
A= $value ne "ltr"B= $value ne "rtl"
ABresult
0X0
100
111
1961 0 ▶ println "13.4.9.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1962 0 die 'invalid base direction';
1963 }
1964  
1965 0 ▶ println "13.4.9.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1966 0 $expandedValue = $value;
1967  
1968 0 ▶ if ($frameExpansion) {
Branch: 1 branch
BranchTrueFalseTotal
if ($frameExpansion) 0 0 0
1969 0 println "13.4.9.4 TODO: frameExpansion support"; # if $debug;
1970 }
1971 0 ▶ println "13.4.9 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1972 }
1973  
1974 0 ▶ if ($expandedProperty eq '@index') {
Branch: 1 branch
BranchTrueFalseTotal
if ($expandedProperty eq "\@index") 0 0 0
1975 0 ▶ println "13.4.10" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1976 0 ▶ if (ref($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value) 0 0 0
1977 0 ▶ println "13.4.10.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1978 0 die 'invalid @index value';
1979 }
1980
1981 0 ▶ println "13.4.10.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1982 0 $expandedValue = $value;
1983 0 ▶ println "13.4.10 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1984 }
1985  
1986 0 ▶ if ($expandedProperty eq '@list') {
Branch: 1 branch
BranchTrueFalseTotal
if ($expandedProperty eq "\@list") 0 0 0
1987 0 ▶ println "13.4.11" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1988 0 ▶ if (not defined($activeProp) or $activeProp eq '@graph') {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $activeProp or $activeProp eq "\@graph") 0 0 0
Condition0%0/3
not defined $activeProp or $activeProp eq "\@graph"
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $activeProp or $activeProp eq "\@graph"
not defined $activeProp $activeProp eq "\@graph"
Truth table0%0/3
not(A) or B
A= not defined $activePropB= $activeProp eq "\@graph"
ABresult
1X1
011
000
1989 0 ▶ println "13.4.11.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1990 0 next;
1991 }
1992  
1993 0 ▶ println "13.4.11.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
1994 0 $expandedValue = $self->_5_1_2_expansion($activeCtx, $activeProp, $value, frameExpansion => $frameExpansion, ordered => $ordered);
1995 0 ▶ if (ref($expandedValue) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $expandedValue ne "ARRAY") 0 0 0
1996 # https://github.com/w3c/json-ld-api/issues/310
1997 0 $expandedValue = [$expandedValue];
1998 }
1999 0 ▶ println "13.4.11 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2000 }
2001  
2002 0 ▶ if ($expandedProperty eq '@set') {
Branch: 1 branch
BranchTrueFalseTotal
if ($expandedProperty eq "\@set") 0 0 0
2003 0 ▶ println "13.4.12" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2004 0 $expandedValue = $self->_5_1_2_expansion($activeCtx, $activeProp, $value, frameExpansion => $frameExpansion, ordered => $ordered);
2005 0 ▶ println "13.4.12 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2006 }
2007  
2008 # NOTE: the language here is really confusing. the first conditional in 13.4.13 is the conjunction "expanded property is @reverse and value is not a map".
2009 # however, by context it seems that really everything under 13.4.13 assumes expanded property is @reverse, and the first branch is dependent only on 'value is not a map'.
2010 0 ▶ if ($expandedProperty eq '@reverse') {
Branch: 1 branch
BranchTrueFalseTotal
if ($expandedProperty eq "\@reverse") 0 0 0
2011 0 ▶ println "13.4.13" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2012 0 ▶ if (ref($value) ne 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value ne "HASH") 0 0 0
2013 0 ▶ println "13.4.13.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2014 0 die 'invalid @reverse value';
2015 }
2016  
2017 0 ▶ println "13.4.13.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2018 0 $expandedValue = $self->_5_1_2_expansion($activeCtx, '@reverse', $value, frameExpansion => $frameExpansion, ordered => $ordered); # 13.4.13.1
2019 0 ▶ println "13.4.13.2 " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2020
2021 0 ▶ if (ref($expandedValue) eq 'HASH' and exists $expandedValue->{'@reverse'}) { # NOTE: spec text does not assert that expandedValue is a map
Branch: 1 branch
BranchTrueFalseTotal
if (ref $expandedValue eq "HASH" and exists $expandedValue->{"\@reverse"}) 0 0 0
Condition0%0/3
ref $expandedValue eq "HASH" and exists $expandedValue->{"\@reverse"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $expandedValue eq "HASH" and exists $expandedValue->{"\@reverse"}
ref $expandedValue eq "HASH" exists $expandedValue->{"\@reverse"}
Truth table0%0/3
A and B
A= ref $expandedValue eq "HASH"B= exists $expandedValue->{"\@reverse"}
ABresult
0X0
100
111
2022 0 ▶ println "13.4.13.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2023 0 foreach my $property (keys %{ $expandedValue->{'@reverse'} }) {
2024 0 my $__indent = indent();
2025 0 ▶ println "13.4.13.3 [$property]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2026 0 my $item = $expandedValue->{'@reverse'}{$property};
2027 0 ▶ if (not exists $result->{$property}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $result->{$property}) 0 0 0
2028 0 ▶ println "13.4.13.3.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2029 0 $result->{$property} = [];
2030 }
2031
2032 0 ▶ println "13.4.13.3.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2033 0 push(@{ $result->{$property} }, @$item);
2034 }
2035 }
2036
2037 0 ▶ if (ref($expandedValue) eq 'HASH') { # NOTE: spec text does not assert that expandedValue is a map
Branch: 1 branch
BranchTrueFalseTotal
if (ref $expandedValue eq "HASH") 0 0 0
2038 0 my @keys = grep { $_ ne '@reverse' } keys %$expandedValue;
2039 0 ▶ if (scalar(@keys)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @keys) 0 0 0
2040 0 ▶ println "13.4.13.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2041
2042 0 ▶ if (not exists $result->{'@reverse'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $result->{"\@reverse"}) 0 0 0
2043 0 ▶ println "13.4.13.4.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2044 0 $result->{'@reverse'} = {};
2045 }
2046
2047 0 ▶ println "13.4.13.4.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2048 0 my $reverse_map = $result->{'@reverse'};
2049
2050 0 ▶ println "13.4.13.4.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2051 0 foreach my $property (grep { $_ ne '@reverse' } keys %{ $expandedValue }) {
2052 0 my $__indent = indent();
2053 0 ▶ println "13.4.13.4.3 [$property]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2054 0 my $items = $expandedValue->{$property};
2055
2056 0 ▶ println "13.4.13.4.3.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2057 0 foreach my $item (@$items) {
2058 0 my $__indent = indent();
2059 0 ▶ if ($self->_is_value_object($item) or $self->_is_list_object($item)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_value_object($item) or $self->_is_list_object($item)) 0 0 0
Condition0%0/3
$self->_is_value_object($item) or $self->_is_list_object($item)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->_is_value_object($item) or $self->_is_list_object($item)
$self->_is_value_object($item) $self->_is_list_object($item)
Truth table0%0/3
A or B
A= $self->_is_value_object($item)B= $self->_is_list_object($item)
ABresult
1X1
011
000
2060 0 ▶ println "13.4.13.4.3.1.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2061 0 die 'invalid reverse property value';
2062 }
2063
2064 0 ▶ if (not exists $reverse_map->{$property}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $reverse_map->{$property}) 0 0 0
2065 0 ▶ println "13.4.13.4.3.1.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2066 0 $reverse_map->{$property} = [];
2067 }
2068
2069 0 ▶ println "13.4.13.4.3.1.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2070 0 push(@{ $reverse_map->{$property} }, $item);
2071 }
2072 }
2073 }
2074 }
2075 0 ▶ println "13.4.13.5 going to next element key" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2076 0 next; # 13.4.13.5
2077 }
2078  
2079 0 ▶ if ($expandedProperty eq '@nest') {
Branch: 1 branch
BranchTrueFalseTotal
if ($expandedProperty eq "\@nest") 0 0 0
2080 0 ▶ println "13.4.14 adding '$key' to nests" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2081 0 ▶ $nests->{$key} //= [];
Condition0%0/2
$nests->{$key} //= []
l!l
00
MC/DC0%0/1
$nests->{$key} //= []
$nests->{$key}
Truth table0%0/2
A
A= $nests->{$key}
Aresult
11
00
2082 0 next;
2083 }
2084  
2085 0 ▶ if ($frameExpansion) {
Branch: 1 branch
BranchTrueFalseTotal
if ($frameExpansion) 0 0 0
2086 0 my %other_framings = map { $_ => 1 } qw(@explicit @default @embed @explicit @omitDefault @requireAll);
2087 0 ▶ if ($other_framings{$expandedProperty}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($other_framings{$expandedProperty}) 0 0 0
2088 0 ▶ println "13.4.15" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2089 0 $expandedValue = $self->_5_1_2_expansion($activeCtx, $activeProp, $value, frameExpansion => $frameExpansion, ordered => $ordered); # 13.4.15
2090 0 ▶ println "13.4.15 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2091 }
2092 }
2093
2094 0 ▶ println "before 13.4.16 " . Data::Dumper->Dump([$expandedValue, $expandedProperty, $input_type], [qw'expandedValue expandedProperty input_type']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2095 0 ▶ unless (not(defined($expandedValue)) and $expandedProperty eq '@value' and $input_type ne '@json') {
Branch: 1 branch
BranchTrueFalseTotal
unless (not defined $expandedValue and $expandedProperty eq "\@value" and $input_type ne "\@json") 0 0 0
Condition0%0/6
not defined $expandedValue and $expandedProperty eq "\@value" and $input_type ne "\@json"
!ll&&!rl&&r
000
not defined $expandedValue and $expandedProperty eq "\@value"
!ll&&!rl&&r
000
MC/DC0%0/3
not defined $expandedValue and $expandedProperty eq "\@value" and $input_type ne "\@json"
not defined $expandedValue $expandedProperty eq "\@value" $input_type ne "\@json"
Truth table0%0/4
not(A) and B and C
A= not defined $expandedValueB= $expandedProperty eq "\@value"C= $input_type ne "\@json"
ABCresult
0XX0
10X0
1100
1111
2096 0 ▶ println "13.4.16 setting " . Data::Dumper->Dump([$expandedValue], [$expandedProperty]) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2097 # println "$expandedProperty expanded value is " . Dumper($expandedValue) if $debug;
2098 0 $result->{$expandedProperty} = $expandedValue; # https://github.com/w3c/json-ld-api/issues/270
2099 0 ▶ println "13.4.16 resulting in " . Data::Dumper->Dump([$result], ['*result']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2100 }
2101  
2102 0 ▶ println "13.4.17 going to next element key" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2103 0 next; # 13.4.17
2104 }
2105  
2106  
2107 1 my $tdef = $self->_ctx_term_defn($activeCtx, $key);
2108  
2109 1 ▶ println "13.5 initializing container mapping" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2110 1 my $container_mapping = $tdef->{'container_mapping'}; # 13.5
2111 1 ▶ println(Data::Dumper->Dump([$container_mapping, $value], ['*container_mapping', '*value'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2112  
2113 1 ▶ if (exists($tdef->{'type_mapping'}) and $tdef->{'type_mapping'} eq '@json') {
Branch: 3 branches
BranchTrueFalseTotal
if (exists $tdef->{'type_mapping'} and $tdef->{'type_mapping'} eq '@json') { } 0 1 1
elsif ($self->_cm_contains($container_mapping, '@language') and ref $value eq 'HASH') { } 0 1 1
elsif ($self->_cm_contains_any($container_mapping, '@index', '@type', '@id') and ref $value eq 'HASH') { } 0 1 1
Condition33%1/3
exists $tdef->{"type_mapping"} and $tdef->{"type_mapping"} eq "\@json"
!ll&&!rl&&r
100
MC/DC0%0/2
exists $tdef->{"type_mapping"} and $tdef->{"type_mapping"} eq "\@json"
exists $tdef->{"type_mapping"} $tdef->{"type_mapping"} eq "\@json"
Truth table33%1/3
A and B
A= exists $tdef->{"type_mapping"}B= $tdef->{"type_mapping"} eq "\@json"
ABresult
0X0
100
111
2114 0 ▶ println "13.6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2115 0 $expandedValue = { '@value' => $value, '@type' => '@json' }; # 13.6
2116 0 ▶ println "13.6 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2117 ▶ } elsif ($self->_cm_contains($container_mapping, '@language') and ref($value) eq 'HASH') {
Condition33%1/3
$self->_cm_contains($container_mapping, "\@language") and ref $value eq "HASH"
!ll&&!rl&&r
100
MC/DC0%0/2
$self->_cm_contains($container_mapping, "\@language") and ref $value eq "HASH"
$self->_cm_contains($container_mapping, "\@language") ref $value eq "HASH"
Truth table33%1/3
A and B
A= $self->_cm_contains($container_mapping, "\@language")B= ref $value eq "HASH"
ABresult
0X0
100
111
2118 0 ▶ println "13.7" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2119 0 ▶ println "13.7.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2120 0 $expandedValue = [];
2121
2122 0 ▶ println "13.7.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2123 0 my $direction = $activeCtx->{'@direction'};
2124
2125 0 ▶ if (exists $tdef->{'direction_mapping'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $tdef->{"direction_mapping"}) 0 0 0
2126 0 ▶ println "13.7.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2127 0 $direction = $tdef->{'direction_mapping'};
2128 }
2129
2130 0 ▶ println "13.7.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2131 0 for my $language (sort keys %$value) {
2132 0 my $__indent = indent();
2133 0 my $language_value = $value->{$language};
2134 0 ▶ println "13.7.4 [$language]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2135
2136 0 ▶ if (ref($language_value) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $language_value ne "ARRAY") 0 0 0
2137 0 ▶ println "13.7.4.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2138 0 $language_value = [$language_value];
2139 }
2140
2141 0 ▶ println "13.7.4.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2142 0 foreach my $item (@$language_value) {
2143 0 my $__indent = indent();
2144 0 ▶ unless (defined($item)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $item) 0 0 0
2145 0 ▶ println "13.7.4.2.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2146 0 next;
2147 }
2148
2149 0 ▶ if (ref($item)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $item) 0 0 0
2150 0 ▶ println "13.7.4.2.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2151 0 die 'invalid language map value';
2152 }
2153
2154 0 ▶ println "13.7.4.2.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2155 0 my $v = {'@value' => $item, '@language' => $language};
2156 0 my $well_formed = 1; # TODO: check BCP47 well-formedness of $item
2157 0 ▶ if ($item ne '@none' and not($well_formed)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item ne "\@none" and not $well_formed) 0 0 0
Condition0%0/3
$item ne "\@none" and not $well_formed
!ll&&!rl&&r
000
MC/DC0%0/2
$item ne "\@none" and not $well_formed
$item ne "\@none" not $well_formed
Truth table0%0/3
A and not(B)
A= $item ne "\@none"B= not $well_formed
ABresult
0X0
100
111
2158 0 warn "Language tag is not well-formed: $item";
2159 }
2160 # TODO: normalize language tag
2161
2162 0 my $expandedLanguage = $self->_5_2_2_iri_expansion($activeCtx, $language);
2163 0 ▶ if ($language eq '@none' or $expandedLanguage eq '@none') {
Branch: 1 branch
BranchTrueFalseTotal
if ($language eq "\@none" or $expandedLanguage eq "\@none") 0 0 0
Condition0%0/3
$language eq "\@none" or $expandedLanguage eq "\@none"
l!l&&r!l&&!r
000
MC/DC0%0/2
$language eq "\@none" or $expandedLanguage eq "\@none"
$language eq "\@none" $expandedLanguage eq "\@none"
Truth table0%0/3
A or B
A= $language eq "\@none"B= $expandedLanguage eq "\@none"
ABresult
1X1
011
000
2164 0 ▶ println "13.7.4.2.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2165 0 delete $v->{'@language'};
2166 }
2167
2168 0 ▶ if (defined($direction)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $direction) 0 0 0
2169 0 ▶ println "13.7.4.2.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2170 0 $v->{'@direction'} = $direction;
2171 }
2172
2173 0 ▶ println "13.7.4.2.6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2174 0 push(@$expandedValue, $v);
2175 }
2176 }
2177 0 ▶ println "13.7 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2178 # } elsif ((exists $container_mapping->{'@index'} or exists $container_mapping->{'@type'} or exists $container_mapping->{'@id'}) and ref($value) eq 'HASH') {
2179 ▶ } elsif ($self->_cm_contains_any($container_mapping, '@index', '@type', '@id') and ref($value) eq 'HASH') {
Condition33%1/3
$self->_cm_contains_any($container_mapping, "\@index", "\@type", "\@id") and ref $value eq "HASH"
!ll&&!rl&&r
100
MC/DC0%0/2
$self->_cm_contains_any($container_mapping, "\@index", "\@type", "\@id") and ref $value eq "HASH"
$self->_cm_contains_any($container_mapping, "\@index", "\@type", "\@id") ref $value eq "HASH"
Truth table33%1/3
A and B
A= $self->_cm_contains_any($container_mapping, "\@index", "\@type", "\@id")B= ref $value eq "HASH"
ABresult
0X0
100
111
2180 0 ▶ println "13.8" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2181 0 ▶ println "13.8.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2182 0 $expandedValue = [];
2183
2184 0 ▶ println "13.8.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2185 0 ▶ my $index_key = $tdef->{'index_mapping'} // '@index';
Condition0%0/2
$tdef->{"index_mapping"} // "\@index"
l!l
00
MC/DC0%0/1
$tdef->{"index_mapping"} // "\@index"
$tdef->{"index_mapping"}
Truth table0%0/2
A
A= $tdef->{"index_mapping"}
Aresult
11
00
2186
2187 0 ▶ println "13.8.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2188 0 foreach my $index (sort keys %$value) {
2189 0 my $__indent = indent();
2190 0 my $index_value = $value->{$index};
2191 0 ▶ println '-----------------------------------------------------------------' if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2192 0 ▶ println "13.8.3 [$index]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2193 0 my $map_context;
2194 0 ▶ if ($self->_cm_contains_any($container_mapping, '@id', '@type')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_cm_contains_any($container_mapping, '@id', '@type')) { } 0 0 0
2195 0 ▶ println "13.8.3.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2196 0 ▶ $map_context = $activeCtx->{'previous_context'} // $activeCtx;
Condition0%0/3
$activeCtx->{"previous_context"} // $activeCtx
l!l&&r!l&&!r
000
MC/DC0%0/2
$activeCtx->{"previous_context"} // $activeCtx
$activeCtx->{"previous_context"} $activeCtx
Truth table0%0/3
A // B
A= $activeCtx->{"previous_context"}B= $activeCtx
ABresult
1X1
011
000
2197 } else {
2198 0 $map_context = $activeCtx;
2199 }
2200
2201 0 my $index_tdef = $self->_ctx_term_defn($map_context, $index);
2202 0 ▶ if ($self->_cm_contains_any($container_mapping, '@type') and exists $index_tdef->{'@context'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_cm_contains_any($container_mapping, '@type') and exists $index_tdef->{'@context'}) { } 0 0 0
Condition0%0/3
$self->_cm_contains_any($container_mapping, "\@type") and exists $index_tdef->{"\@context"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_cm_contains_any($container_mapping, "\@type") and exists $index_tdef->{"\@context"}
$self->_cm_contains_any($container_mapping, "\@type") exists $index_tdef->{"\@context"}
Truth table0%0/3
A and B
A= $self->_cm_contains_any($container_mapping, "\@type")B= exists $index_tdef->{"\@context"}
ABresult
0X0
100
111
2203 0 ▶ println "13.8.3.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2204 0 $map_context = $self->_4_1_2_ctx_processing($map_context, $index_tdef->{'@context'});
2205 } else {
2206 0 ▶ println "13.8.3.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2207 0 $map_context = $activeCtx;
2208 }
2209
2210 0 ▶ println "13.8.3.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2211 0 my $expanded_index = $self->_5_2_2_iri_expansion($activeCtx, $index, vocab => 1);
2212  
2213 0 ▶ if (ref($index_value) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $index_value ne "ARRAY") 0 0 0
2214 0 ▶ println "13.8.3.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2215 0 $index_value = [$index_value];
2216 }
2217
2218 0 ▶ println "13.8.3.6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2219 0 $index_value = $self->_5_1_2_expansion($map_context, $key, $index_value, frameExpansion => $frameExpansion, ordered => $ordered);
2220 0 ▶ println(Data::Dumper->Dump([$index_value], ['*index_value'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2221
2222 0 ▶ println "13.8.3.7" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2223 0 foreach my $item (@$index_value) {
2224 0 my $__indent = indent();
2225 0 ▶ println '-----------------------------------------------------------------' if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2226 0 ▶ println "13.8.3.7 [$item]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2227 0 ▶ if ($self->_cm_contains($container_mapping, '@graph') and not $self->_is_graph_object($item)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_cm_contains($container_mapping, "\@graph") and not $self->_is_graph_object($item)) 0 0 0
Condition0%0/3
$self->_cm_contains($container_mapping, "\@graph") and not $self->_is_graph_object($item)
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_cm_contains($container_mapping, "\@graph") and not $self->_is_graph_object($item)
$self->_cm_contains($container_mapping, "\@graph") not $self->_is_graph_object($item)
Truth table0%0/3
A and not(B)
A= $self->_cm_contains($container_mapping, "\@graph")B= not $self->_is_graph_object($item)
ABresult
0X0
100
111
2228 0 ▶ println(Data::Dumper->Dump([$container_mapping], ['*container_mapping'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2229 0 ▶ println "13.8.3.7.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2230 0 ▶ $item = {'@graph' => (ref($item) eq 'ARRAY') ? $item : [$item]};
Branch: 1 branch
BranchTrueFalseTotal
ref $item eq 'ARRAY' ? : 0 0 0
2231 0 ▶ println(Data::Dumper->Dump([$item], ['*item'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2232 }
2233  
2234 0 ▶ if ($self->_cm_contains($container_mapping, '@index') and $index_key ne '@index' and $expanded_index ne '@none') {
Branch: 4 branches
BranchTrueFalseTotal
if ($self->_cm_contains($container_mapping, '@index') and $index_key ne '@index' and $expanded_index ne '@none') { } 0 0 0
elsif ($self->_cm_contains($container_mapping, '@index') and not exists $item->{'@index'} and $expanded_index ne '@none') { } 0 0 0
elsif ($self->_cm_contains($container_mapping, '@id') and not exists $item->{'@id'} and $expanded_index ne '@none') { } 0 0 0
elsif ($self->_cm_contains($container_mapping, '@type') and $expanded_index ne '@none') { } 0 0 0
Condition0%0/6
$self->_cm_contains($container_mapping, "\@index") and $index_key ne "\@index" and $expanded_index ne "\@none"
!ll&&!rl&&r
000
$self->_cm_contains($container_mapping, "\@index") and $index_key ne "\@index"
!ll&&!rl&&r
000
MC/DC0%0/3
$self->_cm_contains($container_mapping, "\@index") and $index_key ne "\@index" and $expanded_index ne "\@none"
$self->_cm_contains($container_mapping, "\@index") $index_key ne "\@index" $expanded_index ne "\@none"
Truth table0%0/4
A and B and C
A= $self->_cm_contains($container_mapping, "\@index")B= $index_key ne "\@index"C= $expanded_index ne "\@none"
ABCresult
0XX0
10X0
1100
1111
2235 0 ▶ println "13.8.3.7.2 " . Data::Dumper->Dump([$index_key], ['index_key']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2236 0 ▶ println "13.8.3.7.2.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2237 0 my $re_expanded_index = $self->_5_3_2_value_expand($activeCtx, $index_key, $index);
2238 0 ▶ println "13.8.3.7.2.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2239 0 my $expanded_index_key = $self->_5_2_2_iri_expansion($activeCtx, $index_key, vocab => 1);
2240 0 ▶ println "13.8.3.7.2.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2241 0 my $index_property_values = [$re_expanded_index];
2242 0 ▶ if (exists $item->{$expanded_index_key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $item->{$expanded_index_key}) 0 0 0
2243 0 my $v = $item->{$expanded_index_key};
2244 0 ▶ if (ref($v) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $v eq 'ARRAY') { } 0 0 0
2245 0 push(@{$index_property_values}, @$v);
2246 } else {
2247 0 push(@{$index_property_values}, $v);
2248 }
2249 }
2250 0 ▶ println "13.8.3.7.2.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2251 0 $item->{$expanded_index_key} = $index_property_values;
2252  
2253 0 ▶ if ($self->_is_value_object($item)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_value_object($item)) 0 0 0
2254 0 my @keys = sort keys %$item;
2255 0 ▶ if (scalar(@keys) > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @keys > 1) 0 0 0
2256 0 die 'invalid value object';
2257 }
2258 }
2259 ▶ } elsif ($self->_cm_contains($container_mapping, '@index') and not exists $item->{'@index'} and $expanded_index ne '@none') {
Condition0%0/6
$self->_cm_contains($container_mapping, "\@index") and not exists $item->{"\@index"} and $expanded_index ne "\@none"
!ll&&!rl&&r
000
$self->_cm_contains($container_mapping, "\@index") and not exists $item->{"\@index"}
!ll&&!rl&&r
000
MC/DC0%0/3
$self->_cm_contains($container_mapping, "\@index") and not exists $item->{"\@index"} and $expanded_index ne "\@none"
$self->_cm_contains($container_mapping, "\@index") not exists $item->{"\@index"} $expanded_index ne "\@none"
Truth table0%0/4
A and not(B) and C
A= $self->_cm_contains($container_mapping, "\@index")B= not exists $item->{"\@index"}C= $expanded_index ne "\@none"
ABCresult
0XX0
10X0
1100
1111
2260 0 ▶ println "13.8.3.7.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2261 0 $item->{'@index'} = $index;
2262 0 ▶ println(Data::Dumper->Dump([$item], ['*item'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2263 ▶ } elsif ($self->_cm_contains($container_mapping, '@id') and not exists $item->{'@id'} and $expanded_index ne '@none') {
Condition0%0/6
$self->_cm_contains($container_mapping, "\@id") and not exists $item->{"\@id"} and $expanded_index ne "\@none"
!ll&&!rl&&r
000
$self->_cm_contains($container_mapping, "\@id") and not exists $item->{"\@id"}
!ll&&!rl&&r
000
MC/DC0%0/3
$self->_cm_contains($container_mapping, "\@id") and not exists $item->{"\@id"} and $expanded_index ne "\@none"
$self->_cm_contains($container_mapping, "\@id") not exists $item->{"\@id"} $expanded_index ne "\@none"
Truth table0%0/4
A and not(B) and C
A= $self->_cm_contains($container_mapping, "\@id")B= not exists $item->{"\@id"}C= $expanded_index ne "\@none"
ABCresult
0XX0
10X0
1100
1111
2264 0 ▶ println "13.8.3.7.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2265 0 $expanded_index = $self->_5_2_2_iri_expansion($activeCtx, $index, documentRelative => 1);
2266 0 $item->{'@id'} = $expanded_index;
2267 ▶ } elsif ($self->_cm_contains($container_mapping, '@type') and $expanded_index ne '@none') {
Condition0%0/3
$self->_cm_contains($container_mapping, "\@type") and $expanded_index ne "\@none"
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_cm_contains($container_mapping, "\@type") and $expanded_index ne "\@none"
$self->_cm_contains($container_mapping, "\@type") $expanded_index ne "\@none"
Truth table0%0/3
A and B
A= $self->_cm_contains($container_mapping, "\@type")B= $expanded_index ne "\@none"
ABresult
0X0
100
111
2268 0 ▶ println "13.8.3.7.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2269 0 my $types = [$expanded_index];
2270 0 ▶ if (exists $item->{'@type'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $item->{"\@type"}) 0 0 0
2271 0 my $v = $item->{'@type'};
2272 0 ▶ if (ref($v) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $v eq 'ARRAY') { } 0 0 0
2273 0 push(@$types, @{$item->{'@type'}});
2274 } else {
2275 0 push(@$types, $v);
2276 }
2277 }
2278 0 $item->{'@type'} = $types;
2279 0 ▶ println "13.8.3.7.5 " . Data::Dumper->Dump([$types], ['types']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2280 }
2281
2282 0 ▶ println "13.8.3.7.6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2283 0 push(@$expandedValue, $item);
2284 }
2285 }
2286 0 ▶ println "13.8 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2287 } else {
2288 1 ▶ println "13.9" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2289 1 $expandedValue = $self->_5_1_2_expansion($activeCtx, $key, $value, frameExpansion => $frameExpansion, ordered => $ordered); # 13.9
2290 1 ▶ println "13.9 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2291 }
2292
2293 # warn Dumper($expandedValue);
2294 1 ▶ if (not(defined($expandedValue))) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $expandedValue) 0 1 1
2295 0 ▶ println "13.10 going to next element key" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2296 0 next; # 13.10
2297 }
2298
2299 1 ▶ if ($self->_cm_contains($container_mapping, '@list') and not $self->_is_list_object($expandedValue)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_cm_contains($container_mapping, "\@list") and not $self->_is_list_object($expandedValue)) 0 1 1
Condition33%1/3
$self->_cm_contains($container_mapping, "\@list") and not $self->_is_list_object($expandedValue)
!ll&&!rl&&r
100
MC/DC0%0/2
$self->_cm_contains($container_mapping, "\@list") and not $self->_is_list_object($expandedValue)
$self->_cm_contains($container_mapping, "\@list") not $self->_is_list_object($expandedValue)
Truth table33%1/3
A and not(B)
A= $self->_cm_contains($container_mapping, "\@list")B= not $self->_is_list_object($expandedValue)
ABresult
0X0
100
111
2300 # 13.11
2301 0 ▶ println "13.11" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2302 0 ▶ unless (ref($expandedValue) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $expandedValue eq "ARRAY") 0 0 0
2303 0 $expandedValue = [$expandedValue];
2304 }
2305 0 $expandedValue = { '@list' => $expandedValue };
2306 0 ▶ println "13.11 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2307 }
2308  
2309 1 ▶ if ($self->_cm_contains($container_mapping, '@graph') and not($self->_cm_contains($container_mapping, '@id')) and not($self->_cm_contains($container_mapping, '@index'))) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_cm_contains($container_mapping, "\@graph") and not $self->_cm_contains($container_mapping, "\@id") and not $self->_cm_contains($container_mapping, "\@index")) 0 1 1
Condition33%2/6
$self->_cm_contains($container_mapping, "\@graph") and not $self->_cm_contains($container_mapping, "\@id") and not $self->_cm_contains($container_mapping, "\@index")
!ll&&!rl&&r
100
$self->_cm_contains($container_mapping, "\@graph") and not $self->_cm_contains($container_mapping, "\@id")
!ll&&!rl&&r
100
MC/DC0%0/3
$self->_cm_contains($container_mapping, "\@graph") and not $self->_cm_contains($container_mapping, "\@id") and not $self->_cm_contains($container_mapping, "\@index")
$self->_cm_contains($container_mapping, "\@graph") not $self->_cm_contains($container_mapping, "\@id") not $self->_cm_contains($container_mapping, "\@index")
Truth table25%1/4
A and not(B) and not(C)
A= $self->_cm_contains($container_mapping, "\@graph")B= not $self->_cm_contains($container_mapping, "\@id")C= not $self->_cm_contains($container_mapping, "\@index")
ABCresult
0XX0
10X0
1100
1111
2310 # https://github.com/w3c/json-ld-api/issues/311
2311 # 13.12
2312 0 ▶ println "13.12" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2313 0 ▶ if (ref($expandedValue) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $expandedValue ne "ARRAY") 0 0 0
2314 0 $expandedValue = [$expandedValue];
2315 }
2316 0 my @values;
2317 0 foreach my $ev (@$expandedValue) {
2318 0 ▶ println "13.12.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2319 0 ▶ my $av = (ref($ev) eq 'ARRAY') ? $ev : [$ev];
Branch: 1 branch
BranchTrueFalseTotal
ref $ev eq 'ARRAY' ? : 0 0 0
2320 0 push(@values, {'@graph' => $av});
2321 }
2322 0 $expandedValue = \@values;
2323 0 ▶ println "13.12 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2324 }
2325
2326 1 ▶ if ($tdef->{'reverse'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tdef->{'reverse'}) { } 0 1 1
2327 # 13.13
2328 0 ▶ println "13.13" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2329 0 ▶ unless (exists $result->{'@reverse'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $result->{"\@reverse"}) 0 0 0
2330 0 ▶ println "13.13.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2331 0 $result->{'@reverse'} = {};
2332 }
2333
2334 0 ▶ println "13.13.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2335 0 my $reverse_map = $result->{'@reverse'};
2336
2337 0 ▶ if (ref($expandedValue) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $expandedValue ne "ARRAY") 0 0 0
2338 0 ▶ println "13.13.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2339 0 $expandedValue = [$expandedValue];
2340 }
2341
2342 0 foreach my $item (@$expandedValue) {
2343 0 ▶ println "13.13.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2344 0 ▶ if ($self->_is_value_object($item) or $self->_is_list_object($item)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_value_object($item) or $self->_is_list_object($item)) 0 0 0
Condition0%0/3
$self->_is_value_object($item) or $self->_is_list_object($item)
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->_is_value_object($item) or $self->_is_list_object($item)
$self->_is_value_object($item) $self->_is_list_object($item)
Truth table0%0/3
A or B
A= $self->_is_value_object($item)B= $self->_is_list_object($item)
ABresult
1X1
011
000
2345 0 ▶ println "13.13.4.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2346 0 die 'invalid reverse property value';
2347 }
2348
2349 0 ▶ unless (exists $reverse_map->{$expandedProperty}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $reverse_map->{$expandedProperty}) 0 0 0
2350 0 ▶ println "13.13.4.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2351 0 $reverse_map->{$expandedProperty} = [];
2352 }
2353
2354 0 ▶ println "13.13.4.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2355 0 push(@{ $reverse_map->{$expandedProperty} }, $item);
2356 }
2357 0 ▶ println "13.13 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2358 } else {
2359 # 13.14
2360 1 ▶ println "13.14" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2361 1 ▶ unless (exists $result->{$expandedProperty}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $result->{$expandedProperty}) 1 0 1
2362 1 ▶ println "13.14.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2363 1 $result->{$expandedProperty} = []; # 13.14.1
2364 }
2365  
2366 1 ▶ println "13.14.2 appending to result[$expandedProperty]: " . Data::Dumper->Dump([$expandedValue], ['expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2367 1 ▶ if (ref($expandedValue) eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $expandedValue eq 'ARRAY') { } 0 1 1
elsif (ref $expandedValue) { } 1 0 1
2368 0 push(@{$result->{$expandedProperty}}, @$expandedValue); # 13.14.2
2369 } elsif (ref($expandedValue)) {
2370 1 ▶ println "setting result[$expandedProperty]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2371 1 push(@{$result->{$expandedProperty}}, $expandedValue); # 13.14.2
2372 }
2373 1 ▶ println "13.14 resulting in " . Data::Dumper->Dump([$expandedValue], ['*expandedValue']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2374 }
2375 }
2376 1 $self->_5_1_2_expansion_step_14($activeCtx, $type_scoped_ctx, $result, $activeProp, $input_type, $nests, $ordered, $frameExpansion, $element);
2377 }
2378  
2379 1 ▶ sub _5_1_2_expansion_step_14 {
Subroutine _5_1_2_expansion_step_14: called CC=19 SCAR=52.7
2380 1 my $self = shift;
2381 1 my $activeCtx = shift;
2382 1 my $type_scoped_ctx = shift;
2383 1 my $result = shift;
2384 1 my $activeProp = shift;
2385 1 my $input_type = shift;
2386 1 my $nests = shift;
2387 1 my $ordered = shift;
2388 1 my $frameExpansion = shift;
2389 1 my $element = shift;
2390
2391 # https://github.com/w3c/json-ld-api/issues/262
2392 1 ▶ println "14" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2393 1 my @keys = sort keys %$nests; # https://github.com/w3c/json-ld-api/issues/295
2394 1 foreach my $nesting_key (@keys) {
2395 0 delete $nests->{$nesting_key};
2396 # 14
2397 0 my $__indent = indent();
2398 0 ▶ println "14 [$nesting_key]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2399 0 ▶ println "14.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2400 # next unless (exists $element->{$nesting_key});
2401 0 my $nested_values = $element->{$nesting_key}; # 14.1
2402 0 ▶ if (not defined $nested_values) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $nested_values) 0 0 0
2403 0 $nested_values = [];
2404 }
2405 0 ▶ if (not(ref($nested_values)) or ref($nested_values) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $nested_values or ref $nested_values ne "ARRAY") 0 0 0
Condition0%0/3
not ref $nested_values or ref $nested_values ne "ARRAY"
l!l&&r!l&&!r
000
MC/DC0%0/2
not ref $nested_values or ref $nested_values ne "ARRAY"
not ref $nested_values ref $nested_values ne "ARRAY"
Truth table0%0/3
not(A) or B
A= not ref $nested_valuesB= ref $nested_values ne "ARRAY"
ABresult
1X1
011
000
2406 0 $nested_values = [$nested_values];
2407 }
2408  
2409 0 ▶ println "14.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2410 0 ▶ println(Data::Dumper->Dump([$nesting_key, $element, $nested_values], [qw(nesting_key element nested_values)])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2411 0 foreach my $nested_value (@$nested_values) {
2412 0 my $__indent = indent();
2413 0 ▶ println '-----------------------------------------------------------------' if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2414 0 ▶ println "14.2 loop iteration" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2415 0 ▶ if (ref($nested_value) ne 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $nested_value ne "HASH") 0 0 0
2416 0 ▶ println "14.2.1 " . Data::Dumper->Dump([$nested_value], ['*invalid_nest_value']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2417 0 die 'invalid @nest value'; # 14.2.1
2418 }
2419
2420 0 my @keys = keys %$nested_value;
2421 0 my %expandedKeys = map { $_ => 1 } map { $self->_5_2_2_iri_expansion($activeCtx, $_) } @keys;
2422 0 ▶ if (exists $expandedKeys{'@value'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $expandedKeys{"\@value"}) 0 0 0
2423 0 ▶ println "14.2.1 " . Data::Dumper->Dump([$nested_value], ['*invalid_nest_value']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2424 0 die 'invalid @nest value';
2425 }
2426
2427 0 ▶ println "14.2.2 ENTER =================> call to _5_1_2_expansion_step_13" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2428 0 my $__indent_2 = indent();
2429 0 $self->_5_1_2_expansion_step_13($activeCtx, $type_scoped_ctx, $result, $activeProp, $input_type, $nests, $ordered, $frameExpansion, $nested_value); # 14.2.2
2430  
2431 }
2432 }
2433 1 ▶ println "after 14 resulting in " . Data::Dumper->Dump([$result], ['*result']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2434 }
2435  
2436 6 ▶ sub _5_2_2_iri_expansion {
Subroutine _5_2_2_iri_expansion: called CC=50 SCAR=62.1
2437 6 my $self = shift;
2438 6 my $activeCtx = shift;
2439 6 my $value = shift;
2440 6 ▶ println "ENTER =================> _5_2_2_iri_expansion($value)" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 6 6
2441 6 my $__indent = indent();
2442 6 my %args = @_;
2443 6 my %acceptable = map { $_ => 1 } qw(documentRelative vocab localCtx defined);
2444 6 foreach my $k (keys %args) {
2445 5 ▶ die "Not a recognized IRI expansion algorithm argument: $k" unless exists $acceptable{$k};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $acceptable{$k} 0 5 5
2446 }
2447 6 ▶ my $vocab = $args{vocab} // 0;
Condition100%2/2
$args{"vocab"} // 0
l!l
42
MC/DC100%1/1
$args{"vocab"} // 0
$args{"vocab"}
Truth table100%2/2
A
A= $args{"vocab"}
Aresult
11
00
2448 6 ▶ my $documentRelative = $args{documentRelative} // 0;
Condition100%2/2
$args{"documentRelative"} // 0
l!l
15
MC/DC100%1/1
$args{"documentRelative"} // 0
$args{"documentRelative"}
Truth table100%2/2
A
A= $args{"documentRelative"}
Aresult
11
00
2449 6 ▶ my $localCtx = $args{localCtx} // {};
Condition50%1/2
$args{"localCtx"} // {}
l!l
06
MC/DC0%0/1
$args{"localCtx"} // {}
$args{"localCtx"}
Truth table50%1/2
A
A= $args{"localCtx"}
Aresult
11
00
2450 6 ▶ my $defined = $args{'defined'} // {};
Condition50%1/2
$args{"defined"} // {}
l!l
06
MC/DC0%0/1
$args{"defined"} // {}
$args{"defined"}
Truth table50%1/2
A
A= $args{"defined"}
Aresult
11
00
2451 6 local($Data::Dumper::Indent) = 0;
2452 6 ▶ println(Data::Dumper->Dump([$activeCtx], ['*activeCtx'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 6 6
2453 6 ▶ println(Data::Dumper->Dump([$localCtx], ['*localCtx'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 6 6
2454 6 ▶ println(Data::Dumper->Dump([$defined], ['*defined'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 6 6
2455
2456 # 5.2.2 algorithm
2457
2458 6 ▶ unless (defined($value) and not exists $keywords{$value}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $value and not exists $keywords{$value}) 2 4 6
Condition66%2/3
defined $value and not exists $keywords{$value}
!ll&&!rl&&r
024
MC/DC50%1/2
defined $value and not exists $keywords{$value}
defined $value not exists $keywords{$value}
Truth table66%2/3
A and not(B)
A= defined $valueB= not exists $keywords{$value}
ABresult
0X0
100
111
2459 2 ▶ println "1 returning from _5_2_2_iri_expansion: undefined/keyword value" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 2 2
2460 2 return $value;
2461 }
2462
2463 4 ▶ if ($value =~ /^@[A-Za-z]+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^\@[A-Za-z]+$/u) 0 4 4
2464 0 ▶ println "2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2465 0 warn "IRI expansion attempted on a term that looks like a keyword: $value\n"; # 2
2466 0 return;
2467 }
2468
2469 4 ▶ if (defined($localCtx) and my $v = $localCtx->{$value}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $localCtx and my $v = $localCtx->{$value}) 0 4 4
Condition33%1/3
defined $localCtx and my $v = $localCtx->{$value}
!ll&&!rl&&r
040
MC/DC0%0/2
defined $localCtx and my $v = $localCtx->{$value}
defined $localCtx my $v = $localCtx->{$value}
Truth table33%1/3
A and B
A= defined $localCtxB= my $v = $localCtx->{$value}
ABresult
0X0
100
111
2470 0 ▶ unless ($defined->{$v}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($defined->{$v}) 0 0 0
2471 0 ▶ println "3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2472 0 $self->_4_2_2_create_term_definition($activeCtx, $localCtx, $value, $defined); # 3
2473 }
2474 }
2475  
2476 4 ▶ if (my $tdef = $self->_ctx_term_defn($activeCtx, $value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tdef = $self->_ctx_term_defn($activeCtx, $value)) 0 4 4
2477 0 ▶ my $i = $tdef->{'iri_mapping'} // '';
Condition0%0/2
$tdef->{"iri_mapping"} // ""
l!l
00
MC/DC0%0/1
$tdef->{"iri_mapping"} // ""
$tdef->{"iri_mapping"}
Truth table0%0/2
A
A= $tdef->{"iri_mapping"}
Aresult
11
00
2478 0 ▶ if ($keywords{$i}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($keywords{$i}) 0 0 0
2479 0 ▶ println "4 returning from _5_2_2_iri_expansion with a keyword: $i" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2480 0 return $i; # 4
2481 }
2482 }
2483
2484 4 ▶ if ($vocab and my $tdef = $self->_ctx_term_defn($activeCtx, $value)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($vocab and my $tdef = $self->_ctx_term_defn($activeCtx, $value)) 0 4 4
Condition66%2/3
$vocab and my $tdef = $self->_ctx_term_defn($activeCtx, $value)
!ll&&!rl&&r
130
MC/DC0%0/2
$vocab and my $tdef = $self->_ctx_term_defn($activeCtx, $value)
$vocab my $tdef = $self->_ctx_term_defn($activeCtx, $value)
Truth table66%2/3
A and B
A= $vocabB= my $tdef = $self->_ctx_term_defn($activeCtx, $value)
ABresult
0X0
100
111
2485 0 my $i = $tdef->{'iri_mapping'};
2486 0 ▶ println "5 returning from _5_2_2_iri_expansion with iri mapping from active context: $i" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2487 0 return $i; # 5
2488 }
2489
2490 4 ▶ if ($value =~ /.:/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /.:/u) 1 3 4
2491 # 6
2492 1 ▶ println "6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2493 1 ▶ println "6.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2494 1 my ($prefix, $suffix) = split(/:/, $value, 2); # 6.1
2495
2496 1 ▶ if ($prefix eq '_' or $suffix =~ m{^//}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prefix eq "_" or $suffix =~ m[^//]u) 1 0 1
Condition33%1/3
$prefix eq "_" or $suffix =~ m[^//]u
l!l&&r!l&&!r
010
MC/DC0%0/2
$prefix eq "_" or $suffix =~ m[^//]u
$prefix eq "_" $suffix =~ m[^//]u
Truth table33%1/3
A or B
A= $prefix eq "_"B= $suffix =~ m[^//]u
ABresult
1X1
011
000
2497 1 ▶ println "6.2 returning from _5_2_2_iri_expansion: already an absolute IRI or blank node identifier: $value" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2498 1 return $value; # 6.2
2499 }
2500
2501 0 ▶ if ($localCtx and exists $localCtx->{$prefix} and not($defined->{$prefix})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($localCtx and exists $localCtx->{$prefix} and not $defined->{$prefix}) 0 0 0
Condition0%0/6
$localCtx and exists $localCtx->{$prefix} and not $defined->{$prefix}
!ll&&!rl&&r
000
$localCtx and exists $localCtx->{$prefix}
!ll&&!rl&&r
000
MC/DC0%0/3
$localCtx and exists $localCtx->{$prefix} and not $defined->{$prefix}
$localCtx exists $localCtx->{$prefix} not $defined->{$prefix}
Truth table0%0/4
A and B and not(C)
A= $localCtxB= exists $localCtx->{$prefix}C= not $defined->{$prefix}
ABCresult
0XX0
10X0
1100
1111
2502 0 ▶ println "6.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2503 0 $self->_4_2_2_create_term_definition($activeCtx, $localCtx, $prefix, $defined);
2504 }
2505
2506 0 my $tdef = $self->_ctx_term_defn($activeCtx, $prefix);
2507 0 ▶ if ($tdef and $tdef->{'iri_mapping'} and $tdef->{'prefix_flag'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tdef and $tdef->{"iri_mapping"} and $tdef->{"prefix_flag"}) 0 0 0
Condition0%0/6
$tdef and $tdef->{"iri_mapping"} and $tdef->{"prefix_flag"}
!ll&&!rl&&r
000
$tdef and $tdef->{"iri_mapping"}
!ll&&!rl&&r
000
MC/DC0%0/3
$tdef and $tdef->{"iri_mapping"} and $tdef->{"prefix_flag"}
$tdef $tdef->{"iri_mapping"} $tdef->{"prefix_flag"}
Truth table0%0/4
A and B and C
A= $tdefB= $tdef->{"iri_mapping"}C= $tdef->{"prefix_flag"}
ABCresult
0XX0
10X0
1100
1111
2508 0 my $i = $tdef->{'iri_mapping'} . $suffix;
2509 0 ▶ println "6.4 returning from _5_2_2_iri_expansion with concatenated iri mapping and suffix: $i" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2510 0 return $i;
2511 }
2512
2513 0 ▶ if ($self->_is_abs_iri($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_abs_iri($value)) 0 0 0
2514 0 ▶ println "6.5 returning from _5_2_2_iri_expansion with absolute IRI: $value" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2515 0 return $value;
2516 }
2517 }
2518
2519 3 ▶ if ($vocab and exists $activeCtx->{'@vocab'}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($vocab and exists $activeCtx->{'@vocab'}) { } 2 1 3
elsif ($documentRelative) { } 0 1 1
Condition66%2/3
$vocab and exists $activeCtx->{"\@vocab"}
!ll&&!rl&&r
102
MC/DC50%1/2
$vocab and exists $activeCtx->{"\@vocab"}
$vocab exists $activeCtx->{"\@vocab"}
Truth table66%2/3
A and B
A= $vocabB= exists $activeCtx->{"\@vocab"}
ABresult
0X0
100
111
2520 2 my $i = $activeCtx->{'@vocab'} . $value;
2521 2 ▶ println "7 returning from _5_2_2_iri_expansion with concatenated vocabulary mapping and value: $i" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 2 2
2522 2 return $i;
2523 } elsif ($documentRelative) {
2524 # 8
2525 0 ▶ println "8" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2526 0 my $base = $activeCtx->{'@base'};
2527 0 ▶ if (defined $base) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $base) 0 0 0
2528 0 my $i = IRI->new(value => $value, base => $base);
2529 0 $value = $i->abs;
2530 }
2531 }
2532  
2533 1 ▶ println "9 returning from _5_2_2_iri_expansion with final value: $value" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2534 1 return $value; # 9
2535 }
2536
2537 1 ▶ sub _5_3_2_value_expand {
Subroutine _5_3_2_value_expand: called CC=26 SCAR=50.7
2538 1 my $self = shift;
2539 1 my $activeCtx = shift;
2540 1 my $activeProp = shift;
2541 1 my $value = shift;
2542 1 my $_vs = Data::Dumper->new([$value], ['value'])->Terse(1)->Dump([$value], ['value']);
2543 1 ▶ println "ENTER =================> _5_3_2_value_expand($_vs)" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2544 1 my $__indent = indent();
2545
2546 1 my $tdef = $self->_ctx_term_defn($activeCtx, $activeProp);
2547  
2548 1 ▶ if (exists $tdef->{'type_mapping'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $tdef->{"type_mapping"}) 0 1 1
2549 0 ▶ if ($tdef->{'type_mapping'} eq '@id' and _is_string($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tdef->{"type_mapping"} eq "\@id" and _is_string($value)) 0 0 0
Condition0%0/3
$tdef->{"type_mapping"} eq "\@id" and _is_string($value)
!ll&&!rl&&r
000
MC/DC0%0/2
$tdef->{"type_mapping"} eq "\@id" and _is_string($value)
$tdef->{"type_mapping"} eq "\@id" _is_string($value)
Truth table0%0/3
A and B
A= $tdef->{"type_mapping"} eq "\@id"B= _is_string($value)
ABresult
0X0
100
111
2550 0 my $iri = $self->_5_2_2_iri_expansion($activeCtx, $value, documentRelative => 1);
2551 0 ▶ println "1 returning from _5_3_2_value_expand with new map containing \@id: $iri" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2552 0 return { '@id' => $iri }; # 1
2553 }
2554  
2555 0 ▶ if ($tdef->{'type_mapping'} eq '@vocab' and _is_string($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tdef->{"type_mapping"} eq "\@vocab" and _is_string($value)) 0 0 0
Condition0%0/3
$tdef->{"type_mapping"} eq "\@vocab" and _is_string($value)
!ll&&!rl&&r
000
MC/DC0%0/2
$tdef->{"type_mapping"} eq "\@vocab" and _is_string($value)
$tdef->{"type_mapping"} eq "\@vocab" _is_string($value)
Truth table0%0/3
A and B
A= $tdef->{"type_mapping"} eq "\@vocab"B= _is_string($value)
ABresult
0X0
100
111
2556 0 my $iri = $self->_5_2_2_iri_expansion($activeCtx, $value, vocab => 1, documentRelative => 1);
2557 0 ▶ println "1 returning from _5_3_2_value_expand with new map containing vocab \@id: $iri" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2558 0 return { '@id' => $iri }; # 2
2559 }
2560 }
2561
2562 1 ▶ println "3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2563 1 my $result = { '@value' => $value }; # 3
2564
2565 1 my $tm = $tdef->{'type_mapping'};
2566 1 ▶ if (exists($tdef->{'type_mapping'}) and $tm ne '@id' and $tm ne '@vocab' and $tm ne '@none') {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $tdef->{'type_mapping'} and $tm ne '@id' and $tm ne '@vocab' and $tm ne '@none') { } 0 1 1
elsif (_is_string($value)) { } 1 0 1
Condition33%3/9
exists $tdef->{"type_mapping"} and $tm ne "\@id" and $tm ne "\@vocab" and $tm ne "\@none"
!ll&&!rl&&r
100
exists $tdef->{"type_mapping"} and $tm ne "\@id" and $tm ne "\@vocab"
!ll&&!rl&&r
100
exists $tdef->{"type_mapping"} and $tm ne "\@id"
!ll&&!rl&&r
100
MC/DC0%0/4
exists $tdef->{"type_mapping"} and $tm ne "\@id" and $tm ne "\@vocab" and $tm ne "\@none"
exists $tdef->{"type_mapping"} $tm ne "\@id" $tm ne "\@vocab" $tm ne "\@none"
Truth table20%1/5
A and B and C and D
A= exists $tdef->{"type_mapping"}B= $tm ne "\@id"C= $tm ne "\@vocab"D= $tm ne "\@none"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2567 0 ▶ println "4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2568 0 $result->{'@type'} = $tm; # 4
2569 } elsif (_is_string($value)) {
2570 1 ▶ println "5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2571 1 ▶ println "5.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2572 1 ▶ my $language = (exists $tdef->{'language_mapping'}) ? $tdef->{'language_mapping'} : $activeCtx->{'@language'}; # 5.1
Branch: 1 branch
BranchTrueFalseTotal
exists $tdef->{'language_mapping'} ? : 0 1 1
2573  
2574 1 ▶ println "5.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2575 1 ▶ my $direction = (exists $tdef->{'direction_mapping'}) ? $tdef->{'direction_mapping'} : $activeCtx->{'@direction'}; # 5.2
Branch: 1 branch
BranchTrueFalseTotal
exists $tdef->{'direction_mapping'} ? : 0 1 1
2576  
2577 1 ▶ if (defined($language)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $language) 0 1 1
2578 0 ▶ println "5.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2579 0 $result->{'@language'} = $language; # 5.3
2580 }
2581
2582 1 ▶ if (defined($direction)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $direction) 0 1 1
2583 0 ▶ println "5.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2584 0 $result->{'@direction'} = $direction; # 5.4
2585 }
2586 }
2587
2588 1 ▶ println "6 returning from _5_3_2_value_expand with final result" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 1 1
2589 1 return $result; # 6
2590 }
2591  
2592 0 ▶ sub _6_1_2_compaction {
Subroutine _6_1_2_compaction: not called CC=237 SCAR=109.3
2593 0 my $self = shift;
2594 0 my $activeCtx = shift;
2595 0 my $inverseCtx = shift;
2596 0 my $activeProp = shift;
2597 0 my $element = shift;
2598 {
2599 0 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.2
2600 0 ▶ println "ENTER =================> _6_1_2_compaction('$activeProp')" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2601 }
2602 0 my $__indent = indent();
2603 # local($Data::Dumper::Indent) = 0;
2604 # println(Data::Dumper->Dump([$activeCtx], ['activeCtx'])) if $debug;
2605 # println(Data::Dumper->Dump([$activeProp], ['activeProp'])) if $debug;
2606 0 ▶ println(Data::Dumper->Dump([$element], ['element'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2607 0 my %args = @_;
2608 0 ▶ my $compactArrays = $args{compactArrays} // 0;
Condition0%0/2
$args{"compactArrays"} // 0
l!l
00
MC/DC0%0/1
$args{"compactArrays"} // 0
$args{"compactArrays"}
Truth table0%0/2
A
A= $args{"compactArrays"}
Aresult
11
00
2609 0 ▶ my $ordered = $args{ordered} // 0;
Condition0%0/2
$args{"ordered"} // 0
l!l
00
MC/DC0%0/1
$args{"ordered"} // 0
$args{"ordered"}
Truth table0%0/2
A
A= $args{"ordered"}
Aresult
11
00
2610
2611 0 ▶ println "1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2612 0 my $type_scoped_ctx = clone($activeCtx);
2613
2614 0 ▶ if (_is_scalar($element)) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_scalar($element)) 0 0 0
2615 0 ▶ println "2 returning scalar " . Data::Dumper->Dump([$element], [qw(element)]) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2616 0 return $element;
2617 }
2618
2619 0 ▶ if (ref($element) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $element eq "ARRAY") 0 0 0
2620 0 ▶ println "3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2621 0 ▶ println "3.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2622 0 my $result = [];
2623  
2624 0 ▶ println "3.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2625 0 foreach my $item (@$element) {
2626 0 ▶ println "3.2.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2627 0 my $compactedItem = $self->_6_1_2_compaction($activeCtx, $inverseCtx, $activeProp, $item, %args);
2628 0 ▶ if (defined($compactedItem)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $compactedItem) 0 0 0
2629 0 ▶ println "3.2.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2630 0 push(@$result, $compactedItem);
2631 }
2632 }
2633
2634 0 ▶ my $not_graph = ($activeProp // '') ne '@graph';
Condition0%0/2
$activeProp // ""
l!l
00
MC/DC0%0/1
$activeProp // ""
$activeProp
Truth table0%0/2
A
A= $activeProp
Aresult
11
00
2635 0 ▶ my $not_set = ($activeProp // '') ne '@set';
Condition0%0/2
$activeProp // ""
l!l
00
MC/DC0%0/1
$activeProp // ""
$activeProp
Truth table0%0/2
A
A= $activeProp
Aresult
11
00
2636 0 my $tdef = $self->_ctx_term_defn($activeCtx, $activeProp);
2637 0 my $container_mapping = $tdef->{'container_mapping'};
2638 # https://github.com/w3c/json-ld-api/issues/334
2639 # if (scalar(@$result) == 1 and $compactArrays and (($not_graph and $not_set) or (not($self->_cm_contains_any($container_mapping, '@list', '@set')) ))) {
2640 0 ▶ if (scalar(@$result) == 1 and (($not_graph and $not_set) or (not($self->_cm_contains_any($container_mapping, '@list', '@set')) and $compactArrays))) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$result == 1 and $not_graph && $not_set || !$self->_cm_contains_any($container_mapping, "\@list", "\@set") && $compactArrays) 0 0 0
Condition0%0/12
scalar @$result == 1 and $not_graph && $not_set || !$self->_cm_contains_any($container_mapping, "\@list", "\@set") && $compactArrays
!ll&&!rl&&r
000
$not_graph and $not_set or not $self->_cm_contains_any($container_mapping, "\@list", "\@set") and $compactArrays
l!l&&r!l&&!r
000
$not_graph and $not_set
!ll&&!rl&&r
000
not $self->_cm_contains_any($container_mapping, "\@list", "\@set") and $compactArrays
!ll&&!rl&&r
000
MC/DC0%0/5
scalar @$result == 1 and $not_graph && $not_set || !$self->_cm_contains_any($container_mapping, "\@list", "\@set") && $compactArrays
scalar @$result == 1 $not_graph $not_set not $self->_cm_contains_any($container_mapping, "\@list", "\@set") $compactArrays
Truth table0%0/8
A and B and C or not(D) and E
A= scalar @$result == 1B= $not_graphC= $not_setD= not $self->_cm_contains_any($container_mapping, "\@list", "\@set")E= $compactArrays
ABCDEresult
0XXXX0
10X0X0
10X100
1100X0
110100
111XX1
10X111
110111
2641 # https://github.com/w3c/json-ld-api/issues/334
2642 0 ▶ println "3.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2643 0 $result = $result->[0];
2644 }
2645
2646 0 ▶ println "3.4 returning " . Data::Dumper->Dump([$result], [qw(result)]) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2647 0 return $result;
2648 }
2649
2650 0 ▶ println "4 element is a map" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2651
2652 0 ▶ if (exists $activeCtx->{'previous_context'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $activeCtx->{"previous_context"}) 0 0 0
2653 0 ▶ if (not exists $element->{'@value'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $element->{"\@value"}) 0 0 0
2654 0 my @keys = keys %$element;
2655 0 ▶ unless (scalar(@keys) == 1 and $keys[0] eq '@id') {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar @keys == 1 and $keys[0] eq "\@id") 0 0 0
Condition0%0/3
scalar @keys == 1 and $keys[0] eq "\@id"
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @keys == 1 and $keys[0] eq "\@id"
scalar @keys == 1 $keys[0] eq "\@id"
Truth table0%0/3
A and B
A= scalar @keys == 1B= $keys[0] eq "\@id"
ABresult
0X0
100
111
2656 0 ▶ println "5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2657 0 $activeCtx = $activeCtx->{'previous_context'};
2658 }
2659 }
2660 }
2661
2662 0 my $tdef = $self->_ctx_term_defn($activeCtx, $activeProp);
2663 0 ▶ if (exists $tdef->{'@context'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $tdef->{"\@context"}) 0 0 0
2664 0 ▶ println "6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2665 0 ▶ println "6.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2666 0 $activeCtx = $self->_4_1_2_ctx_processing($activeCtx, $tdef->{'@context'}, override_protected => 1);
2667
2668 0 ▶ println "6.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2669 0 $inverseCtx = $self->_4_3_inverse_context_creation($activeCtx);
2670 }
2671
2672 0 ▶ if (exists $element->{'@value'} or exists $element->{'@id'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $element->{"\@value"} or exists $element->{"\@id"}) 0 0 0
Condition0%0/3
exists $element->{"\@value"} or exists $element->{"\@id"}
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $element->{"\@value"} or exists $element->{"\@id"}
exists $element->{"\@value"} exists $element->{"\@id"}
Truth table0%0/3
A or B
A= exists $element->{"\@value"}B= exists $element->{"\@id"}
ABresult
1X1
011
000
2673 0 ▶ println "possibly 7" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2674 0 my $v = $self->_6_3_value_compaction($activeCtx, $inverseCtx, $activeProp, $element);
2675 0 ▶ my $tm = $tdef->{'type_mapping'} // '';
Condition0%0/2
$tdef->{"type_mapping"} // ""
l!l
00
MC/DC0%0/1
$tdef->{"type_mapping"} // ""
$tdef->{"type_mapping"}
Truth table0%0/2
A
A= $tdef->{"type_mapping"}
Aresult
11
00
2676 0 ▶ if (_is_scalar($v) or $tm eq '@json') {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_scalar($v) or $tm eq "\@json") 0 0 0
Condition0%0/3
_is_scalar($v) or $tm eq "\@json"
l!l&&r!l&&!r
000
MC/DC0%0/2
_is_scalar($v) or $tm eq "\@json"
_is_scalar($v) $tm eq "\@json"
Truth table0%0/3
A or B
A= _is_scalar($v)B= $tm eq "\@json"
ABresult
1X1
011
000
2677 0 ▶ println "7 returning " . Data::Dumper->Dump([$v], [qw(result)]) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2678 0 return $v;
2679 }
2680 }
2681
2682 0 my $container_mapping = $tdef->{'container_mapping'};
2683 0 ▶ if (_is_list_object($element) and $self->_cm_contains($container_mapping, '@list')) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_list_object($element) and $self->_cm_contains($container_mapping, "\@list")) 0 0 0
Condition0%0/3
_is_list_object($element) and $self->_cm_contains($container_mapping, "\@list")
!ll&&!rl&&r
000
MC/DC0%0/2
_is_list_object($element) and $self->_cm_contains($container_mapping, "\@list")
_is_list_object($element) $self->_cm_contains($container_mapping, "\@list")
Truth table0%0/3
A and B
A= _is_list_object($element)B= $self->_cm_contains($container_mapping, "\@list")
ABresult
0X0
100
111
2684 0 ▶ println "8" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2685 0 my $result = $self->_6_1_2_compaction($activeCtx, $inverseCtx, $activeProp, $element->{'@list'}, %args);
2686 0 ▶ println "8 returning " . Data::Dumper->Dump([$result], [qw(result)]) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2687 0 return $result;
2688 }
2689  
2690 0 ▶ println "9" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2691 0 ▶ my $insideReverse = (defined($activeProp) and $activeProp eq '@reverse');
Condition0%0/3
defined $activeProp && $activeProp eq '@reverse'
!ll&&!rl&&r
000
MC/DC0%0/2
defined $activeProp && $activeProp eq '@reverse'
defined $activeProp $activeProp eq '@reverse'
Truth table0%0/3
A && B
A= defined $activePropB= $activeProp eq '@reverse'
ABresult
0X0
100
111
2692
2693 0 ▶ println "10" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2694 0 my $result = {};
2695
2696 0 ▶ if (exists $element->{'@type'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $element->{"\@type"}) 0 0 0
2697 0 ▶ println "11" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2698 0 my @types = _values_from_scalar_or_array($element->{'@type'});
2699 # my @types = @{ $element->{'@type'} };
2700 0 my @compacted_types = map { $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, $_, vocab => 1) } @types;
2701 0 foreach my $term (sort @compacted_types) {
2702 0 ▶ println "11.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2703 0 my $tdef = $self->_ctx_term_defn($type_scoped_ctx, $term);
2704 0 ▶ if (exists $tdef->{'@context'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $tdef->{"\@context"}) 0 0 0
2705 0 ▶ println "11.1.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2706 0 $activeCtx = $self->_4_1_2_ctx_processing($activeCtx, $tdef->{'@context'});
2707  
2708 0 ▶ println "11.1.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2709 0 $inverseCtx = $self->_4_3_inverse_context_creation($activeCtx);
2710 }
2711 }
2712 }
2713
2714 0 ▶ println "12" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2715 0 foreach my $expandedProperty (sort keys %$element) {
2716 0 my $__indent = indent();
2717 0 ▶ println "----------------------------------------------------------------" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2718 0 my $expandedValue = $element->{$expandedProperty};
2719 0 ▶ println "12 [$expandedProperty]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2720  
2721 0 ▶ my $tdef = $self->_ctx_term_defn($activeCtx, $activeProp) || {};
Condition0%0/2
$self->_ctx_term_defn($activeCtx, $activeProp) || {}
l!l
00
MC/DC0%0/1
$self->_ctx_term_defn($activeCtx, $activeProp) || {}
$self->_ctx_term_defn($activeCtx, $activeProp)
Truth table0%0/2
A
A= $self->_ctx_term_defn($activeCtx, $activeProp)
Aresult
11
00
2722 0 my $container_mapping = $tdef->{'container_mapping'};
2723
2724 0 ▶ if ($expandedProperty eq '@id') {
Branch: 6 branches
BranchTrueFalseTotal
if ($expandedProperty eq '@id') { } 0 0 0
elsif ($expandedProperty eq '@type') { } 0 0 0
elsif ($expandedProperty eq '@reverse') { } 0 0 0
elsif ($expandedProperty eq '@preserve') { } 0 0 0
elsif ($expandedProperty eq '@index' and $self->_cm_contains($container_mapping, '@index')) { } 0 0 0
elsif ($expandedProperty =~ /^@(direction|index|language|value)$/u) { } 0 0 0
2725 0 ▶ println "12.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2726 0 ▶ if (_is_string($expandedValue)) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_string($expandedValue)) 0 0 0
2727 0 ▶ println "12.1.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2728 0 my $compactedValue = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, $expandedValue, vocab => 0);
2729  
2730 0 ▶ println "12.1.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2731 0 my $alias = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, $expandedProperty, vocab => 1);
2732
2733 0 ▶ println "12.1.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2734 0 $result->{$alias} = $compactedValue;
2735 0 next;
2736 }
2737 } elsif ($expandedProperty eq '@type') {
2738 0 ▶ println "12.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2739 0 my $compactedValue;
2740 0 ▶ if (_is_string($expandedValue)) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_string($expandedValue)) { } 0 0 0
2741 0 ▶ println "12.2.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2742 0 $compactedValue = $self->_6_2_2_iri_compaction($type_scoped_ctx, $inverseCtx, $expandedValue, vocab => 1);
2743 } else {
2744 0 ▶ println "12.2.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2745 0 ▶ println "12.2.2.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2746 0 $compactedValue = [];
2747  
2748 0 ▶ println "12.2.2.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2749 0 foreach my $expandedType (@{ $expandedValue }) {
2750 0 ▶ println "12.2.2.2.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2751 0 my $term = $self->_6_2_2_iri_compaction($type_scoped_ctx, $inverseCtx, $expandedType, vocab => 1);
2752
2753 0 ▶ println "12.2.2.2.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2754 0 push(@{ $compactedValue }, $term);
2755 }
2756  
2757 0 ▶ println "12.2.2.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2758 0 ▶ if (scalar(@$compactedValue) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$compactedValue == 1) 0 0 0
2759 0 $compactedValue = $compactedValue->[0];
2760 }
2761 }
2762  
2763 0 ▶ println "12.2.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2764 0 my $alias = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, $expandedProperty, vocab => 1);
2765  
2766 0 ▶ println "12.2.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2767 0 my $tdef = $self->_ctx_term_defn($activeCtx, $alias);
2768 0 my $container_mapping = $tdef->{'container_mapping'};
2769 0 ▶ my $as_array = ($self->_cm_contains($container_mapping, '@set'))
Branch: 1 branch
BranchTrueFalseTotal
$self->_cm_contains($container_mapping, '@set') ? : 0 0 0
2770 ? 1
2771 : not($compactArrays);
2772 0 ▶ println "12.2.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2773 0 $self->_add_value($result, $alias, $compactedValue, as_array => $as_array);
2774  
2775 0 ▶ println "12.2.6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2776 0 next;
2777 } elsif ($expandedProperty eq '@reverse') {
2778 0 ▶ println "12.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2779 0 ▶ println "12.3.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2780 0 my $compactedValue = $self->_6_1_2_compaction($activeCtx, $inverseCtx, '@reverse', $expandedValue, compactArrays => $compactArrays, ordered => $ordered);
2781
2782 0 foreach my $property (keys %$compactedValue) {
2783 0 ▶ println "12.3.2 [$property]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2784 0 my $value = $compactedValue->{$property};
2785
2786 0 my $tdef = $self->_ctx_term_defn($activeCtx, $property);
2787 0 ▶ if ($tdef->{'reverse'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tdef->{"reverse"}) 0 0 0
2788 0 ▶ println "12.3.2.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2789 0 ▶ println "12.3.2.1.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2790 0 my $container_mapping = $tdef->{'container_mapping'};
2791 0 my $as_array;
2792 0 ▶ if ($self->_cm_contains($container_mapping, '@set')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_cm_contains($container_mapping, '@set')) { } 0 0 0
2793 0 $as_array = 1;
2794 } else {
2795 0 $as_array = not($compactArrays);
2796 }
2797
2798 0 ▶ println "12.3.2.1.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2799 0 $self->_add_value($result, $property, $value, as_array => $as_array);
2800
2801 0 ▶ println "12.3.2.1.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2802 0 delete $compactedValue->{$property};
2803 }
2804 }
2805
2806 0 my @keys = keys %$compactedValue;
2807 0 ▶ if (scalar(@keys)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @keys) 0 0 0
2808 0 ▶ println "12.3.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2809 0 ▶ println "12.3.3.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2810 0 my $alias = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, '@reverse', vocab => 1);
2811
2812 0 ▶ println "12.3.3.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2813 0 $result->{$alias} = $compactedValue;
2814 }
2815
2816 0 ▶ println "12.3.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2817 0 next;
2818 } elsif ($expandedProperty eq '@preserve') {
2819 0 ▶ println "12.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2820 0 ▶ println "12.4.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2821 0 my $compactedValue = $self->_6_1_2_compaction($activeCtx, $inverseCtx, $activeProp, $expandedValue, compactArrays => $compactArrays, ordered => $ordered);
2822
2823 0 ▶ unless (ref($expandedValue) eq 'ARRAY' and scalar(@$expandedValue) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $expandedValue eq "ARRAY" and scalar @$expandedValue == 0) 0 0 0
Condition0%0/3
ref $expandedValue eq "ARRAY" and scalar @$expandedValue == 0
!ll&&!rl&&r
000
MC/DC0%0/2
ref $expandedValue eq "ARRAY" and scalar @$expandedValue == 0
ref $expandedValue eq "ARRAY" scalar @$expandedValue == 0
Truth table0%0/3
A and B
A= ref $expandedValue eq "ARRAY"B= scalar @$expandedValue == 0
ABresult
0X0
100
111
2824 0 ▶ println "12.4.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2825 0 $result->{'@preserve'} = $compactedValue;
2826 }
2827 ▶ } elsif ($expandedProperty eq '@index' and $self->_cm_contains($container_mapping, '@index')) {
Condition0%0/3
$expandedProperty eq "\@index" and $self->_cm_contains($container_mapping, "\@index")
!ll&&!rl&&r
000
MC/DC0%0/2
$expandedProperty eq "\@index" and $self->_cm_contains($container_mapping, "\@index")
$expandedProperty eq "\@index" $self->_cm_contains($container_mapping, "\@index")
Truth table0%0/3
A and B
A= $expandedProperty eq "\@index"B= $self->_cm_contains($container_mapping, "\@index")
ABresult
0X0
100
111
2828 0 ▶ println "12.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2829 0 next;
2830 } elsif ($expandedProperty =~ /^@(direction|index|language|value)$/) {
2831 0 ▶ println "12.6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2832 0 ▶ println "12.6.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2833 0 my $alias = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, $expandedProperty, vocab => 1);
2834
2835 0 ▶ println "12.6.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2836 0 $result->{$alias} = $expandedValue;
2837 0 next;
2838 }
2839
2840 0 ▶ if (ref($expandedValue) eq 'ARRAY' and scalar(@$expandedValue) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $expandedValue eq "ARRAY" and scalar @$expandedValue == 0) 0 0 0
Condition0%0/3
ref $expandedValue eq "ARRAY" and scalar @$expandedValue == 0
!ll&&!rl&&r
000
MC/DC0%0/2
ref $expandedValue eq "ARRAY" and scalar @$expandedValue == 0
ref $expandedValue eq "ARRAY" scalar @$expandedValue == 0
Truth table0%0/3
A and B
A= ref $expandedValue eq "ARRAY"B= scalar @$expandedValue == 0
ABresult
0X0
100
111
2841 0 ▶ println "12.7" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2842 0 ▶ println "12.7.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2843 # https://github.com/w3c/json-ld-api/issues/357
2844 0 my $item_active_property = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, $expandedProperty, value => $expandedValue, vocab => 1, 'reverse' => $insideReverse);
2845  
2846 0 ▶ println "12.7.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2847 0 my $tdef = $self->_ctx_term_defn($activeCtx, $item_active_property);
2848 0 my $nest_result;
2849 0 ▶ if (exists $tdef->{'nest_value'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $tdef->{'nest_value'}) { } 0 0 0
2850 0 my $nest_term = $tdef->{'nest_value'};
2851 0 ▶ if ($nest_term ne '@nest') {
Branch: 1 branch
BranchTrueFalseTotal
if ($nest_term ne "\@nest") 0 0 0
2852 0 die 'invalid @nest value';
2853 }
2854 0 ▶ if (not exists $result->{$nest_term}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $result->{$nest_term}) 0 0 0
2855 0 $result->{$nest_term} = {};
2856 }
2857 0 ▶ if (not exists $result->{$nest_term}{$item_active_property}) {
Branch: 2 branches
BranchTrueFalseTotal
if (not exists $result->{$nest_term}{$item_active_property}) { } 0 0 0
elsif (ref $result->{$nest_term}{$item_active_property} ne 'ARRAY') { } 0 0 0
2858 0 $result->{$nest_term}{$item_active_property} = [];
2859 } elsif (ref($result->{$nest_term}{$item_active_property}) ne 'ARRAY') {
2860 0 $result->{$nest_term}{$item_active_property} = [$result->{$nest_term}{$item_active_property}];
2861 }
2862 } else {
2863 0 ▶ println "12.7.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2864 0 ▶ if (not exists $result->{$item_active_property}) {
Branch: 2 branches
BranchTrueFalseTotal
if (not exists $result->{$item_active_property}) { } 0 0 0
elsif (ref $result->{$item_active_property} ne 'ARRAY') { } 0 0 0
2865 0 $result->{$item_active_property} = [];
2866 } elsif (ref($result->{$item_active_property}) ne 'ARRAY') {
2867 0 $result->{$item_active_property} = [$result->{$item_active_property}];
2868 }
2869 }
2870 }
2871
2872 0 ▶ println "12.8" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2873
2874 0 foreach my $expandedItem (@$expandedValue) {
2875 0 ▶ println "12.8.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2876 0 my $item_active_property = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, $expandedProperty, value => $expandedItem, vocab => 1, 'reverse' => $insideReverse);
2877 0 ▶ println(Data::Dumper->Dump([$item_active_property], ['item_active_property'])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2878
2879 0 my $tdef = $self->_ctx_term_defn($activeCtx, $item_active_property);
2880 0 my $nest_result;
2881 0 ▶ if (exists $tdef->{'nest_value'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $tdef->{'nest_value'}) { } 0 0 0
2882 0 ▶ println "12.8.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2883 0 my $nest_term = $tdef->{'nest_value'};
2884 0 ▶ if ($nest_term ne '@nest') {
Branch: 1 branch
BranchTrueFalseTotal
if ($nest_term ne "\@nest") 0 0 0
2885 0 die 'invalid @nest value';
2886 }
2887 0 ▶ $nest_result = $result->{$nest_term} // {};
Condition0%0/2
$result->{$nest_term} // {}
l!l
00
MC/DC0%0/1
$result->{$nest_term} // {}
$result->{$nest_term}
Truth table0%0/2
A
A= $result->{$nest_term}
Aresult
11
00
2888 } else {
2889 0 ▶ println "12.8.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2890 0 $nest_result = $result;
2891 }
2892
2893 0 ▶ println "12.8.4 " . Data::Dumper->Dump([$container_mapping], [qw(container_mapping)]) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2894 0 my $container = undef;
2895 0 my $container_mapping = $tdef->{'container_mapping'};
2896 0 ▶ if (defined $container_mapping) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $container_mapping) 0 0 0
2897 # https://github.com/w3c/json-ld-api/issues/322
2898 0 $container = [grep { $_ ne '@set' } @$container_mapping]; # TODO unfiled issue on this
2899 # $container = (grep { $_ ne '@set' } @$container_mapping)[0];
2900 }
2901
2902 0 ▶ println "12.8.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2903 0 ▶ my $as_array = ($self->_cm_contains($container_mapping, '@set') or $item_active_property eq '@graph' or $item_active_property eq '@list');
Condition0%0/6
$self->_cm_contains($container_mapping, '@set') || $item_active_property eq '@graph' || $item_active_property eq '@list'
l!l&&r!l&&!r
000
$self->_cm_contains($container_mapping, "\@set") or $item_active_property eq "\@graph"
l!l&&r!l&&!r
000
MC/DC0%0/3
$self->_cm_contains($container_mapping, '@set') || $item_active_property eq '@graph' || $item_active_property eq '@list'
$self->_cm_contains($container_mapping, "\@set") $item_active_property eq "\@graph" $item_active_property eq '@list'
Truth table0%0/4
A or B || C
A= $self->_cm_contains($container_mapping, "\@set")B= $item_active_property eq "\@graph"C= $item_active_property eq '@list'
ABCresult
1XX1
01X1
0011
0000
2904
2905 0 ▶ println "12.8.6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2906 my $_element = ((ref($expandedItem) ne 'HASH' or not exists $expandedItem->{'@list'}) and (not($self->_is_graph_object($expandedItem)) or not exists($expandedItem->{'@list'})))
2907 ? $expandedItem
2908 0 ▶ : $expandedItem->{'@list'};
Branch: 1 branch
BranchTrueFalseTotal
(ref $expandedItem ne 'HASH' || !exists $expandedItem->{'@list'}) && !($self->_is_graph_object($expandedItem) && exists $expandedItem->{'@list'}) ? : 0 0 0
Condition0%0/9
ref $expandedItem ne "HASH" || !exists $expandedItem->{"\@list"} and not $self->_is_graph_object($expandedItem) && exists $expandedItem->{"\@list"}
!ll&&!rl&&r
000
ref $expandedItem ne "HASH" or not exists $expandedItem->{"\@list"}
l!l&&r!l&&!r
000
$self->_is_graph_object($expandedItem) && exists $expandedItem->{'@list'}
!ll&&!rl&&r
000
MC/DC0%0/4
ref $expandedItem ne "HASH" || !exists $expandedItem->{"\@list"} and not $self->_is_graph_object($expandedItem) && exists $expandedItem->{"\@list"}
ref $expandedItem ne "HASH" not exists $expandedItem->{"\@list"} $self->_is_graph_object($expandedItem) exists $expandedItem->{'@list'}
Truth table0%0/7
A or not(B) and not(C && D)
A= ref $expandedItem ne "HASH"B= not exists $expandedItem->{"\@list"}C= $self->_is_graph_object($expandedItem)D= exists $expandedItem->{'@list'}
ABCDresult
00XX0
1X110
01110
1X0X1
1X101
010X1
01101
2909 0 my $compactedItem = $self->_6_1_2_compaction($activeCtx, $inverseCtx, $item_active_property, $_element, %args);
2910
2911 0 ▶ if ($self->_is_list_object($expandedItem)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_list_object($expandedItem)) 0 0 0
2912 0 ▶ println "12.8.7" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2913 0 ▶ if (ref($compactedItem) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $compactedItem ne "ARRAY") 0 0 0
2914 0 ▶ println "12.8.7.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2915 0 $compactedItem = [$compactedItem];
2916 }
2917
2918 0 ▶ if (not $self->_cm_contains($container, '@list')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_cm_contains($container, "\@list")) 0 0 0
2919 0 ▶ println "12.8.7.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2920 0 ▶ println "12.8.7.2.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2921 0 my $key = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, '@list', value => $compactedItem);
2922 0 $compactedItem = { $key => $compactedItem };
2923
2924 0 ▶ println "12.8.7.2.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2925 0 ▶ if (exists $expandedItem->{'@index'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $expandedItem->{"\@index"}) 0 0 0
2926 0 my $key = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, '@index');
2927 0 $compactedItem->{ $key } = $expandedItem->{'@index'};
2928 }
2929 }
2930 }
2931
2932 0 ▶ if ($self->_is_graph_object($expandedItem)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->_is_graph_object($expandedItem)) { } 0 0 0
elsif ($self->_cm_contains_any($container, '@language', '@index', '@id', '@type') and not $self->_cm_contains($container, '@graph')) { } 0 0 0
2933 0 println "12.8.8"; # if $debug;
2934 0 ▶ if ($self->_cm_contains($container, '@graph') and $self->_cm_contains($container, '@id')) {
Branch: 4 branches
BranchTrueFalseTotal
if ($self->_cm_contains($container, '@graph') and $self->_cm_contains($container, '@id')) { } 0 0 0
elsif ($self->_cm_contains($container, '@graph') and $self->_cm_contains($container, '@index') and $self->_is_simple_graph_object($expandedItem)) { } 0 0 0
elsif ($container eq '@graph' and $self->_is_simple_graph_object($expandedItem)) { } 0 0 0
elsif ($container ne '@graph') { } 0 0 0
Condition0%0/3
$self->_cm_contains($container, "\@graph") and $self->_cm_contains($container, "\@id")
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_cm_contains($container, "\@graph") and $self->_cm_contains($container, "\@id")
$self->_cm_contains($container, "\@graph") $self->_cm_contains($container, "\@id")
Truth table0%0/3
A and B
A= $self->_cm_contains($container, "\@graph")B= $self->_cm_contains($container, "\@id")
ABresult
0X0
100
111
2935 0 ▶ println "12.8.8.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2936 0 ▶ println "12.8.8.1.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2937 0 ▶ my $map_object = ($nest_result->{$item_active_property} //= {});
Condition0%0/2
$nest_result->{$item_active_property} //= {}
l!l
00
MC/DC0%0/1
$nest_result->{$item_active_property} //= {}
$nest_result->{$item_active_property}
Truth table0%0/2
A
A= $nest_result->{$item_active_property}
Aresult
11
00
2938
2939 0 ▶ println "12.8.8.1.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2940 0 ▶ my $map_key = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, $expandedItem->{'@id'} // '@none', vocab => (not exists $expandedItem->{'@id'}));
Condition0%0/2
$expandedItem->{"\@id"} // "\@none"
l!l
00
MC/DC0%0/1
$expandedItem->{"\@id"} // "\@none"
$expandedItem->{"\@id"}
Truth table0%0/2
A
A= $expandedItem->{"\@id"}
Aresult
11
00
2941
2942 0 ▶ println "12.8.8.1.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2943 0 $self->_add_value($map_object, $map_key, $compactedItem, as_array => $as_array);
2944 ▶ } elsif ($self->_cm_contains($container, '@graph') and $self->_cm_contains($container, '@index') and $self->_is_simple_graph_object($expandedItem)) {
Condition0%0/6
$self->_cm_contains($container, "\@graph") and $self->_cm_contains($container, "\@index") and $self->_is_simple_graph_object($expandedItem)
!ll&&!rl&&r
000
$self->_cm_contains($container, "\@graph") and $self->_cm_contains($container, "\@index")
!ll&&!rl&&r
000
MC/DC0%0/3
$self->_cm_contains($container, "\@graph") and $self->_cm_contains($container, "\@index") and $self->_is_simple_graph_object($expandedItem)
$self->_cm_contains($container, "\@graph") $self->_cm_contains($container, "\@index") $self->_is_simple_graph_object($expandedItem)
Truth table0%0/4
A and B and C
A= $self->_cm_contains($container, "\@graph")B= $self->_cm_contains($container, "\@index")C= $self->_is_simple_graph_object($expandedItem)
ABCresult
0XX0
10X0
1100
1111
2945 0 ▶ println "12.8.8.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2946 0 ▶ println "12.8.8.2.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2947 0 ▶ my $map_object = ($nest_result->{$item_active_property} //= {});
Condition0%0/2
$nest_result->{$item_active_property} //= {}
l!l
00
MC/DC0%0/1
$nest_result->{$item_active_property} //= {}
$nest_result->{$item_active_property}
Truth table0%0/2
A
A= $nest_result->{$item_active_property}
Aresult
11
00
2948
2949 0 ▶ println "12.8.8.2.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2950 0 ▶ my $map_key = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, $expandedItem->{'@index'} // '@none');
Condition0%0/2
$expandedItem->{"\@index"} // "\@none"
l!l
00
MC/DC0%0/1
$expandedItem->{"\@index"} // "\@none"
$expandedItem->{"\@index"}
Truth table0%0/2
A
A= $expandedItem->{"\@index"}
Aresult
11
00
2951  
2952 0 ▶ println "12.8.8.2.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2953 0 $self->_add_value($map_object, $map_key, $compactedItem, as_array => $as_array);
2954 ▶ } elsif ($container eq '@graph' and $self->_is_simple_graph_object($expandedItem)) {
Condition0%0/3
$container eq "\@graph" and $self->_is_simple_graph_object($expandedItem)
!ll&&!rl&&r
000
MC/DC0%0/2
$container eq "\@graph" and $self->_is_simple_graph_object($expandedItem)
$container eq "\@graph" $self->_is_simple_graph_object($expandedItem)
Truth table0%0/3
A and B
A= $container eq "\@graph"B= $self->_is_simple_graph_object($expandedItem)
ABresult
0X0
100
111
2955 0 ▶ println "12.8.8.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2956 0 ▶ if (ref($compactedItem) eq 'ARRAY' and scalar(@$compactedItem) > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $compactedItem eq "ARRAY" and scalar @$compactedItem > 1) 0 0 0
Condition0%0/3
ref $compactedItem eq "ARRAY" and scalar @$compactedItem > 1
!ll&&!rl&&r
000
MC/DC0%0/2
ref $compactedItem eq "ARRAY" and scalar @$compactedItem > 1
ref $compactedItem eq "ARRAY" scalar @$compactedItem > 1
Truth table0%0/3
A and B
A= ref $compactedItem eq "ARRAY"B= scalar @$compactedItem > 1
ABresult
0X0
100
111
2957 0 ▶ println "12.8.8.3.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2958 0 my $k = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, '@included', value => $compactedItem);
2959 0 $compactedItem = {$k => $compactedItem};
2960 }
2961
2962 0 ▶ println "12.8.8.3.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2963 0 $self->_add_value($nest_result, $item_active_property, $compactedItem, as_array => $as_array);
2964 } elsif ($container ne '@graph') {
2965 0 ▶ println "12.8.8.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2966 0 ▶ println "12.8.8.4.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2967 0 my $key = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, '@graph', vocab => 1);
2968 0 $compactedItem = { $key => $compactedItem };
2969
2970 0 ▶ if (exists $expandedItem->{'@id'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $expandedItem->{"\@id"}) 0 0 0
2971 0 ▶ println "12.8.8.4.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2972 0 my $key = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, '@id', vocab => 1);
2973 0 my $value = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, $expandedItem->{'@id'});
2974 0 $compactedItem->{$key} = $value;
2975 }
2976
2977
2978 0 ▶ if (exists $expandedItem->{'@index'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $expandedItem->{"\@index"}) 0 0 0
2979 0 ▶ println "12.8.8.4.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2980 0 my $key = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, '@index', vocab => 1);
2981 0 $compactedItem->{$key} = $expandedItem->{'@index'};
2982 }
2983
2984 0 ▶ println "12.8.8.4.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2985 0 $self->_add_value($nest_result, $item_active_property, $compactedItem, as_array => $as_array);
2986 }
2987 ▶ } elsif ($self->_cm_contains_any($container, '@language', '@index', '@id', '@type') and not $self->_cm_contains($container, '@graph')) {
Condition0%0/3
$self->_cm_contains_any($container, "\@language", "\@index", "\@id", "\@type") and not $self->_cm_contains($container, "\@graph")
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_cm_contains_any($container, "\@language", "\@index", "\@id", "\@type") and not $self->_cm_contains($container, "\@graph")
$self->_cm_contains_any($container, "\@language", "\@index", "\@id", "\@type") not $self->_cm_contains($container, "\@graph")
Truth table0%0/3
A and not(B)
A= $self->_cm_contains_any($container, "\@language", "\@index", "\@id", "\@type")B= not $self->_cm_contains($container, "\@graph")
ABresult
0X0
100
111
2988 # TODO: spec text here is really confused since the type of `container` is scalar: "Otherwise, if container includes @language, @index, @id, or @type and container does not include @graph"
2989 0 ▶ println "12.8.9" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2990 0 ▶ println "12.8.9.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2991 0 ▶ my $map_object = ($nest_result->{$item_active_property} //= {});
Condition0%0/2
$nest_result->{$item_active_property} //= {}
l!l
00
MC/DC0%0/1
$nest_result->{$item_active_property} //= {}
$nest_result->{$item_active_property}
Truth table0%0/2
A
A= $nest_result->{$item_active_property}
Aresult
11
00
2992
2993 0 ▶ println "12.8.9.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
2994 0 my $compaction_value;
2995 0 foreach my $k ('@language', '@index', '@id', '@type') {
2996 0 ▶ $compaction_value = $k if ($self->_cm_contains_any($container, $k));
Branch: 1 branch
BranchTrueFalseTotal
if $self->_cm_contains_any($container, $k) 0 0 0
2997 }
2998 0 my $container_key = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, $compaction_value, vocab => 1);
2999
3000 0 ▶ println "12.8.9.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3001 0 ▶ my $tdef = $self->_ctx_term_defn($activeCtx, $item_active_property) // {};
Condition0%0/2
$self->_ctx_term_defn($activeCtx, $item_active_property) // {}
l!l
00
MC/DC0%0/1
$self->_ctx_term_defn($activeCtx, $item_active_property) // {}
$self->_ctx_term_defn($activeCtx, $item_active_property)
Truth table0%0/2
A
A= $self->_ctx_term_defn($activeCtx, $item_active_property)
Aresult
11
00
3002 0 ▶ my $index_key = $tdef->{'index_mapping'} // '@index';
Condition0%0/2
$tdef->{"index_mapping"} // "\@index"
l!l
00
MC/DC0%0/1
$tdef->{"index_mapping"} // "\@index"
$tdef->{"index_mapping"}
Truth table0%0/2
A
A= $tdef->{"index_mapping"}
Aresult
11
00
3003
3004 0 my $map_key;
3005 0 ▶ if ($self->_cm_contains_any($container, '@language') and exists $expandedItem->{'@value'}) {
Branch: 5 branches
BranchTrueFalseTotal
if ($self->_cm_contains_any($container, '@language') and exists $expandedItem->{'@value'}) { } 0 0 0
elsif ($self->_cm_contains_any($container, '@index') and $index_key eq '@index') { } 0 0 0
elsif ($self->_cm_contains_any($container, '@index') and $index_key ne '@index') { } 0 0 0
elsif ($self->_cm_contains_any($container, '@id')) { } 0 0 0
elsif ($self->_cm_contains_any($container, '@type')) { } 0 0 0
Condition0%0/3
$self->_cm_contains_any($container, "\@language") and exists $expandedItem->{"\@value"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_cm_contains_any($container, "\@language") and exists $expandedItem->{"\@value"}
$self->_cm_contains_any($container, "\@language") exists $expandedItem->{"\@value"}
Truth table0%0/3
A and B
A= $self->_cm_contains_any($container, "\@language")B= exists $expandedItem->{"\@value"}
ABresult
0X0
100
111
3006 0 ▶ println "12.8.9.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3007 0 $compactedItem = $expandedItem->{'@value'};
3008 0 $map_key = $expandedItem->{'@language'};
3009 ▶ } elsif ($self->_cm_contains_any($container, '@index') and $index_key eq '@index') {
Condition0%0/3
$self->_cm_contains_any($container, "\@index") and $index_key eq "\@index"
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_cm_contains_any($container, "\@index") and $index_key eq "\@index"
$self->_cm_contains_any($container, "\@index") $index_key eq "\@index"
Truth table0%0/3
A and B
A= $self->_cm_contains_any($container, "\@index")B= $index_key eq "\@index"
ABresult
0X0
100
111
3010 0 ▶ println "12.8.9.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3011 0 $map_key = $expandedItem->{'@index'};
3012 ▶ } elsif ($self->_cm_contains_any($container, '@index') and $index_key ne '@index') {
Condition0%0/3
$self->_cm_contains_any($container, "\@index") and $index_key ne "\@index"
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_cm_contains_any($container, "\@index") and $index_key ne "\@index"
$self->_cm_contains_any($container, "\@index") $index_key ne "\@index"
Truth table0%0/3
A and B
A= $self->_cm_contains_any($container, "\@index")B= $index_key ne "\@index"
ABresult
0X0
100
111
3013 0 ▶ println "12.8.9.6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3014 my @values = (ref($compactedItem) eq 'ARRAY')
3015 0 ▶ ? @{ $compactedItem->{$container_key} || [] }
Condition0%0/2
$compactedItem->{$container_key} || []
l!l
00
MC/DC0%0/1
$compactedItem->{$container_key} || []
$compactedItem->{$container_key}
Truth table0%0/2
A
A= $compactedItem->{$container_key}
Aresult
11
00
3016 0 ▶ : ($compactedItem->{$container_key});
Branch: 1 branch
BranchTrueFalseTotal
ref $compactedItem eq 'ARRAY' ? : 0 0 0
3017 0 $map_key = shift @values;
3018 0 ▶ if (scalar(@values)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @values) { } 0 0 0
3019 0 $compactedItem->{$container_key} = [@values];
3020 } else {
3021 0 delete $compactedItem->{$container_key};
3022 }
3023 } elsif ($self->_cm_contains_any($container, '@id')) {
3024 0 ▶ println "12.8.9.7" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3025 0 $map_key = delete $compactedItem->{$container_key};
3026 } elsif ($self->_cm_contains_any($container, '@type')) {
3027 0 ▶ println "12.8.9.8" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3028 0 ▶ println "12.8.9.8.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3029 0 ▶ my @values = @{ $compactedItem->{$container_key} || [] };
Condition0%0/2
$compactedItem->{$container_key} || []
l!l
00
MC/DC0%0/1
$compactedItem->{$container_key} || []
$compactedItem->{$container_key}
Truth table0%0/2
A
A= $compactedItem->{$container_key}
Aresult
11
00
3030 0 $map_key = shift @values;
3031
3032 0 ▶ if (scalar(@values)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @values) { } 0 0 0
3033 0 ▶ println "12.8.9.8.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3034 0 $compactedItem->{$container_key} = [@values];
3035 } else {
3036 0 ▶ println "12.8.9.8.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3037 0 delete $compactedItem->{$container_key};
3038 }
3039
3040 0 my @keys = map { $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, $_, vocab => 1) } keys %$compactedItem;
3041 0 ▶ if (scalar(@keys) == 1 and $keys[0] eq '@id') {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @keys == 1 and $keys[0] eq "\@id") 0 0 0
Condition0%0/3
scalar @keys == 1 and $keys[0] eq "\@id"
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @keys == 1 and $keys[0] eq "\@id"
scalar @keys == 1 $keys[0] eq "\@id"
Truth table0%0/3
A and B
A= scalar @keys == 1B= $keys[0] eq "\@id"
ABresult
0X0
100
111
3042 0 ▶ println "12.8.9.8.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3043 0 $compactedItem = $self->_6_1_2_compaction($activeCtx, $inverseCtx, $item_active_property, {'@id' => $expandedItem});
3044 }
3045 }
3046
3047 0 ▶ if (not defined($map_key)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $map_key) 0 0 0
3048 0 ▶ println "12.8.9.9" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3049 0 $map_key = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, '@none', vocab => 1);
3050 }
3051
3052 0 ▶ println "12.8.9.10 adding value to [$map_key]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3053 0 $self->_add_value($map_object, $map_key, $compactedItem, as_array => 1);
3054 } else {
3055 0 ▶ println "12.8.10" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3056 0 ▶ if (not($compactArrays) and $as_array and ref($compactedItem) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (not $compactArrays and $as_array and ref $compactedItem ne "ARRAY") 0 0 0
Condition0%0/6
not $compactArrays and $as_array and ref $compactedItem ne "ARRAY"
!ll&&!rl&&r
000
not $compactArrays and $as_array
!ll&&!rl&&r
000
MC/DC0%0/3
not $compactArrays and $as_array and ref $compactedItem ne "ARRAY"
not $compactArrays $as_array ref $compactedItem ne "ARRAY"
Truth table0%0/4
not(A) and B and C
A= not $compactArraysB= $as_arrayC= ref $compactedItem ne "ARRAY"
ABCresult
0XX0
10X0
1100
1111
3057 0 ▶ println "12.8.10.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3058 0 $compactedItem = [$compactedItem];
3059 }
3060
3061 0 ▶ if (not exists $result->{$item_active_property}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $result->{$item_active_property}) { } 0 0 0
3062 0 ▶ println "12.8.10.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3063 0 $nest_result->{$item_active_property} = $compactedItem;
3064 } else {
3065 0 ▶ println "12.8.10.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3066 0 ▶ if (ref($nest_result->{$item_active_property}) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $nest_result->{$item_active_property} ne "ARRAY") 0 0 0
3067 0 $nest_result->{$item_active_property} = [$nest_result->{$item_active_property}];
3068 }
3069
3070 0 ▶ if (ref($compactedItem) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $compactedItem eq 'ARRAY') { } 0 0 0
3071 0 push(@{$nest_result->{$item_active_property}}, @{ $compactedItem });
3072 } else {
3073 0 push(@{$nest_result->{$item_active_property}}, $compactedItem);
3074 }
3075 }
3076 }
3077 }
3078 0 ▶ println "after this 12 loop body " . Data::Dumper->Dump([$result], [qw(result)]) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3079 }
3080  
3081 0 ▶ println "13 returning " . Data::Dumper->Dump([$result], [qw(result)]) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3082 0 return $result;
3083
3084 }
3085  
3086 0 ▶ sub _6_2_2_iri_compaction {
Subroutine _6_2_2_iri_compaction: not called CC=170 SCAR=102.6
3087 0 my $self = shift;
3088 0 my $activeCtx = shift;
3089 0 my $inverseCtx = shift;
3090 0 my $var = shift;
3091 0 my %args = @_;
3092 0 my $value = $args{'value'};
3093 0 ▶ my $vocab = $args{'vocab'} || 0;
Condition0%0/2
$args{'vocab'} || 0
l!l
00
MC/DC0%0/1
$args{'vocab'} || 0
$args{'vocab'}
Truth table0%0/2
A
A= $args{'vocab'}
Aresult
11
00
3094 0 ▶ my $reverse = $args{'reverse'} || 0;
Condition0%0/2
$args{'reverse'} || 0
l!l
00
MC/DC0%0/1
$args{'reverse'} || 0
$args{'reverse'}
Truth table0%0/2
A
A= $args{'reverse'}
Aresult
11
00
3095 {
3096 0 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.2
3097 0 ▶ println "ENTER =================> _6_2_2_iri_compaction('$var')" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3098 }
3099 0 my $__indent = indent();
3100 # println(Data::Dumper->Dump([$activeCtx], ['activeCtx'])) if $debug;
3101 # println(Data::Dumper->Dump([$inverseCtx], ['inverseCtx'])) if $debug;
3102
3103 0 ▶ unless (defined($var)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $var) 0 0 0
3104 0 ▶ println "1 returning" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3105 0 return;
3106 }
3107
3108 0 ▶ if ($vocab and exists $inverseCtx->{$var}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($vocab and exists $inverseCtx->{$var}) 0 0 0
Condition0%0/3
$vocab and exists $inverseCtx->{$var}
!ll&&!rl&&r
000
MC/DC0%0/2
$vocab and exists $inverseCtx->{$var}
$vocab exists $inverseCtx->{$var}
Truth table0%0/3
A and B
A= $vocabB= exists $inverseCtx->{$var}
ABresult
0X0
100
111
3109 0 ▶ println "2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3110 0 ▶ println "2.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3111 0 my $defaultLanguage;
3112 0 ▶ if (defined $activeCtx->{'default_base_direction'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $activeCtx->{'default_base_direction'}) { } 0 0 0
3113 0 ▶ println "2.1.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3114 0 $defaultLanguage = join('_', $activeCtx->{'@language'}, $activeCtx->{'default_base_direction'});
3115 } else {
3116 0 ▶ println "2.1.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3117 0 ▶ if (exists $activeCtx->{'@language'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $activeCtx->{'@language'}) { } 0 0 0
3118 0 $defaultLanguage = lc($activeCtx->{'@language'});
3119 } else {
3120 0 $defaultLanguage = '@none';
3121 }
3122 }
3123
3124 0 ▶ if (ref($value) eq 'HASH' and exists $value->{'@preserve'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq "HASH" and exists $value->{"\@preserve"}) 0 0 0
Condition0%0/3
ref $value eq "HASH" and exists $value->{"\@preserve"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $value eq "HASH" and exists $value->{"\@preserve"}
ref $value eq "HASH" exists $value->{"\@preserve"}
Truth table0%0/3
A and B
A= ref $value eq "HASH"B= exists $value->{"\@preserve"}
ABresult
0X0
100
111
3125 0 ▶ println "2.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3126 0 $value = $value->{'@preserve'}[0];
3127 }
3128
3129 0 ▶ println "2.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3130 0 my $containers = [];
3131
3132 0 ▶ println "2.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3133 0 my $type_language = '@language';
3134 0 my $type_language_value = '@null';
3135
3136 0 ▶ if (ref($value) eq 'HASH' and exists $value->{'@index'} and not $self->_is_graph_object($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq "HASH" and exists $value->{"\@index"} and not $self->_is_graph_object($value)) 0 0 0
Condition0%0/6
ref $value eq "HASH" and exists $value->{"\@index"} and not $self->_is_graph_object($value)
!ll&&!rl&&r
000
ref $value eq "HASH" and exists $value->{"\@index"}
!ll&&!rl&&r
000
MC/DC0%0/3
ref $value eq "HASH" and exists $value->{"\@index"} and not $self->_is_graph_object($value)
ref $value eq "HASH" exists $value->{"\@index"} not $self->_is_graph_object($value)
Truth table0%0/4
A and B and not(C)
A= ref $value eq "HASH"B= exists $value->{"\@index"}C= not $self->_is_graph_object($value)
ABCresult
0XX0
10X0
1100
1111
3137 0 ▶ println "2.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3138 0 push(@$containers, '@index', '@index@set');
3139 }
3140
3141 0 ▶ if ($reverse) {
Branch: 3 branches
BranchTrueFalseTotal
if ($reverse) { } 0 0 0
elsif ($self->_is_list_object($value)) { } 0 0 0
elsif ($self->_is_graph_object($value)) { } 0 0 0
3142 0 ▶ println "2.6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3143 0 $type_language = '@type';
3144 0 $type_language_value = '@reverse';
3145 0 push(@$containers, '@set');
3146 } elsif ($self->_is_list_object($value)) {
3147 0 ▶ println "2.7" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3148 0 ▶ if (not exists $value->{'@index'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $value->{"\@index"}) 0 0 0
3149 0 ▶ println "2.7.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3150 0 push(@$containers, '@list');
3151 }
3152
3153 0 ▶ println "2.7.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3154 0 my $list = $value->{'@list'};
3155
3156 0 ▶ println "2.7.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3157 0 my $common_type;
3158 my $common_language;
3159 0 ▶ unless (scalar(@$list)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar @$list) 0 0 0
3160 0 $common_language = $defaultLanguage;
3161 }
3162
3163 0 ▶ println "2.7.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3164 0 foreach my $item (@$list) {
3165 0 ▶ println "2.7.4.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3166 0 my $item_language = '@none';
3167 0 my $item_type = '@none';
3168
3169 0 ▶ if (exists $item->{'@value'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $item->{'@value'}) { } 0 0 0
3170 0 ▶ println "2.7.4.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3171 0 ▶ if (exists $item->{'@direction'}) {
Branch: 3 branches
BranchTrueFalseTotal
if (exists $item->{'@direction'}) { } 0 0 0
elsif (exists $item->{'@language'}) { } 0 0 0
elsif (exists $item->{'@type'}) { } 0 0 0
3172 0 ▶ println "2.7.4.2.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3173 0 ▶ $item_language = lc(join('_', $item->{'@language'} // '', $item->{'@direction'}));
Condition0%0/2
$item->{"\@language"} // ""
l!l
00
MC/DC0%0/1
$item->{"\@language"} // ""
$item->{"\@language"}
Truth table0%0/2
A
A= $item->{"\@language"}
Aresult
11
00
3174 } elsif (exists $item->{'@language'}) {
3175 0 ▶ println "2.7.4.2.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3176 0 $item_language = lc($item->{'@language'});
3177 } elsif (exists $item->{'@type'}) {
3178 0 ▶ println "2.7.4.2.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3179 0 $item_type = $item->{'@type'};
3180 } else {
3181 0 ▶ println "2.7.4.2.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3182 0 $item_language = '@null';
3183 }
3184 } else {
3185 0 ▶ println "2.7.4.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3186 0 $item_type = '@id';
3187 }
3188
3189 0 ▶ if (not defined($common_language)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $common_language) { } 0 0 0
elsif ($item_language ne $common_language and exists $item->{'@value'}) { } 0 0 0
3190 0 ▶ println "2.7.4.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3191 0 $common_language = $item_language;
3192 ▶ } elsif ($item_language ne $common_language and exists $item->{'@value'}) {
Condition0%0/3
$item_language ne $common_language and exists $item->{"\@value"}
!ll&&!rl&&r
000
MC/DC0%0/2
$item_language ne $common_language and exists $item->{"\@value"}
$item_language ne $common_language exists $item->{"\@value"}
Truth table0%0/3
A and B
A= $item_language ne $common_languageB= exists $item->{"\@value"}
ABresult
0X0
100
111
3193 0 ▶ println "2.7.4.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3194 0 $common_language = '@none';
3195 }
3196
3197 0 ▶ if (not defined($common_type)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $common_type) { } 0 0 0
elsif ($item_type ne $common_type) { } 0 0 0
3198 0 ▶ println "2.7.4.6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3199 0 $common_type = $item_type;
3200 } elsif ($item_type ne $common_type) {
3201 0 ▶ println "2.7.4.7" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3202 0 $common_type = '@none';
3203 }
3204
3205 0 ▶ if ($common_language eq '@none' and $common_type eq '@none') {
Branch: 1 branch
BranchTrueFalseTotal
if ($common_language eq "\@none" and $common_type eq "\@none") 0 0 0
Condition0%0/3
$common_language eq "\@none" and $common_type eq "\@none"
!ll&&!rl&&r
000
MC/DC0%0/2
$common_language eq "\@none" and $common_type eq "\@none"
$common_language eq "\@none" $common_type eq "\@none"
Truth table0%0/3
A and B
A= $common_language eq "\@none"B= $common_type eq "\@none"
ABresult
0X0
100
111
3206 0 ▶ println "2.7.4.8" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3207 0 last;
3208 }
3209 }
3210
3211 0 ▶ if (not defined($common_language)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $common_language) 0 0 0
3212 0 ▶ println "2.7.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3213 0 $common_language = '@none';
3214 }
3215
3216 0 ▶ if (not defined($common_type)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $common_type) 0 0 0
3217 0 ▶ println "2.7.6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3218 0 $common_type = '@none';
3219 }
3220
3221 0 ▶ if ($common_type ne '@none') {
Branch: 1 branch
BranchTrueFalseTotal
if ($common_type ne '@none') { } 0 0 0
3222 0 ▶ println "2.7.7" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3223 0 $type_language = '@type';
3224 0 $type_language_value = $common_type;
3225 } else {
3226 0 ▶ println "2.7.8" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3227 0 $type_language_value = $common_language;
3228 }
3229
3230 } elsif ($self->_is_graph_object($value)) {
3231 0 ▶ println "2.8" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3232 0 ▶ if (exists $value->{'@index'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $value->{"\@index"}) 0 0 0
3233 0 ▶ println "2.8.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3234 0 push(@$containers, '@graph@index', '@graph@index@set');
3235 }
3236
3237 0 ▶ if (exists $value->{'@id'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $value->{"\@id"}) 0 0 0
3238 0 ▶ println "2.8.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3239 0 push(@$containers, '@graph@id', '@graph@id@set');
3240 }
3241
3242 0 ▶ println "2.8.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3243 0 push(@$containers, '@graph', '@graph@set', '@set');
3244
3245 0 ▶ if (not exists $value->{'@index'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $value->{"\@index"}) 0 0 0
3246 0 ▶ println "2.8.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3247 0 push(@$containers, '@graph@index', '@graph@index@set');
3248 }
3249
3250 0 ▶ if (not exists $value->{'@id'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $value->{"\@id"}) 0 0 0
3251 0 ▶ println "2.8.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3252 0 push(@$containers, '@graph@id', '@graph@id@set');
3253 }
3254  
3255 0 ▶ println "2.8.6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3256 0 push(@$containers, '@index', '@index@set');
3257  
3258 0 ▶ println "2.8.7" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3259 0 $type_language = '@type';
3260 0 $type_language_value = '@id';
3261 } else {
3262 0 ▶ println "2.9" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3263 0 ▶ if ($self->_is_value_object($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_value_object($value)) { } 0 0 0
3264 0 ▶ println "2.9.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3265 0 ▶ if (exists $value->{'@direction'} and not exists $value->{'@index'}) {
Branch: 3 branches
BranchTrueFalseTotal
if (exists $value->{'@direction'} and not exists $value->{'@index'}) { } 0 0 0
elsif (exists $value->{'@language'} and not exists $value->{'@index'}) { } 0 0 0
elsif (exists $value->{'@type'}) { } 0 0 0
Condition0%0/3
exists $value->{"\@direction"} and not exists $value->{"\@index"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $value->{"\@direction"} and not exists $value->{"\@index"}
exists $value->{"\@direction"} not exists $value->{"\@index"}
Truth table0%0/3
A and not(B)
A= exists $value->{"\@direction"}B= not exists $value->{"\@index"}
ABresult
0X0
100
111
3266 0 ▶ println "2.9.1.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3267 0 ▶ $type_language_value = lc(join('_', $value->{'@language'} // '', $value->{'@direction'}));
Condition0%0/2
$value->{"\@language"} // ""
l!l
00
MC/DC0%0/1
$value->{"\@language"} // ""
$value->{"\@language"}
Truth table0%0/2
A
A= $value->{"\@language"}
Aresult
11
00
3268 0 push(@$containers, '@language', '@language@set');
3269 ▶ } elsif (exists $value->{'@language'} and not exists $value->{'@index'}) {
Condition0%0/3
exists $value->{"\@language"} and not exists $value->{"\@index"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $value->{"\@language"} and not exists $value->{"\@index"}
exists $value->{"\@language"} not exists $value->{"\@index"}
Truth table0%0/3
A and not(B)
A= exists $value->{"\@language"}B= not exists $value->{"\@index"}
ABresult
0X0
100
111
3270 0 ▶ println "2.9.1.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3271 0 $type_language_value = $value->{'@language'};
3272 0 push(@$containers, '@language', '@language@set');
3273 } elsif (exists $value->{'@type'}) {
3274 0 ▶ println "2.9.1.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3275 0 $type_language_value = $value->{'@type'};
3276 0 $type_language = '@type';
3277 }
3278 } else {
3279 0 ▶ println "2.9.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3280 0 $type_language = '@type';
3281 0 $type_language_value = '@id';
3282 0 push(@$containers, '@id', '@id@set', '@type', '@set@type');
3283 }
3284
3285 0 ▶ println "2.9.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3286 0 push(@$containers, '@set');
3287 }
3288
3289 0 ▶ println "2.10" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3290 0 push(@$containers, '@none');
3291
3292 # unless (ref($value) eq 'HASH') {
3293 # Carp::cluck "unexpected non-HASH in IRI Compaction: " . Dumper($value);
3294 # }
3295 # if ($self->processing_mode ne 'json-ld-1.0' and not(exists $value->{'@index'})) {
3296 0 ▶ if ($self->processing_mode ne 'json-ld-1.0' and not(ref($value) eq 'HASH' and exists $value->{'@index'})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->processing_mode ne "json-ld-1.0" and not ref $value eq "HASH" && exists $value->{"\@index"}) 0 0 0
Condition0%0/6
$self->processing_mode ne "json-ld-1.0" and not ref $value eq "HASH" && exists $value->{"\@index"}
!ll&&!rl&&r
000
ref $value eq 'HASH' && exists $value->{'@index'}
!ll&&!rl&&r
000
MC/DC0%0/3
$self->processing_mode ne "json-ld-1.0" and not ref $value eq "HASH" && exists $value->{"\@index"}
$self->processing_mode ne "json-ld-1.0" ref $value eq 'HASH' exists $value->{'@index'}
Truth table0%0/4
A and not(B && C)
A= $self->processing_mode ne "json-ld-1.0"B= ref $value eq 'HASH'C= exists $value->{'@index'}
ABCresult
0XX0
1110
10X1
1101
3297 # TODO: spec is missing the ref 'HASH' check
3298 0 ▶ println "2.11" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3299 0 push(@$containers, '@index', '@index@set');
3300 }
3301
3302 0 ▶ my @keys = (ref($value) eq 'HASH') ? keys %$value : ();
Branch: 1 branch
BranchTrueFalseTotal
ref $value eq 'HASH' ? : 0 0 0
3303 0 ▶ if ($self->processing_mode ne 'json-ld-1.0' and scalar(@keys) == 1 and $keys[0] eq '@value') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->processing_mode ne "json-ld-1.0" and scalar @keys == 1 and $keys[0] eq "\@value") 0 0 0
Condition0%0/6
$self->processing_mode ne "json-ld-1.0" and scalar @keys == 1 and $keys[0] eq "\@value"
!ll&&!rl&&r
000
$self->processing_mode ne "json-ld-1.0" and scalar @keys == 1
!ll&&!rl&&r
000
MC/DC0%0/3
$self->processing_mode ne "json-ld-1.0" and scalar @keys == 1 and $keys[0] eq "\@value"
$self->processing_mode ne "json-ld-1.0" scalar @keys == 1 $keys[0] eq "\@value"
Truth table0%0/4
A and B and C
A= $self->processing_mode ne "json-ld-1.0"B= scalar @keys == 1C= $keys[0] eq "\@value"
ABCresult
0XX0
10X0
1100
1111
3304 0 ▶ println "2.12" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3305 0 push(@$containers, '@language', '@language@set');
3306 }
3307
3308 0 ▶ if (not defined($type_language_value)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $type_language_value) 0 0 0
3309 0 ▶ println "2.13" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3310 0 $type_language_value = '@null';
3311 }
3312
3313 0 ▶ println "2.14" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3314 0 my $preferred_values = [];
3315
3316 0 ▶ if ($type_language_value eq '@reverse') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type_language_value eq "\@reverse") 0 0 0
3317 0 ▶ println "2.15" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3318 0 push(@$preferred_values, '@reverse');
3319 }
3320
3321 0 ▶ if (($type_language_value eq '@id' or $type_language_value eq '@reverse') and ref($value) eq 'HASH' and exists $value->{'@id'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type_language_value eq '@id' || $type_language_value eq '@reverse' and ref $value eq 'HASH' and exists $value->{'@id'}) { } 0 0 0
Condition0%0/9
$type_language_value eq "\@id" || $type_language_value eq "\@reverse" and ref $value eq "HASH" and exists $value->{"\@id"}
!ll&&!rl&&r
000
$type_language_value eq "\@id" || $type_language_value eq "\@reverse" and ref $value eq "HASH"
!ll&&!rl&&r
000
$type_language_value eq "\@id" or $type_language_value eq "\@reverse"
l!l&&r!l&&!r
000
MC/DC0%0/4
$type_language_value eq "\@id" || $type_language_value eq "\@reverse" and ref $value eq "HASH" and exists $value->{"\@id"}
$type_language_value eq "\@id" $type_language_value eq "\@reverse" ref $value eq "HASH" exists $value->{"\@id"}
Truth table0%0/7
A or B and C and D
A= $type_language_value eq "\@id"B= $type_language_value eq "\@reverse"C= ref $value eq "HASH"D= exists $value->{"\@id"}
ABCDresult
00XX0
1X0X0
010X0
1X100
01100
1X111
01111
3322 # TODO: spec is missing the ref 'HASH' check
3323 0 ▶ println "2.16" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3324 0 my $compact_iri = $self->_6_2_2_iri_compaction($activeCtx, $activeCtx, $value->{'@id'}, vocab => 1);
3325 0 my $tdef = $self->_ctx_term_defn($activeCtx, $compact_iri);
3326 0 ▶ if ($tdef and $tdef->{'iri_mapping'} eq $value->{'@id'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tdef and $tdef->{'iri_mapping'} eq $value->{'@id'}) { } 0 0 0
Condition0%0/3
$tdef and $tdef->{"iri_mapping"} eq $value->{"\@id"}
!ll&&!rl&&r
000
MC/DC0%0/2
$tdef and $tdef->{"iri_mapping"} eq $value->{"\@id"}
$tdef $tdef->{"iri_mapping"} eq $value->{"\@id"}
Truth table0%0/3
A and B
A= $tdefB= $tdef->{"iri_mapping"} eq $value->{"\@id"}
ABresult
0X0
100
111
3327 0 ▶ println "2.16.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3328 0 push(@$preferred_values, '@vocab', '@id', '@none');
3329 } else {
3330 0 ▶ println "2.16.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3331 0 push(@$preferred_values, '@id', '@vocab', '@none');
3332 }
3333 } else {
3334 0 ▶ println "2.17" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3335 0 push(@$preferred_values, $type_language_value, '@none');
3336 0 ▶ if ($self->_is_list_object($value) and not scalar(@{ $value->{'@list'} })) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_list_object($value) and not scalar @{$value->{"\@list"};}) 0 0 0
Condition0%0/3
$self->_is_list_object($value) and not scalar @{$value->{"\@list"};}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_is_list_object($value) and not scalar @{$value->{"\@list"};}
$self->_is_list_object($value) not scalar @{$value->{"\@list"};}
Truth table0%0/3
A and not(B)
A= $self->_is_list_object($value)B= not scalar @{$value->{"\@list"};}
ABresult
0X0
100
111
3337 # https://github.com/w3c/json-ld-api/issues/345
3338 0 $type_language = '@any';
3339 }
3340 }
3341
3342 0 ▶ println "2.18" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3343 0 push(@$preferred_values, '@any');
3344
3345 0 my @underscored = map { substr($_, 1+index($_, '_')) } grep { /_/ } @$preferred_values;
3346 0 ▶ if (scalar(@underscored)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @underscored) 0 0 0
3347 0 ▶ println "2.19" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3348 0 push(@$preferred_values, @underscored);
3349 }
3350
3351 0 ▶ println "2.20" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3352 0 my $term = $self->_4_4_2_term_selection($inverseCtx, $var, $containers, $type_language, $preferred_values);
3353  
3354 0 ▶ if (defined($term)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $term) 0 0 0
3355 0 ▶ println "2.21 returning: $term" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3356 0 return $term;
3357 }
3358 }
3359
3360 0 ▶ if ($vocab and exists $activeCtx->{'@vocab'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($vocab and exists $activeCtx->{"\@vocab"}) 0 0 0
Condition0%0/3
$vocab and exists $activeCtx->{"\@vocab"}
!ll&&!rl&&r
000
MC/DC0%0/2
$vocab and exists $activeCtx->{"\@vocab"}
$vocab exists $activeCtx->{"\@vocab"}
Truth table0%0/3
A and B
A= $vocabB= exists $activeCtx->{"\@vocab"}
ABresult
0X0
100
111
3361 0 ▶ println "3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3362 0 my $vm = $activeCtx->{'@vocab'};
3363 0 ▶ if (substr($var, 0, length($vm)) eq $vm and length($var) > length($vm)) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($var, 0, length $vm) eq $vm and length $var > length $vm) 0 0 0
Condition0%0/3
substr($var, 0, length $vm) eq $vm and length $var > length $vm
!ll&&!rl&&r
000
MC/DC0%0/2
substr($var, 0, length $vm) eq $vm and length $var > length $vm
substr($var, 0, length $vm) eq $vm length $var > length $vm
Truth table0%0/3
A and B
A= substr($var, 0, length $vm) eq $vmB= length $var > length $vm
ABresult
0X0
100
111
3364 0 ▶ println "3.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3365 0 my $suffix = substr($var, length($vm));
3366 0 my $tdef = $self->_ctx_term_defn($activeCtx, $suffix);
3367 0 ▶ unless ($tdef) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tdef) 0 0 0
3368 0 ▶ println "3.1 returning: $suffix" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3369 0 return $suffix;
3370 }
3371 }
3372 }
3373  
3374 0 ▶ println "4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3375 0 my $compact_iri = undef;
3376
3377 0 ▶ println "5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3378 0 foreach my $term (keys %{ $activeCtx->{terms} }) {
3379 0 ▶ println "5 [$term]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3380 0 my $tdef = $self->_ctx_term_defn($activeCtx, $term);
3381 0 my $iri_mapping = $tdef->{'iri_mapping'};
3382 0 my $iri_is_prefix = _is_prefix_of($iri_mapping, $var);
3383
3384 0 ▶ if (not(defined($tdef)) or (($iri_mapping // '') eq $var) or not($iri_is_prefix) or (not(exists $tdef->{'prefix_flag'}) or not($tdef->{'prefix_flag'}))) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $tdef or ($iri_mapping // "") eq $var or not $iri_is_prefix or not exists $tdef->{"prefix_flag"} && $tdef->{"prefix_flag"}) 0 0 0
Condition0%0/14
not defined $tdef or ($iri_mapping // "") eq $var or not $iri_is_prefix or not exists $tdef->{"prefix_flag"} && $tdef->{"prefix_flag"}
l!l&&r!l&&!r
000
not defined $tdef or ($iri_mapping // "") eq $var or not $iri_is_prefix
l!l&&r!l&&!r
000
not defined $tdef or ($iri_mapping // "") eq $var
l!l&&r!l&&!r
000
$iri_mapping // ""
l!l
00
exists $tdef->{'prefix_flag'} && $tdef->{'prefix_flag'}
!ll&&!rl&&r
000
MC/DC0%0/5
not defined $tdef or ($iri_mapping // "") eq $var or not $iri_is_prefix or not exists $tdef->{"prefix_flag"} && $tdef->{"prefix_flag"}
not defined $tdef $iri_mapping not $iri_is_prefix exists $tdef->{'prefix_flag'} $tdef->{'prefix_flag'}
Truth table0%0/6
not(A) or B or not(C) or not(D && E)
A= not defined $tdefB= $iri_mappingC= not $iri_is_prefixD= exists $tdef->{'prefix_flag'}E= $tdef->{'prefix_flag'}
ABCDEresult
1XXXX1
01XXX1
001XX1
0000X1
000101
000110
3385 0 ▶ println "5.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3386 0 next;
3387 }
3388  
3389 0 ▶ println "5.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3390 0 my $candidate = join(':', $term, substr($var, length($iri_mapping)));
3391
3392 0 ▶ println "5.3 candidate = $candidate" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3393 0 ▶ if (not defined($compact_iri)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $compact_iri) { } 0 0 0
3394 0 ▶ println "5.3a" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3395 0 $compact_iri = $candidate;
3396 } else {
3397 0 my $shorter = (length($candidate) < length($compact_iri));
3398 0 ▶ my $less = ((length($candidate) == length($compact_iri)) and (($candidate cmp $compact_iri) == -1));
Condition0%0/3
length $candidate == length $compact_iri && ($candidate cmp $compact_iri) == -1
!ll&&!rl&&r
000
MC/DC0%0/2
length $candidate == length $compact_iri && ($candidate cmp $compact_iri) == -1
length $candidate == length $compact_iri ($candidate cmp $compact_iri) == -1
Truth table0%0/3
A && B
A= length $candidate == length $compact_iriB= ($candidate cmp $compact_iri) == -1
ABresult
0X0
100
111
3399 0 my $cand_tdef = $self->_ctx_term_defn($activeCtx, $candidate);
3400 0 my $no_tdef = not($cand_tdef);
3401 0 ▶ println "5.3b CANDIDATE: $candidate" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3402 0 ▶ if (($shorter or $less) and $no_tdef) {
Branch: 2 branches
BranchTrueFalseTotal
if ($shorter || $less and $no_tdef) { } 0 0 0
elsif (exists $cand_tdef->{'iri_mapping'} and $cand_tdef->{'iri_mapping'} eq $var and not defined $value) { } 0 0 0
Condition0%0/6
$shorter || $less and $no_tdef
!ll&&!rl&&r
000
$shorter or $less
l!l&&r!l&&!r
000
MC/DC0%0/3
$shorter || $less and $no_tdef
$shorter $less $no_tdef
Truth table0%0/5
A or B and C
A= $shorterB= $lessC= $no_tdef
ABCresult
00X0
1X00
0100
1X11
0111
3403 0 ▶ println "5.3b" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3404 0 $compact_iri = $candidate;
3405 ▶ } elsif (exists $cand_tdef->{'iri_mapping'} and $cand_tdef->{'iri_mapping'} eq $var and not defined($value)) {
Condition0%0/6
exists $cand_tdef->{"iri_mapping"} and $cand_tdef->{"iri_mapping"} eq $var and not defined $value
!ll&&!rl&&r
000
exists $cand_tdef->{"iri_mapping"} and $cand_tdef->{"iri_mapping"} eq $var
!ll&&!rl&&r
000
MC/DC0%0/3
exists $cand_tdef->{"iri_mapping"} and $cand_tdef->{"iri_mapping"} eq $var and not defined $value
exists $cand_tdef->{"iri_mapping"} $cand_tdef->{"iri_mapping"} eq $var not defined $value
Truth table0%0/4
A and B and not(C)
A= exists $cand_tdef->{"iri_mapping"}B= $cand_tdef->{"iri_mapping"} eq $varC= not defined $value
ABCresult
0XX0
10X0
1100
1111
3406 0 ▶ println "5.3c" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3407 0 $compact_iri = $candidate;
3408 }
3409 }
3410 }
3411
3412 0 ▶ if (defined($compact_iri)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $compact_iri) 0 0 0
3413 0 ▶ println "6 returning: $compact_iri" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3414 0 return $compact_iri;
3415 }
3416
3417 0 my $iri = eval { IRI->new($var) };
3418 0 ▶ unless ($@) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($@) 0 0 0
3419 0 my $scheme = $iri->scheme;
3420 0 my $scheme_tdef = $self->_ctx_term_defn($activeCtx, $scheme);
3421 0 ▶ if ($scheme_tdef and $scheme_tdef->{'prefix_flag'} and substr($var, length($scheme)+1, 2) ne '//') {
Branch: 1 branch
BranchTrueFalseTotal
if ($scheme_tdef and $scheme_tdef->{"prefix_flag"} and substr($var, length($scheme) + 1, 2) ne "//") 0 0 0
Condition0%0/6
$scheme_tdef and $scheme_tdef->{"prefix_flag"} and substr($var, length($scheme) + 1, 2) ne "//"
!ll&&!rl&&r
000
$scheme_tdef and $scheme_tdef->{"prefix_flag"}
!ll&&!rl&&r
000
MC/DC0%0/3
$scheme_tdef and $scheme_tdef->{"prefix_flag"} and substr($var, length($scheme) + 1, 2) ne "//"
$scheme_tdef $scheme_tdef->{"prefix_flag"} substr($var, length($scheme) + 1, 2) ne "//"
Truth table0%0/4
A and B and C
A= $scheme_tdefB= $scheme_tdef->{"prefix_flag"}C= substr($var, length($scheme) + 1, 2) ne "//"
ABCresult
0XX0
10X0
1100
1111
3422 0 ▶ println "7" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3423 0 die 'IRI confused with prefix';
3424 }
3425 }
3426  
3427 0 ▶ if (not $vocab) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($vocab) 0 0 0
3428 0 ▶ println "8" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3429 0 ▶ my $base = eval { (exists $activeCtx->{'@base'}) ? IRI->new($activeCtx->{'@base'}) : $self->base_iri };
Branch: 1 branch
BranchTrueFalseTotal
exists $activeCtx->{'@base'} ? : 0 0 0
3430 0 ▶ unless ($@) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($@) 0 0 0
3431 0 eval {
3432 0 my $iri = IRI->new($var);
3433 0 $var = _make_relative_iri($base, $iri);
3434 };
3435 }
3436 }
3437  
3438 0 ▶ println "9 returning: $var" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3439 0 return $var;
3440 }
3441
3442 0 ▶ sub _6_3_value_compaction {
Subroutine _6_3_value_compaction: not called CC=61 SCAR=82.0
3443 0 my $self = shift;
3444 0 my $activeCtx = shift;
3445 0 my $inverseCtx = shift;
3446 0 my $activeProp = shift;
3447 0 my $value = shift;
3448 {
3449 0 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.2
3450 0 ▶ println "ENTER =================> _6_3_value_compaction('$activeProp')" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3451 }
3452 0 my $__indent = indent();
3453 0 ▶ println(Data::Dumper->Dump([$value], [qw(value)])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3454
3455 0 ▶ println "1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3456 0 my $result = clone($value); # https://github.com/w3c/json-ld-api/issues/350
3457
3458 0 ▶ println "2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3459 0 my $tdef = $self->_ctx_term_defn($activeCtx, $activeProp);
3460 my $language = exists $tdef->{'language_mapping'}
3461 ? $tdef->{'language_mapping'}
3462 0 ▶ : $activeCtx->{'@language'};
Branch: 1 branch
BranchTrueFalseTotal
exists $tdef->{'language_mapping'} ? : 0 0 0
3463
3464 0 ▶ println "3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3465 my $direction = exists $tdef->{'direction_mapping'}
3466 ? $tdef->{'direction_mapping'}
3467 0 ▶ : $activeCtx->{'@direction'};
Branch: 1 branch
BranchTrueFalseTotal
exists $tdef->{'direction_mapping'} ? : 0 0 0
3468  
3469 0 ▶ my @keys = grep { $_ ne '@id' and $_ ne '@index' } keys %$value;
Condition0%0/3
$_ ne '@id' && $_ ne '@index'
!ll&&!rl&&r
000
MC/DC0%0/2
$_ ne '@id' && $_ ne '@index'
$_ ne '@id' $_ ne '@index'
Truth table0%0/3
A && B
A= $_ ne '@id'B= $_ ne '@index'
ABresult
0X0
100
111
3470 0 ▶ my $type_mapping = $tdef->{'type_mapping'} // '';
Condition0%0/2
$tdef->{"type_mapping"} // ""
l!l
00
MC/DC0%0/1
$tdef->{"type_mapping"} // ""
$tdef->{"type_mapping"}
Truth table0%0/2
A
A= $tdef->{"type_mapping"}
Aresult
11
00
3471 0 my $container_mapping = $tdef->{'container_mapping'};
3472 0 ▶ if (exists $value->{'@id'} and scalar(@keys) == 0) {
Branch: 4 branches
BranchTrueFalseTotal
if (exists $value->{'@id'} and scalar @keys == 0) { } 0 0 0
elsif (exists $value->{'@type'} and $value->{'@type'} eq $type_mapping) { } 0 0 0
elsif ($type_mapping eq '@none' or exists $value->{'@type'} and $value->{'@type'} ne $type_mapping) { } 0 0 0
elsif (not _is_string($value->{'@value'})) { } 0 0 0
Condition0%0/3
exists $value->{"\@id"} and scalar @keys == 0
!ll&&!rl&&r
000
MC/DC0%0/2
exists $value->{"\@id"} and scalar @keys == 0
exists $value->{"\@id"} scalar @keys == 0
Truth table0%0/3
A and B
A= exists $value->{"\@id"}B= scalar @keys == 0
ABresult
0X0
100
111
3473 0 ▶ println "4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3474 0 ▶ if ($type_mapping eq '@id') {
Branch: 2 branches
BranchTrueFalseTotal
if ($type_mapping eq '@id') { } 0 0 0
elsif ($type_mapping eq '@vocab') { } 0 0 0
3475 0 ▶ println "4.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3476 0 $result = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, $value->{'@id'});
3477 } elsif ($type_mapping eq '@vocab') {
3478 0 ▶ println "4.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3479 0 $result = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, $value->{'@id'}, vocab => 1);
3480 }
3481 ▶ } elsif (exists $value->{'@type'} and $value->{'@type'} eq $type_mapping) {
Condition0%0/3
exists $value->{"\@type"} and $value->{"\@type"} eq $type_mapping
!ll&&!rl&&r
000
MC/DC0%0/2
exists $value->{"\@type"} and $value->{"\@type"} eq $type_mapping
exists $value->{"\@type"} $value->{"\@type"} eq $type_mapping
Truth table0%0/3
A and B
A= exists $value->{"\@type"}B= $value->{"\@type"} eq $type_mapping
ABresult
0X0
100
111
3482 0 ▶ println "5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3483 0 $result = $value->{'@value'};
3484 ▶ } elsif ($type_mapping eq '@none' or (exists $value->{'@type'} and $value->{'@type'} ne $type_mapping)) {
Condition0%0/6
$type_mapping eq "\@none" or exists $value->{"\@type"} and $value->{"\@type"} ne $type_mapping
l!l&&r!l&&!r
000
exists $value->{"\@type"} and $value->{"\@type"} ne $type_mapping
!ll&&!rl&&r
000
MC/DC0%0/3
$type_mapping eq "\@none" or exists $value->{"\@type"} and $value->{"\@type"} ne $type_mapping
$type_mapping eq "\@none" exists $value->{"\@type"} $value->{"\@type"} ne $type_mapping
Truth table0%0/4
A or B and C
A= $type_mapping eq "\@none"B= exists $value->{"\@type"}C= $value->{"\@type"} ne $type_mapping
ABCresult
1XX1
0111
00X0
0100
3485 0 ▶ println "6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3486 0 ▶ if (exists $result->{'@type'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $result->{"\@type"}) 0 0 0
3487 0 ▶ println "6.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3488 0 ▶ my @types = (ref($value->{'@type'}) eq 'ARRAY') ? @{ $value->{'@type'} } : $value->{'@type'};
Branch: 1 branch
BranchTrueFalseTotal
ref $value->{'@type'} eq 'ARRAY' ? : 0 0 0
3489 0 $result->{'@type'} = [ map { $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, $_, vocab => 1) } @types ];
3490 }
3491 } elsif (not _is_string($value->{'@value'})) {
3492 0 ▶ println "7" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3493 0 my @keys = keys %$value;
3494 0 ▶ if (scalar(@keys) == 1 and $keys[0] eq '@value') {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @keys == 1 and $keys[0] eq '@value') { } 0 0 0
elsif (exists $value->{'@index'} and $self->_cm_contains($container_mapping, '@index')) { } 0 0 0
Condition0%0/3
scalar @keys == 1 and $keys[0] eq "\@value"
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @keys == 1 and $keys[0] eq "\@value"
scalar @keys == 1 $keys[0] eq "\@value"
Truth table0%0/3
A and B
A= scalar @keys == 1B= $keys[0] eq "\@value"
ABresult
0X0
100
111
3495 # https://github.com/w3c/json-ld-api/issues/351
3496 0 $result = $value->{'@value'};
3497 ▶ } elsif (exists $value->{'@index'} and $self->_cm_contains($container_mapping, '@index')) {
Condition0%0/3
exists $value->{"\@index"} and $self->_cm_contains($container_mapping, "\@index")
!ll&&!rl&&r
000
MC/DC0%0/2
exists $value->{"\@index"} and $self->_cm_contains($container_mapping, "\@index")
exists $value->{"\@index"} $self->_cm_contains($container_mapping, "\@index")
Truth table0%0/3
A and B
A= exists $value->{"\@index"}B= $self->_cm_contains($container_mapping, "\@index")
ABresult
0X0
100
111
3498 0 ▶ println "7.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3499 0 $result = $value->{'@value'};
3500 }
3501 } else {
3502 # https://github.com/w3c/json-ld-api/issues/313
3503 0 ▶ println "maybe 8" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3504 0 ▶ my $vlang = $value->{'@language'} // '';
Condition0%0/2
$value->{"\@language"} // ""
l!l
00
MC/DC0%0/1
$value->{"\@language"} // ""
$value->{"\@language"}
Truth table0%0/2
A
A= $value->{"\@language"}
Aresult
11
00
3505 0 ▶ my $lang_both_undef = (not(defined($value->{'@language'})) and not(defined($language)));
Condition0%0/3
defined $value->{'@language'} || defined $language
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $value->{'@language'} || defined $language
defined $value->{'@language'} defined $language
Truth table0%0/3
A || B
A= defined $value->{'@language'}B= defined $language
ABresult
1X1
011
000
3506 0 ▶ my $lang_same = ($lang_both_undef or (defined($vlang) and defined($language) and lc($vlang) eq lc($language)));
Condition0%0/9
$lang_both_undef || defined $vlang && defined $language && lc $vlang eq lc $language
l!l&&r!l&&!r
000
defined $vlang and defined $language and lc $vlang eq lc $language
!ll&&!rl&&r
000
defined $vlang and defined $language
!ll&&!rl&&r
000
MC/DC0%0/4
$lang_both_undef || defined $vlang && defined $language && lc $vlang eq lc $language
$lang_both_undef defined $vlang defined $language lc $vlang eq lc $language
Truth table0%0/5
A || B and C and D
A= $lang_both_undefB= defined $vlangC= defined $languageD= lc $vlang eq lc $language
ABCDresult
1XXX1
01111
00XX0
010X0
01100
3507 0 ▶ my $lang_not_present = ((not defined($language)) and (not exists $value->{'@language'}));
Condition0%0/3
defined $language || exists $value->{'@language'}
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $language || exists $value->{'@language'}
defined $language exists $value->{'@language'}
Truth table0%0/3
A || B
A= defined $languageB= exists $value->{'@language'}
ABresult
1X1
011
000
3508 0 my $dir = $value->{'@direction'};
3509 0 ▶ my $dir_both_undef = (not(defined($value->{'@direction'})) and not(defined($direction)));
Condition0%0/3
defined $value->{'@direction'} || defined $direction
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $value->{'@direction'} || defined $direction
defined $value->{'@direction'} defined $direction
Truth table0%0/3
A || B
A= defined $value->{'@direction'}B= defined $direction
ABresult
1X1
011
000
3510 0 ▶ my $dir_same = ($dir_both_undef or ($dir eq $direction));
Condition0%0/3
$dir_both_undef || $dir eq $direction
l!l&&r!l&&!r
000
MC/DC0%0/2
$dir_both_undef || $dir eq $direction
$dir_both_undef $dir eq $direction
Truth table0%0/3
A || B
A= $dir_both_undefB= $dir eq $direction
ABresult
1X1
011
000
3511 0 ▶ my $dir_not_present = ((not defined($direction)) and (not exists $value->{'@direction'}));
Condition0%0/3
defined $direction || exists $value->{'@direction'}
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $direction || exists $value->{'@direction'}
defined $direction exists $value->{'@direction'}
Truth table0%0/3
A || B
A= defined $directionB= exists $value->{'@direction'}
ABresult
1X1
011
000
3512
3513 # if (($lang_same or $lang_not_present) and ($dir_same or $dir_not_present)) {
3514 # println "8" if $debug;
3515 # if ((exists $value->{'@index'} and $self->_cm_contains($container_mapping, '@index')) or not exists $value->{'@index'}) {
3516 # println "8.1" if $debug;
3517 # $result = $value->{'@value'};
3518 # }
3519 # }
3520
3521 my $lang_cmp_1 = (defined($language))
3522 ? lc($value->{'@language'}) eq $language
3523 0 ▶ : not exists($value->{'@language'});
Branch: 1 branch
BranchTrueFalseTotal
defined $language ? : 0 0 0
3524 my $dir_cmp_1 = (defined($direction))
3525 ? $value->{'@direction'} eq $direction
3526 0 ▶ : not exists($value->{'@direction'});
Branch: 1 branch
BranchTrueFalseTotal
defined $direction ? : 0 0 0
3527 0 ▶ if ($lang_cmp_1 and $dir_cmp_1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lang_cmp_1 and $dir_cmp_1) 0 0 0
Condition0%0/3
$lang_cmp_1 and $dir_cmp_1
!ll&&!rl&&r
000
MC/DC0%0/2
$lang_cmp_1 and $dir_cmp_1
$lang_cmp_1 $dir_cmp_1
Truth table0%0/3
A and B
A= $lang_cmp_1B= $dir_cmp_1
ABresult
0X0
100
111
3528 0 ▶ println "8" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3529 0 ▶ if ((exists $value->{'@index'} and $self->_cm_contains($container_mapping, '@index')) or not exists $value->{'@index'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $value->{"\@index"} and $self->_cm_contains($container_mapping, "\@index") or not exists $value->{"\@index"}) 0 0 0
Condition0%0/6
exists $value->{"\@index"} and $self->_cm_contains($container_mapping, "\@index") or not exists $value->{"\@index"}
l!l&&r!l&&!r
000
exists $value->{"\@index"} and $self->_cm_contains($container_mapping, "\@index")
!ll&&!rl&&r
000
MC/DC0%0/3
exists $value->{"\@index"} and $self->_cm_contains($container_mapping, "\@index") or not exists $value->{"\@index"}
exists $value->{"\@index"} $self->_cm_contains($container_mapping, "\@index") not exists $value->{"\@index"}
Truth table0%0/5
A and B or not(C)
A= exists $value->{"\@index"}B= $self->_cm_contains($container_mapping, "\@index")C= not exists $value->{"\@index"}
ABCresult
11X1
0X11
1011
0X00
1000
3530 0 ▶ println "8.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3531 0 $result = $value->{'@value'};
3532 }
3533 }
3534
3535 0 ▶ println "not 8" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3536 0 ▶ println(Data::Dumper->Dump([$lang_cmp_1, $language, $dir_cmp_1, $direction, $value], [qw(lang_cmp_1 language dir_cmp_1 direction value)])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3537 }
3538  
3539 0 ▶ if (ref($result) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $result eq "HASH") 0 0 0
3540 0 ▶ println "9" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3541 0 my @keys = keys %$result;
3542 0 foreach my $k (@keys) {
3543 0 my $__indent = indent();
3544 0 ▶ println "----------------" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3545 0 ▶ println "9 [$k]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3546 0 my $ck = $self->_6_2_2_iri_compaction($activeCtx, $inverseCtx, $k, vocab => 1);
3547 0 $result->{$ck} = delete $result->{$k};
3548 }
3549 }
3550
3551 0 ▶ println "10" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3552 0 return $result;
3553 }
3554
3555 0 ▶ sub _7_1_2_flattening {
Subroutine _7_1_2_flattening: not called CC=2 SCAR=17.9
3556 0 my $self = shift;
3557 0 my $element = shift;
3558 0 my $context = shift;
3559 0 ▶ my $ordered = shift // 0;
Condition0%0/2
shift() // 0
l!l
00
MC/DC0%0/1
shift() // 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
3560 0 die;
3561 }
3562  
3563 0 ▶ sub _7_2_2_nodemap_generation {
Subroutine _7_2_2_nodemap_generation: not called CC=90 SCAR=89.8
3564 0 ▶ println "ENTER =================> _7_2_2_nodemap_generation" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3565 0 my $__indent = indent();
3566 0 my $self = shift;
3567 0 my $element = shift;
3568 0 my $map = shift;
3569 0 ▶ my $activeGraph = shift // '@default';
Condition0%0/2
shift() // "\@default"
l!l
00
MC/DC0%0/1
shift() // "\@default"
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
3570 0 ▶ println(Data::Dumper->Dump([$activeGraph], [qw(activeGraph)])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3571 0 ▶ println(Data::Dumper->Dump([$element], [qw(element)])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3572 0 my $activeSubject = shift;
3573 0 my $activeProp = shift;
3574 0 my $list = shift;
3575
3576 0 ▶ println "1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3577 0 ▶ if (ref($element) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $element eq "ARRAY") 0 0 0
3578 0 foreach my $item (@$element) {
3579 0 $self->_7_2_2_nodemap_generation($item, $map, $activeGraph, $activeSubject, $activeProp, $list);
3580 }
3581 0 return;
3582 }
3583
3584 0 ▶ println "2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3585 0 ▶ my $graph = ($map->{$activeGraph} ||= {});
Condition0%0/2
$map->{$activeGraph} ||= {}
l!l
00
MC/DC0%0/1
$map->{$activeGraph} ||= {}
$map->{$activeGraph}
Truth table0%0/2
A
A= $map->{$activeGraph}
Aresult
11
00
3586 0 my $node;
3587 my $subjectNode;
3588 0 ▶ if (not defined($activeSubject)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $activeSubject) { } 0 0 0
3589 0 $node = undef;
3590 } else {
3591 0 $subjectNode = $graph->{$activeSubject};
3592 }
3593
3594 0 ▶ unless (ref($element) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $element eq "HASH") 0 0 0
3595 0 Carp::cluck 'element is not a HASH';
3596 }
3597
3598 0 ▶ if (exists $element->{'@type'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $element->{"\@type"}) 0 0 0
3599 0 ▶ println "3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3600 # https://github.com/w3c/json-ld-api/issues/276
3601 0 ▶ if (ref($element) and ref($element) ne 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $element and ref $element ne "HASH") 0 0 0
Condition0%0/3
ref $element and ref $element ne "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $element and ref $element ne "HASH"
ref $element ref $element ne "HASH"
Truth table0%0/3
A and B
A= ref $elementB= ref $element ne "HASH"
ABresult
0X0
100
111
3602 0 Carp::cluck 'element is not a HASH';
3603 }
3604 0 ▶ if (ref($element->{'@type'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $element->{'@type'}) { } 0 0 0
3605 0 foreach my $i (0 .. $#{ $element->{'@type'} }) {
3606 0 my $item = $element->{'@type'}[$i];
3607 0 ▶ if ($item =~ /^_:/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item =~ /^_:/u) 0 0 0
3608 0 ▶ println "3.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3609 0 $element->{'@type'}[$i] = $self->_7_4_2_generate_blank_node_ident($item);
3610 }
3611 }
3612 } else {
3613 0 ▶ if ($element->{'@type'} =~ /^_:/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($element->{"\@type"} =~ /^_:/u) 0 0 0
3614 0 $element->{'@type'} = $self->_7_4_2_generate_blank_node_ident($element->{'@type'});
3615 }
3616 }
3617 }
3618
3619 0 my $j = JSON->new()->canonical(1);
3620 0 ▶ if (exists $element->{'@value'}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $element->{'@value'}) { } 0 0 0
elsif (exists $element->{'@list'}) { } 0 0 0
3621 0 ▶ println "4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3622 0 ▶ if (not defined($list)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $list) { } 0 0 0
3623 0 ▶ println "4.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3624 2 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
3625 0 ▶ if (not exists $subjectNode->{$activeProp}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $subjectNode->{$activeProp}) { } 0 0 0
3626 0 ▶ println "4.1.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3627 0 $subjectNode->{$activeProp} = [$element];
3628 } else {
3629 0 ▶ println "4.1.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3630 0 my $je = $j->encode($element);
3631 0 ▶ my $exists = any { $j->encode($_) eq $je } @{ $subjectNode->{$activeProp} };
Subroutine __ANON__: not called CC=1 SCAR=6.9
3632 0 ▶ unless ($exists) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($exists) 0 0 0
3633 0 push(@{ $subjectNode->{$activeProp} }, $element);
3634 }
3635 }
3636 } else {
3637 0 ▶ println "4.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3638 0 push(@{ $list->{'@list'} }, $element);
3639 }
3640 } elsif (exists $element->{'@list'}) {
3641 0 ▶ println "5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3642 0 ▶ println "5.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3643 0 my $result = {'@list' => []};
3644
3645 0 ▶ println "5.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3646 0 $self->_7_2_2_nodemap_generation($element->{'@list'}, $map, $activeGraph, $activeSubject, $activeProp, $result);
3647
3648 0 ▶ if (not defined($list)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $list) { } 0 0 0
3649 0 ▶ println "5.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3650 0 ▶ println(Data::Dumper->Dump([$result], [qw(result)])) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3651 0 push(@{ $subjectNode->{$activeProp} }, $result);
3652 } else {
3653 0 ▶ println "5.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3654 0 push(@{ $list->{'@list'} }, $result);
3655 }
3656 } else {
3657 0 ▶ println "6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3658 0 my $id;
3659 0 ▶ if (exists $element->{'@id'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $element->{'@id'}) { } 0 0 0
3660 0 ▶ println "6.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3661 0 $id = delete $element->{'@id'};
3662 0 ▶ if ($id =~ /^_:/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($id =~ /^_:/u) 0 0 0
3663 0 $id = $self->_7_4_2_generate_blank_node_ident($id);
3664 }
3665 } else {
3666 0 ▶ println "6.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3667 0 $id = $self->_7_4_2_generate_blank_node_ident();
3668 }
3669
3670 0 ▶ unless (exists $graph->{$id}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $graph->{$id}) 0 0 0
3671 0 ▶ println "6.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3672 0 $graph->{$id} = { '@id' => $id };
3673 }
3674
3675 0 ▶ println "6.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3676 0 $node = $graph->{$id};
3677
3678 0 ▶ if (ref($activeSubject) eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $activeSubject eq 'HASH') { } 0 0 0
elsif (defined $activeProp) { } 0 0 0
3679 0 ▶ println "6.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3680 0 ▶ if (not exists $node->{$activeProp}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $node->{$activeProp}) { } 0 0 0
3681 0 ▶ println "6.5.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3682 0 $node->{$activeProp} = [$activeSubject];
3683 } else {
3684 0 ▶ println "6.5.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3685 0 my $je = $j->encode($activeSubject);
3686 0 ▶ my $exists = any { $j->encode($_) eq $je } @{ $node->{$activeProp} };
Subroutine __ANON__: not called CC=1 SCAR=6.9
3687 0 ▶ unless ($exists) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($exists) 0 0 0
3688 0 push(@{ $node->{$activeProp} }, $activeSubject);
3689 }
3690 }
3691 } elsif (defined($activeProp)) {
3692 0 ▶ println "6.6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3693 0 ▶ println "6.6.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3694 0 my $reference = { '@id' => $id };
3695
3696 0 ▶ if (not defined($list)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $list) { } 0 0 0
3697 0 ▶ println "6.6.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3698 0 ▶ if (not exists $subjectNode->{$activeProp}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $subjectNode->{$activeProp}) { } 0 0 0
3699 0 ▶ println "6.6.2.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3700 0 $subjectNode->{$activeProp} = [$reference];
3701 } else {
3702 0 ▶ println "6.6.2.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3703 0 my $je = $j->encode($reference);
3704 0 ▶ my $exists = any { $j->encode($_) eq $je } @{ $subjectNode->{$activeProp} };
Subroutine __ANON__: not called CC=1 SCAR=6.9
3705 0 ▶ unless ($exists) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($exists) 0 0 0
3706 0 push(@{ $subjectNode->{$activeProp} }, $reference);
3707 }
3708 }
3709 } else {
3710 0 push(@{ $list->{'@list'} }, $reference);
3711 }
3712 }
3713
3714 0 ▶ if (exists $element->{'@type'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $element->{"\@type"}) 0 0 0
3715 0 ▶ println "6.7" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3716 0 my %exists = map { $_ => 1 } @{ $node->{'@type'} };
3717 0 push(@{ $node->{'@type'} }, grep { not exists $exists{$_} }@{ $element->{'@type'} });
3718 0 delete $element->{'@type'};
3719 }
3720
3721 0 ▶ if (exists $element->{'@index'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $element->{"\@index"}) 0 0 0
3722 0 ▶ println "6.8" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3723 0 ▶ println "6.8 TODO check if element has a pre-existing value" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3724 0 $node->{'@index'} = delete $element->{'@index'};
3725 }
3726  
3727 0 ▶ if (exists $element->{'@reverse'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $element->{"\@reverse"}) 0 0 0
3728 0 ▶ println "6.9" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3729 0 ▶ println "6.9.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3730 0 my $referenced_node = { '@id' => $id };
3731
3732 0 ▶ println "6.9.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3733 0 my $reverse_map = $element->{'@reverse'};
3734
3735 0 ▶ println "6.9.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3736 0 foreach my $property (keys %$reverse_map) {
3737 0 ▶ println "6.9.3 [$property]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3738 0 my $values = $reverse_map->{$property};
3739
3740 0 ▶ println "6.9.3.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3741 0 foreach my $value (@$values) {
3742 0 ▶ println "6.9.3.1.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3743 0 $self->_7_2_2_nodemap_generation($value, $map, $activeGraph, $referenced_node, $property); # TODO: need to pass $list ?
3744 }
3745 }
3746  
3747 0 ▶ println "6.9.3.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3748 0 delete $element->{'@reverse'};
3749 }
3750
3751 0 ▶ if (exists $element->{'@graph'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $element->{"\@graph"}) 0 0 0
3752 0 ▶ println "6.10" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3753 0 $self->_7_2_2_nodemap_generation($element->{'@graph'}, $map, $id);
3754 0 delete $element->{'@graph'};
3755 }
3756
3757 0 ▶ if (exists $element->{'@included'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $element->{"\@included"}) 0 0 0
3758 0 ▶ println "6.11" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3759 0 $self->_7_2_2_nodemap_generation($element->{'@included'}, $map, $activeGraph);
3760 0 delete $element->{'@included'};
3761 }
3762  
3763 0 ▶ println "6.12" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3764 0 foreach my $property (sort keys %$element) {
3765 0 ▶ println '----------------' if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3766 0 ▶ println "6.12 [$property]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3767 0 my $value = $element->{$property};
3768 0 ▶ if ($property =~ /^_:/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($property =~ /^_:/u) 0 0 0
3769 0 ▶ println "6.12.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3770 0 $property = $self->_7_4_2_generate_blank_node_ident($property);
3771 }
3772 0 ▶ unless (exists $node->{$property}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $node->{$property}) 0 0 0
3773 0 ▶ println "6.12.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3774 0 $node->{$property} = [];
3775 }
3776
3777 0 ▶ println "6.12.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3778 0 $self->_7_2_2_nodemap_generation($value, $map, $activeGraph, $id, $property);
3779 }
3780 }
3781 }
3782  
3783 0 ▶ sub _7_4_2_generate_blank_node_ident {
Subroutine _7_4_2_generate_blank_node_ident: not called CC=9 SCAR=45.0
3784 0 ▶ println "ENTER =================> _7_4_2_generate_blank_node_ident" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3785 0 my $__indent = indent();
3786 0 my $self = shift;
3787 0 my $ident = shift;
3788 0 ▶ if (defined($ident) and exists $self->identifier_map->{$ident}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ident and exists $self->identifier_map->{$ident}) 0 0 0
Condition0%0/3
defined $ident and exists $self->identifier_map->{$ident}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ident and exists $self->identifier_map->{$ident}
defined $ident exists $self->identifier_map->{$ident}
Truth table0%0/3
A and B
A= defined $identB= exists $self->identifier_map->{$ident}
ABresult
0X0
100
111
3789 0 ▶ println "1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3790 0 return $self->identifier_map->{$ident};
3791 }
3792
3793 0 ▶ println "2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3794 0 my $nid = $self->next_identifier_id;
3795 0 $self->next_identifier_id($nid + 1);
3796 0 my $bid = "_:b$nid";
3797  
3798 0 ▶ if (defined($ident)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ident) 0 0 0
3799 0 ▶ println "3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3800 0 $self->identifier_map->{$ident} = $bid;
3801 }
3802
3803 0 ▶ println "4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3804 0 return $bid;
3805 }
3806  
3807 0 ▶ sub _8_1_2_to_rdf {
Subroutine _8_1_2_to_rdf: not called CC=39 SCAR=73.5
3808 0 ▶ println "ENTER =================> _8_1_2_to_rdf" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3809 0 my $__indent = indent();
3810 0 my $self = shift;
3811 0 my $map = shift;
3812 0 my $dataset = shift;
3813 0 my %args = @_;
3814 0 ▶ my $produce_genrdf = $args{'produceGeneralizedRdf'} || 0;
Condition0%0/2
$args{'produceGeneralizedRdf'} || 0
l!l
00
MC/DC0%0/1
$args{'produceGeneralizedRdf'} || 0
$args{'produceGeneralizedRdf'}
Truth table0%0/2
A
A= $args{'produceGeneralizedRdf'}
Aresult
11
00
3815 0 my $rdfDirection = $args{'rdfDirection'};
3816
3817 0 ▶ println "1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3818 0 for my $graphName (keys %$map) {
3819 0 my $__indent = indent();
3820 0 ▶ println '----------------------' if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3821 0 ▶ println "1 [$graphName]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3822 0 my $graph = $map->{$graphName};
3823  
3824 0 ▶ unless ($self->_is_well_formed_graphname($graphName)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_is_well_formed_graphname($graphName)) 0 0 0
3825 0 ▶ println "1.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3826 0 next;
3827 }
3828
3829 0 my $graph_iri;
3830 0 ▶ println "1.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3831 0 ▶ if ($graphName eq '@default') {
Branch: 1 branch
BranchTrueFalseTotal
if ($graphName eq '@default') { } 0 0 0
3832 0 $graph_iri = $self->default_graph();
3833 } else {
3834 0 $graph_iri = $self->new_graphname($graphName);
3835 }
3836
3837 0 ▶ println "1.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3838 0 foreach my $subject (sort keys %$graph) {
3839 0 my $__indent = indent();
3840 0 ▶ println '----------------------' if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3841 0 ▶ println "1.3 [$subject]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3842 0 my $node = $graph->{$subject};
3843  
3844 0 ▶ println "1.3.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3845 0 foreach my $property (sort keys %$node) {
3846 0 ▶ println "1.3.2 [$property]" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3847 0 my $values = $node->{$property};
3848 0 ▶ println(Dumper($property, $node)) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3849 0 ▶ if ($property eq '@type') {
Branch: 4 branches
BranchTrueFalseTotal
if ($property eq '@type') { } 0 0 0
elsif (exists $keywords{$property}) { } 0 0 0
elsif ($property =~ /^_:(.*)$/u and not $produce_genrdf) { } 0 0 0
elsif (not $self->_is_well_formed_iri($property)) { } 0 0 0
3850 0 ▶ println "1.3.2.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3851 0 foreach my $type (@$values) {
3852 0 ▶ if ($self->_is_well_formed_graph_node($type)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_well_formed_graph_node($type)) 0 0 0
3853 0 my $q = $self->new_quad(
3854 $self->new_graph_node($subject),
3855 $self->new_iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
3856 $self->new_graph_node($type),
3857 $graph_iri
3858 );
3859 0 $self->add_quad($q, $dataset);
3860 }
3861 }
3862 } elsif (exists $keywords{$property}) {
3863 0 ▶ println "1.3.2.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3864 0 next;
3865 ▶ } elsif ($property =~ /^_:(.*)$/ and not $produce_genrdf) {
Condition0%0/3
$property =~ /^_:(.*)$/u and not $produce_genrdf
!ll&&!rl&&r
000
MC/DC0%0/2
$property =~ /^_:(.*)$/u and not $produce_genrdf
$property =~ /^_:(.*)$/u not $produce_genrdf
Truth table0%0/3
A and not(B)
A= $property =~ /^_:(.*)$/uB= not $produce_genrdf
ABresult
0X0
100
111
3866 0 ▶ println "1.3.2.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3867 0 next;
3868 } elsif (not $self->_is_well_formed_iri($property)) {
3869 0 ▶ println "1.3.2.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3870 0 next;
3871 } else {
3872 0 ▶ println "1.3.2.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3873 0 foreach my $item (@$values) {
3874 0 ▶ println "1.3.2.5.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3875 0 ▶ println "1.3.2.5.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3876 0 my $list_triples = [];
3877 0 my $s = $self->_8_2_2_object_to_rdf({'@id' => $subject}, $list_triples);
3878 0 my $o = $self->_8_2_2_object_to_rdf($item, $list_triples);
3879 0 ▶ if ($o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o) 0 0 0
3880 0 ▶ println "1.3.2.5.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3881 0 my $q = $self->new_quad(
3882 $s,
3883 $self->new_iri($property),
3884 $o,
3885 $graph_iri
3886 );
3887 0 ▶ if ($q) {
Branch: 1 branch
BranchTrueFalseTotal
if ($q) 0 0 0
3888 0 $self->add_quad($q, $dataset);
3889 }
3890 }
3891 0 ▶ println "1.3.2.5.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3892 0 foreach my $t (@$list_triples) {
3893 0 my $q = $t->as_quad($graph_iri);
3894 0 $self->add_quad($q, $dataset);
3895 }
3896 }
3897 }
3898 }
3899 }
3900 }
3901 }
3902  
3903 0 ▶ sub _8_2_2_object_to_rdf {
Subroutine _8_2_2_object_to_rdf: not called CC=61 SCAR=82.4
3904 0 ▶ println "ENTER =================> _8_2_2_object_to_rdf" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3905 0 my $__indent = indent();
3906 0 my $self = shift;
3907 0 my $item = shift;
3908 0 my $list_triples = shift;
3909 0 ▶ if ($self->_is_node_object($item) and not $self->_is_well_formed_graph_node($item->{'@id'})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_node_object($item) and not $self->_is_well_formed_graph_node($item->{"\@id"})) 0 0 0
Condition0%0/3
$self->_is_node_object($item) and not $self->_is_well_formed_graph_node($item->{"\@id"})
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_is_node_object($item) and not $self->_is_well_formed_graph_node($item->{"\@id"})
$self->_is_node_object($item) not $self->_is_well_formed_graph_node($item->{"\@id"})
Truth table0%0/3
A and not(B)
A= $self->_is_node_object($item)B= not $self->_is_well_formed_graph_node($item->{"\@id"})
ABresult
0X0
100
111
3910 0 ▶ println "1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3911 0 ▶ println "*** _8_2_2_object_to_rdf RETURNING NULL on " . Data::Dumper->Dump([$item], ['item']) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3912 0 return;
3913 }
3914  
3915 0 ▶ if ($self->_is_node_object($item)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_node_object($item)) 0 0 0
3916 0 my $value = $item->{'@id'};
3917 0 ▶ println "2 $value" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3918 0 ▶ if ($value =~ /^_:(.*)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^_:(.*)$/u) { } 0 0 0
3919 0 return $self->new_blank($1);
3920 } else {
3921 0 return $self->new_iri($value);
3922 }
3923 }
3924
3925 0 ▶ if ($self->_is_list_object($item)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_is_list_object($item)) 0 0 0
3926 0 ▶ println "3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3927 0 return $self->_8_3_2_list_conversion($item->{'@list'}, $list_triples);
3928 }
3929
3930 0 ▶ println "4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3931 0 my $value = $item->{'@value'};
3932
3933 0 ▶ println "5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3934 0 my $datatype = $item->{'@type'};
3935  
3936 0 ▶ if (defined($datatype) and not $self->_is_well_formed_datatype($datatype)) { # https://github.com/w3c/json-ld-api/issues/282 ; https://github.com/w3c/json-ld-api/issues/298
Branch: 1 branch
BranchTrueFalseTotal
if (defined $datatype and not $self->_is_well_formed_datatype($datatype)) 0 0 0
Condition0%0/3
defined $datatype and not $self->_is_well_formed_datatype($datatype)
!ll&&!rl&&r
000
MC/DC0%0/2
defined $datatype and not $self->_is_well_formed_datatype($datatype)
defined $datatype not $self->_is_well_formed_datatype($datatype)
Truth table0%0/3
A and not(B)
A= defined $datatypeB= not $self->_is_well_formed_datatype($datatype)
ABresult
0X0
100
111
3937 0 ▶ println "6" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3938 0 ▶ println "*** _8_2_2_object_to_rdf RETURNING NULL" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3939 0 return;
3940 }
3941
3942 0 ▶ if (exists $item->{'@language'} and not $self->_is_well_formed_language($item->{'@language'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $item->{"\@language"} and not $self->_is_well_formed_language($item->{"\@language"})) 0 0 0
Condition0%0/3
exists $item->{"\@language"} and not $self->_is_well_formed_language($item->{"\@language"})
!ll&&!rl&&r
000
MC/DC0%0/2
exists $item->{"\@language"} and not $self->_is_well_formed_language($item->{"\@language"})
exists $item->{"\@language"} not $self->_is_well_formed_language($item->{"\@language"})
Truth table0%0/3
A and not(B)
A= exists $item->{"\@language"}B= not $self->_is_well_formed_language($item->{"\@language"})
ABresult
0X0
100
111
3943 0 ▶ println "7" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3944 0 ▶ println "*** _8_2_2_object_to_rdf RETURNING NULL" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3945 0 return;
3946 }
3947
3948 0 ▶ if (defined($datatype) and $datatype eq '@json') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $datatype and $datatype eq "\@json") 0 0 0
Condition0%0/3
defined $datatype and $datatype eq "\@json"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $datatype and $datatype eq "\@json"
defined $datatype $datatype eq "\@json"
Truth table0%0/3
A and B
A= defined $datatypeB= $datatype eq "\@json"
ABresult
0X0
100
111
3949 0 ▶ println "8" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3950 0 $value = decode_utf8(JSON->new->utf8->allow_nonref->canonical(1)->encode($value));
3951 0 $datatype = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#JSON';
3952 }
3953
3954 0 ▶ if (JSON::is_bool($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&JSON::is_bool($value)) 0 0 0
3955 0 ▶ println "9" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3956 0 ▶ $value = $value ? 'true' : 'false';
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 0 0 0
3957 0 ▶ unless ($datatype) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($datatype) 0 0 0
3958 0 $datatype = 'http://www.w3.org/2001/XMLSchema#boolean';
3959 }
3960 }
3961
3962 0 my $is_num = _is_numeric($value);
3963 0 my $is_int = _is_integer($value);
3964 0 ▶ my $int_repr = $is_num ? sprintf('%011.0f', $value) : '';
Branch: 1 branch
BranchTrueFalseTotal
$is_num ? : 0 0 0
3965 0 ▶ my $double_or_not_int = (not($is_int) or (defined($datatype) and $datatype eq 'http://www.w3.org/2001/XMLSchema#double'));
Condition0%0/6
!$is_int || defined $datatype && $datatype eq 'http://www.w3.org/2001/XMLSchema#double'
l!l&&r!l&&!r
000
defined $datatype and $datatype eq "http://www.w3.org/2001/XMLSchema#double"
!ll&&!rl&&r
000
MC/DC0%0/3
!$is_int || defined $datatype && $datatype eq 'http://www.w3.org/2001/XMLSchema#double'
!$is_int defined $datatype $datatype eq "http://www.w3.org/2001/XMLSchema#double"
Truth table0%0/4
not(A) || B and C
A= !$is_intB= defined $datatypeC= $datatype eq "http://www.w3.org/2001/XMLSchema#double"
ABCresult
1XX1
0111
00X0
0100
3966 0 ▶ my $is_large_int = ($is_int and length($int_repr) >= 22 and $int_repr =~ /^[^-+0]/);
Condition0%0/6
$is_int && length $int_repr >= 22 && $int_repr =~ /^[^-+0]/u
!ll&&!rl&&r
000
$is_int and length $int_repr >= 22
!ll&&!rl&&r
000
MC/DC0%0/3
$is_int && length $int_repr >= 22 && $int_repr =~ /^[^-+0]/u
$is_int length $int_repr >= 22 $int_repr =~ /^[^-+0]/u
Truth table0%0/4
A and B && C
A= $is_intB= length $int_repr >= 22C= $int_repr =~ /^[^-+0]/u
ABCresult
0XX0
10X0
1100
1111
3967 0 ▶ if ($is_large_int or ($is_num and $double_or_not_int)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($is_large_int or $is_num and $double_or_not_int) { } 0 0 0
elsif ($is_num) { } 0 0 0
Condition0%0/6
$is_large_int or $is_num and $double_or_not_int
l!l&&r!l&&!r
000
$is_num and $double_or_not_int
!ll&&!rl&&r
000
MC/DC0%0/3
$is_large_int or $is_num and $double_or_not_int
$is_large_int $is_num $double_or_not_int
Truth table0%0/4
A or B and C
A= $is_large_intB= $is_numC= $double_or_not_int
ABCresult
1XX1
0111
00X0
0100
3968 # https://github.com/w3c/json-ld-api/issues/312
3969 0 ▶ println "10" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3970 0 $value = sprintf('%E', $value);
3971 0 $value =~ s/0+E/0E/;
3972 0 $value =~ s/(\d)0E/$1E/;
3973 0 $value =~ s/E[+]/E/;
3974 0 $value =~ s/E0+([1-9])/E$1/;
3975 0 $value =~ s/E0+/E0/;
3976 0 ▶ unless ($datatype) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($datatype) 0 0 0
3977 0 $datatype = 'http://www.w3.org/2001/XMLSchema#double';
3978 }
3979 } elsif ($is_num) {
3980 0 ▶ println "11" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3981 0 $value = sprintf('%011.0f', $value);
3982 0 $value =~ s/^(-?)0+(\d)/$1$2/;
3983 0 $value =~ s/^-0/0/;
3984
3985 0 ▶ unless ($datatype) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($datatype) 0 0 0
3986 0 $datatype = 'http://www.w3.org/2001/XMLSchema#integer';
3987 }
3988 }
3989  
3990 0 ▶ if (not defined($datatype)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $datatype) 0 0 0
3991 0 ▶ println "12" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3992 0 ▶ $datatype = (exists $item->{'@language'}) ? 'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString' : 'http://www.w3.org/2001/XMLSchema#string';
Branch: 1 branch
BranchTrueFalseTotal
exists $item->{'@language'} ? : 0 0 0
3993 }
3994
3995 0 my $literal;
3996 0 ▶ if (exists $item->{'@direction'} and defined(my $dir = $self->rdf_direction)) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $item->{'@direction'} and defined(my $dir = $self->rdf_direction)) { } 0 0 0
Condition0%0/3
exists $item->{"\@direction"} and defined(my $dir = $self->rdf_direction)
!ll&&!rl&&r
000
MC/DC0%0/2
exists $item->{"\@direction"} and defined(my $dir = $self->rdf_direction)
exists $item->{"\@direction"} defined(my $dir = $self->rdf_direction)
Truth table0%0/3
A and B
A= exists $item->{"\@direction"}B= defined(my $dir = $self->rdf_direction)
ABresult
0X0
100
111
3997 0 ▶ println "13" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
3998 0 ▶ if ($dir eq 'i18n-datatype') {
Branch: 2 branches
BranchTrueFalseTotal
if ($dir eq 'i18n-datatype') { } 0 0 0
elsif ($dir eq 'compound-literal') { } 0 0 0
3999 0 ▶ println "13.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
4000 0 ▶ my $language = $item->{'@language'} // '';
Condition0%0/2
$item->{"\@language"} // ""
l!l
00
MC/DC0%0/1
$item->{"\@language"} // ""
$item->{"\@language"}
Truth table0%0/2
A
A= $item->{"\@language"}
Aresult
11
00
4001 # https://github.com/w3c/json-ld-api/issues/337
4002 0 $datatype = 'https://www.w3.org/ns/i18n#' . join('_', lc($language), $item->{'@direction'});
4003 0 $literal = $self->new_dt_literal($value, $datatype);
4004 } elsif ($dir eq 'compound-literal') {
4005 0 ▶ println "13.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
4006 0 ▶ println "13.2.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
4007 0 $literal = $self->new_blank();
4008 0 ▶ println "13.2.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
4009 0 println "TODO: spec text issue for literal construction";
4010 my $t = $self->new_triple(
4011 $literal,
4012 $self->new_iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#value'),
4013 0 $self->new_dt_literal($item->{'@value'}, 'http://www.w3.org/2001/XMLSchema#string')
4014 # $item->{'@value'} # TODO: should this be a term constructor call?
4015 );
4016 0 push(@$list_triples, $t);
4017
4018 0 ▶ if (exists $item->{'@language'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $item->{"\@language"}) 0 0 0
4019 0 ▶ println "13.2.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
4020 0 println "TODO: spec text issue for literal construction";
4021 my $t = $self->new_triple(
4022 $literal,
4023 $self->new_iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#language'),
4024 0 $self->new_dt_literal(lc($item->{'@language'}), 'http://www.w3.org/2001/XMLSchema#string')
4025 # $item->{'@language'} # TODO: should this be a term constructor call?
4026 );
4027 0 push(@$list_triples, $t);
4028 }
4029
4030 0 ▶ println "13.2.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
4031 0 println "TODO: spec text issue for literal construction";
4032 my $t2 = $self->new_triple(
4033 $literal,
4034 $self->new_iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#direction'),
4035 0 $self->new_dt_literal($item->{'@direction'}, 'http://www.w3.org/2001/XMLSchema#string')
4036 # $item->{'@direction'} # TODO: should this be a term constructor call?
4037 );
4038 0 push(@$list_triples, $t2);
4039 }
4040 } else {
4041 0 ▶ println "14" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
4042 $literal = (exists $item->{'@language'})
4043 0 ▶ ? $self->new_lang_literal($value, lc($item->{'@language'} // ''))
Branch: 1 branch
BranchTrueFalseTotal
exists $item->{'@language'} ? : 0 0 0
Condition0%0/2
$item->{"\@language"} // ""
l!l
00
MC/DC0%0/1
$item->{"\@language"} // ""
$item->{"\@language"}
Truth table0%0/2
A
A= $item->{"\@language"}
Aresult
11
00
4044 : $self->new_dt_literal($value, $datatype);
4045 }
4046
4047 0 ▶ println "15" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
4048 0 return $literal;
4049 }
4050  
4051 0 ▶ sub _8_3_2_list_conversion {
Subroutine _8_3_2_list_conversion: not called CC=16 SCAR=56.1
4052 0 ▶ println "ENTER =================> _8_3_2_list_conversion" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
4053 0 my $__indent = indent();
4054 0 my $self = shift;
4055 0 my $list = shift;
4056 0 my $list_triples = shift;
4057
4058 0 my $NIL = $self->new_iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#nil');
4059 0 ▶ if (scalar(@$list) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @$list == 0) 0 0 0
4060 0 ▶ println "1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
4061 0 return $NIL;
4062 }
4063
4064 0 ▶ println "2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
4065 0 my $bnodes = [map { $self->new_blank() } @$list];
4066 0 foreach my $i (0..$#{$bnodes}) {
4067 0 my $subject = $bnodes->[$i];
4068 0 my $item = $list->[$i];
4069 0 ▶ println "3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
4070 0 ▶ println "3.1" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
4071 0 my $embedded_triples = [];
4072
4073 0 ▶ println "3.2" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
4074 0 my $object = $self->_8_2_2_object_to_rdf($item, $embedded_triples);
4075
4076 0 ▶ if (defined($object)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $object) 0 0 0
4077 0 ▶ println "3.3" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
4078 0 push(@$list_triples, $self->new_triple(
4079 $subject,
4080 $self->new_iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#first'),
4081 $object
4082 ));
4083 }
4084
4085 0 ▶ println "3.4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
4086 0 ▶ my $rest = ($i == $#{$bnodes}) ? $NIL : $bnodes->[$i+1];
Branch: 1 branch
BranchTrueFalseTotal
$i == $#{$bnodes;} ? : 0 0 0
4087 0 push(@$list_triples, $self->new_triple(
4088 $subject,
4089 $self->new_iri('http://www.w3.org/1999/02/22-rdf-syntax-ns#rest'),
4090 $rest
4091 ));
4092
4093 0 ▶ println "3.5" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
4094 0 push(@$list_triples, @$embedded_triples);
4095 }
4096  
4097 0 ▶ println "4" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 0 0
4098 0 ▶ my $head = (scalar(@$bnodes)) ? $bnodes->[0] : $NIL;
Branch: 1 branch
BranchTrueFalseTotal
scalar @$bnodes ? : 0 0 0
4099 0 return $head;
4100 }
4101
4102 0 ▶ sub new_graph_node {
Subroutine new_graph_node: not called CC=2 SCAR=17.9
Pod undocumented
4103 0 my $self = shift;
4104 0 my $value = shift;
4105 0 ▶ if ($value =~ /_:(.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /_:(.*)/u) { } 0 0 0
4106 0 return $self->new_blank($1);
4107 } else {
4108 0 return $self->new_iri($value);
4109 }
4110 }
4111  
4112 0 ▶ sub new_graphname {
Subroutine new_graphname: not called CC=1 SCAR=6.9
Pod documented
4113 0 my $self = shift;
4114 0 Carp::cluck 'RDF term constructors must be overloaded in a JSONLD subclass';
4115 }
4116  
4117 0 ▶ sub default_graph {
Subroutine default_graph: not called CC=1 SCAR=6.9
Pod documented
4118 0 my $self = shift;
4119 0 Carp::cluck 'RDF default graph accessor must be overloaded in a JSONLD subclass';
4120 }
4121
4122 0 ▶ sub new_dataset {
Subroutine new_dataset: not called CC=1 SCAR=6.9
Pod documented
4123 0 my $self = shift;
4124 0 Carp::cluck 'RDF dataset constructors must be overloaded in a JSONLD subclass';
4125 }
4126
4127 0 ▶ sub new_triple {
Subroutine new_triple: not called CC=1 SCAR=6.9
Pod documented
4128 0 my $self = shift;
4129 0 Carp::cluck 'RDF statement constructors must be overloaded in a JSONLD subclass';
4130 }
4131
4132 0 ▶ sub new_quad {
Subroutine new_quad: not called CC=1 SCAR=6.9
Pod documented
4133 0 my $self = shift;
4134 0 Carp::cluck 'RDF statement constructors must be overloaded in a JSONLD subclass';
4135 }
4136
4137 0 ▶ sub new_iri {
Subroutine new_iri: not called CC=1 SCAR=6.9
Pod documented
4138 0 my $self = shift;
4139 0 Carp::cluck 'RDF term constructors must be overloaded in a JSONLD subclass';
4140 }
4141
4142 0 ▶ sub new_blank {
Subroutine new_blank: not called CC=1 SCAR=6.9
Pod documented
4143 0 my $self = shift;
4144 0 Carp::cluck 'RDF term constructors must be overloaded in a JSONLD subclass';
4145 }
4146
4147 0 ▶ sub new_lang_literal {
Subroutine new_lang_literal: not called CC=1 SCAR=6.9
Pod documented
4148 0 my $self = shift;
4149 0 Carp::cluck 'RDF term constructors must be overloaded in a JSONLD subclass';
4150 }
4151
4152 0 ▶ sub new_dt_literal {
Subroutine new_dt_literal: not called CC=1 SCAR=6.9
Pod documented
4153 0 my $self = shift;
4154 0 Carp::cluck 'RDF term constructors must be overloaded in a JSONLD subclass';
4155 }
4156
4157 0 ▶ sub add_quad {
Subroutine add_quad: not called CC=1 SCAR=6.9
Pod documented
4158 0 my $self = shift;
4159 0 Carp::cluck 'RDF dataset methods must be overloaded in a JSONLD subclass';
4160 }
4161 }
4162  
4163  
4164  
4165 2 1;
4166  
4167 __END__
↑ Summary