Attean/API/Term.pm

filter: Statementstmt 63.2% 377 / 596 Branchbran 36.5% 133 / 364 Conditioncond 30.5% 26 / 85 MC/DCmcdc 5.8% 3 / 51 Subroutinesub 84.8% 67 / 79 Podpod 22.2% 8 / 36 totaltotal 50.7% 614 / 1211 CC 216 SCAR 45.5
CC
216
Cov
51%
_canonicalized_term
524.9
argument_compatible
210.0
_lowest_base_type
81.2
CRAP 94.9
« AtteanX/Functions/CompositeLists.pm ↑ Summary AtteanX/Parser/Turtle.pm »
1 50 ▶use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 50 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 =head1 NAME
5  
6 Attean::API::Term - RDF Terms
7  
8 =head1 VERSION
9  
10 This document describes Attean::API::Term version 0.040
11  
12 =head1 DESCRIPTION
13  
14 The Attean::API::Term role defines a common API for all RDF terms.
15  
16 =head1 REQUIRED METHODS
17  
18 The following methods are required by the L<Attean::API::Term> role:
19  
20 =over 4
21  
22 =item C<< value >>
23  
24 Returns the term's value string.
25  
26 =item C<< ntriples_string >>
27  
28 Returns an N-Triples-compatible string serialization.
29  
30 =back
31  
32 =head1 METHODS
33  
34 This role provides default implementations of the following methods:
35  
36 =over 4
37  
38 =item C<< as_string >>
39  
40 Returns a string serialization of the term.
41  
42 =cut
43  
44 50 package Attean::API::Term 0.040 {
45 50 ▶ use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
46
47 50 with 'Attean::API::TermOrVariable', 'Attean::API::ResultOrTerm';
48 50 with 'Attean::API::TermOrVariableOrTriplePattern';
49
50 50 requires 'value'; # => (is => 'ro', isa => 'Str', required => 1);
51 50 requires 'ntriples_string';
52 1022 ▶ sub as_string {
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
53 1022 shift->ntriples_string();
54 }
55  
56 =item C<< ebv >>
57  
58 Returns true if the term has a true SPARQL "effective boolean value", false otherwise.
59  
60 =cut
61  
62 50 requires 'ebv';
63 50 requires 'compare';
64 50 requires 'sameTerms';
65
66 =item C<< order ( $other ) >>
67  
68 Similar to C<< compare >>, but provides the ordering semantics of ORDER BY.
69  
70 =cut
71  
72 13 ▶ sub order {
Subroutine order: called CC=1 SCAR=0.0
Pod documented
73 13 my $self = shift;
74 13 return $self->compare(@_);
75 }
76
77 496 ▶ sub __ntriples_string {
Subroutine __ntriples_string: called CC=15 SCAR=33.3
78 496 my $self = shift;
79 496 my $value = $self->value;
80 496 ▶ if ($value =~ m/^[\x20\x23-\x5a\x5d-\x7e]*$/o) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^[\x20\x23-\x5a\x5d-\x7e]*$/ou) 495 1 496
81 495 return $value;
82 }
83
84 1 my @chars = split(//, $value);
85 1 my $string = '';
86 1 ▶ while (scalar(@chars)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @chars) 20 1 21
87 20 my $c = shift(@chars);
88 20 my $o = ord($c);
89 20 ▶ if ($o < 0x8) {
Branch: 12 branches
BranchTrueFalseTotal
if ($o < 8) { } 0 20 20
elsif ($o == 9) { } 0 20 20
elsif ($o == 10) { } 0 20 20
elsif ($o < 12) { } 0 20 20
elsif ($o == 13) { } 0 20 20
elsif ($o < 31) { } 0 20 20
elsif ($o < 33) { } 0 20 20
elsif ($o == 34) { } 0 20 20
elsif ($o < 91) { } 5 15 20
elsif ($o == 92) { } 0 15 15
elsif ($o < 126) { } 14 1 15
elsif ($o < 65535) { } 1 0 1
90 0 $string .= sprintf("\\u%04X", $o);
91 } elsif ($o == 0x9) {
92 0 $string .= "\\t";
93 } elsif ($o == 0xA) {
94 0 $string .= "\\n";
95 } elsif ($o < 0xC) {
96 0 $string .= sprintf("\\u%04X", $o);
97 } elsif ($o == 0xD) {
98 0 $string .= "\\r";
99 } elsif ($o < 0x1F) {
100 0 $string .= sprintf("\\u%04X", $o);
101 } elsif ($o < 0x21) {
102 0 $string .= $c;
103 } elsif ($o == 0x22) {
104 0 $string .= "\"";
105 } elsif ($o < 0x5B) {
106 5 $string .= $c;
107 } elsif ($o == 0x5C) {
108 0 $string .= "\\";
109 } elsif ($o < 0x7E) {
110 14 $string .= $c;
111 } elsif ($o < 0xFFFF) {
112 1 $string .= sprintf("\\u%04X", $o);
113 } else {
114 0 $string .= sprintf("\\U%08X", $o);
115 }
116 }
117 1 return $string;
118 }
119  
120 50 with 'Attean::API::TermOrTriple';
121 }
122  
123 50 package Attean::API::Literal 0.040 {
124 50 ▶ use IRI;
Subroutine BEGIN: called CC=1 SCAR=0.0
125 50 ▶ use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
126 50 ▶ use Types::Standard qw(Maybe Str ConsumerOf);
Subroutine BEGIN: called CC=1 SCAR=0.0
127 50 ▶ use AtteanX::SPARQL::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
128 50 ▶ use AtteanX::SPARQL::Token;
Subroutine BEGIN: called CC=1 SCAR=0.0
129 50 ▶ use Attean::API::Query;
Subroutine BEGIN: called CC=1 SCAR=0.0
130  
131 50 ▶ use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
132
133 50 with 'Attean::API::Term';
134 50 with 'Attean::API::SPARQLSerializable';
135 50 with 'Attean::API::TermOrVariableOrTriplePattern';
136
137 50 requires 'language'; # => (is => 'ro', isa => 'Maybe[Str]', predicate => 'has_language');
138 50 requires 'base_dir'; # => (is => 'ro', isa => 'Maybe[Str]');
139 50 requires 'datatype'; # => (is => 'ro', isa => 'Attean::API::IRI', required => 1, coerce => 1, default => sub { IRI->new(value => 'http://www.w3.org/2001/XMLSchema#string') });
140
141 461 ▶ sub BUILD {}
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
142 472 ▶ around 'BUILDARGS' => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
143 472 my $orig = shift;
144 472 my $class = shift;
145 472 my $args = $class->$orig(@_);
146 461 ▶ if (my $lang = $args->{language}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $lang = $args->{"language"}) 40 421 461
147 40 my $oldlang = $lang;
148 # http://tools.ietf.org/html/bcp47#section-2.1.1
149 # All subtags use lowercase letters
150 40 $lang = lc($lang);
151  
152 # with 2 exceptions: subtags that neither appear at the start of the tag nor occur after singletons
153 # i.e. there's a subtag of length at least 2 preceding the exception; and a following subtag or end-of-tag
154  
155 # 1. two-letter subtags are all uppercase
156 40 $lang =~ s{(?<=\w\w-)(\w\w)(?=($|-))}{\U$1}g;
157  
158 # 2. four-letter subtags are titlecase
159 40 $lang =~ s{(?<=\w\w-)(\w\w\w\w)(?=($|-))}{\u\L$1}g;
160 40 $args->{language} = $lang;
161 }
162 461 return $args;
163 50 };
164 461 ▶ around 'BUILD' => sub {
Subroutine __ANON__: called CC=6 SCAR=18.1
165 461 my $orig = shift;
166 461 my $self = shift;
167 461 $self->$orig(@_);
168 461 ▶ if (my $dt = $self->datatype) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $dt = $self->datatype) 461 0 461
169 461 my $type = $dt->value;
170 461 ▶ if ($type =~ qr<^http://www[.]w3[.]org/2001/XMLSchema#(?:integer|decimal|float|double|non(?:Positive|Negative)Integer|(?:positive|negative)Integer|long|int|short|byte|unsigned(?:Long|Int|Short|Byte))$>) {
Branch: 4 branches
BranchTrueFalseTotal
if ($type =~ qr"^http://www[.]w3[.]org/2001/XMLSchema#(?:integer|decimal|float|double|non(?:Positive|Negative)Integer|(?:positive|negative)Integer|long|int|short|byte|unsigned(?:Long|Int|Short|Byte))$"u) { } 144 317 461
elsif ($type eq 'http://www.w3.org/2001/XMLSchema#boolean') { } 17 300 317
elsif ($type eq 'http://www.w3.org/2001/XMLSchema#dateTime') { } 3 297 300
elsif (my $role = 'Attean'->get_datatype_role($type)) { } 0 297 297
171 144 Moo::Role->apply_roles_to_object($self, 'Attean::API::NumericLiteral');
172 } elsif ($type eq 'http://www.w3.org/2001/XMLSchema#boolean') {
173 17 Moo::Role->apply_roles_to_object($self, 'Attean::API::BooleanLiteral');
174 } elsif ($type eq 'http://www.w3.org/2001/XMLSchema#dateTime') {
175 3 Moo::Role->apply_roles_to_object($self, 'Attean::API::DateTimeLiteral');
176 } elsif (my $role = Attean->get_datatype_role($type)) {
177 0 Moo::Role->apply_roles_to_object($self, $role);
178 }
179 }
180 50 };
181  
182 268 ▶ sub is_recognized_type {
Subroutine is_recognized_type: called CC=7 SCAR=31.1
Pod undocumented
183 268 my $self = shift;
184 268 ▶ if (my $dt = $self->datatype) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $dt = $self->datatype) 268 0 268
185 268 my $type = $dt->value;
186 268 ▶ if ($type eq 'http://www.w3.org/2001/XMLSchema#string') {
Branch: 5 branches
BranchTrueFalseTotal
if ($type eq 'http://www.w3.org/2001/XMLSchema#string') { } 268 0 268
elsif ($type =~ qr"^http://www[.]w3[.]org/2001/XMLSchema#(?:integer|decimal|float|double|non(?:Positive|Negative)Integer|(?:positive|negative)Integer|long|int|short|byte|unsigned(?:Long|Int|Short|Byte))$"u) { } 0 0 0
elsif ($type eq 'http://www.w3.org/2001/XMLSchema#boolean') { } 0 0 0
elsif ($type eq 'http://www.w3.org/2001/XMLSchema#dateTime') { } 0 0 0
elsif (my $role = 'Attean'->get_datatype_role($type)) { } 0 0 0
187 268 return 1;
188 } elsif ($type =~ qr<^http://www[.]w3[.]org/2001/XMLSchema#(?:integer|decimal|float|double|non(?:Positive|Negative)Integer|(?:positive|negative)Integer|long|int|short|byte|unsigned(?:Long|Int|Short|Byte))$>) {
189 0 return 1;
190 } elsif ($type eq 'http://www.w3.org/2001/XMLSchema#boolean') {
191 0 return 1;
192 } elsif ($type eq 'http://www.w3.org/2001/XMLSchema#dateTime') {
193 0 return 1;
194 } elsif (my $role = Attean->get_datatype_role($type)) {
195 0 return 1;
196 }
197 0 return 0;
198 }
199 }
200
201 87 ▶ sub sparql_tokens {
Subroutine sparql_tokens: called CC=8 SCAR=20.9
Pod undocumented
202 87 my $self = shift;
203 87 my @tokens;
204
205 87 my $dt = $self->datatype;
206 87 ▶ if ($self->does('Attean::API::NumericLiteral') and $dt->value eq 'http://www.w3.org/2001/XMLSchema#integer') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->does("Attean::API::NumericLiteral") and $dt->value eq "http://www.w3.org/2001/XMLSchema#integer") 16 71 87
Condition66%2/3
$self->does("Attean::API::NumericLiteral") and $dt->value eq "http://www.w3.org/2001/XMLSchema#integer"
!ll&&!rl&&r
71016
MC/DC50%1/2
$self->does("Attean::API::NumericLiteral") and $dt->value eq "http://www.w3.org/2001/XMLSchema#integer"
$self->does("Attean::API::NumericLiteral") $dt->value eq "http://www.w3.org/2001/XMLSchema#integer"
Truth table66%2/3
A and B
A= $self->does("Attean::API::NumericLiteral")B= $dt->value eq "http://www.w3.org/2001/XMLSchema#integer"
ABresult
0X0
100
111
207 16 ▶ if ($self->value =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->value =~ /^\d+$/u) 16 0 16
208 16 my $t = AtteanX::SPARQL::Token->fast_constructor( INTEGER, -1, -1, -1, -1, [$self->value] );
209 16 return Attean::ListIterator->new( values => [$t], item_type => 'AtteanX::SPARQL::Token' );
210 }
211 }
212
213 71 ▶ my $qtype = ($self->value =~ /\n/) ? STRING3D : STRING1D;
Branch: 1 branch
BranchTrueFalseTotal
$self->value =~ /\n/u ? : 1 70 71
214 71 my $t = AtteanX::SPARQL::Token->fast_constructor( $qtype, -1, -1, -1, -1, [$self->value] );
215 71 push(@tokens, $t);
216 71 ▶ if (my $lang = $self->language) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $lang = $self->language) { } 6 65 71
217 6 my $lex = "$lang";
218 6 ▶ if (my $d = $self->base_dir) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $d = $self->base_dir) 0 6 6
219 0 $lex .= '--' . $d;
220 }
221 6 my $l = AtteanX::SPARQL::Token->fast_constructor( LANG, -1, -1, -1, -1, ["$lang"] );
222 6 push(@tokens, $l);
223 } else {
224 65 ▶ if ($dt->value ne 'http://www.w3.org/2001/XMLSchema#string') {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt->value ne "http://www.w3.org/2001/XMLSchema#string") 2 63 65
225 2 push(@tokens, AtteanX::SPARQL::Token->hathat);
226 2 push(@tokens, $dt->sparql_tokens->elements);
227 }
228 }
229 71 return Attean::ListIterator->new( values => \@tokens, item_type => 'AtteanX::SPARQL::Token' );
230 }
231
232 28 ▶ sub ebv {
Subroutine ebv: called CC=8 SCAR=24.2
Pod documented
233 28 my $self = shift;
234 28 my $value = $self->value;
235 28 my $dt = $self->datatype->value;
236 28 ▶ if ($dt eq 'http://www.w3.org/2001/XMLSchema#boolean') {
Branch: 3 branches
BranchTrueFalseTotal
if ($dt eq 'http://www.w3.org/2001/XMLSchema#boolean') { } 26 2 28
elsif ($dt eq 'http://www.w3.org/2001/XMLSchema#string') { } 2 0 2
elsif ($self->language) { } 0 0 0
237 26 ▶ if ($value eq 'true' or $value eq '1') {
Branch: 2 branches
BranchTrueFalseTotal
if ($value eq 'true' or $value eq '1') { } 14 12 26
elsif ($value eq 'false' or $value eq '0') { } 12 0 12
Condition66%2/3
$value eq "true" or $value eq 1
l!l&&r!l&&!r
14012
MC/DC50%1/2
$value eq "true" or $value eq 1
$value eq "true" $value eq 1
Truth table66%2/3
A or B
A= $value eq "true"B= $value eq 1
ABresult
1X1
011
000
238 14 return 1;
239 ▶ } elsif ($value eq 'false' or $value eq '0') {
Condition33%1/3
$value eq "false" or $value eq 0
l!l&&r!l&&!r
1200
MC/DC0%0/2
$value eq "false" or $value eq 0
$value eq "false" $value eq 0
Truth table33%1/3
A or B
A= $value eq "false"B= $value eq 0
ABresult
1X1
011
000
240 12 return 0;
241 } else {
242 0 die "TypeError: EBV of an xsd:boolean with invalid lexical form";
243 }
244 } elsif ($dt eq 'http://www.w3.org/2001/XMLSchema#string') {
245 2 return (length($value) > 0);
246 } elsif ($self->language) {
247 0 die "TypeError: EBV of a language-tagged literal";
248 } else {
249 0 die "TypeError: EBV of a datatyped literal: $dt";
250 }
251 }
252
253 1 ▶ sub compare {
Subroutine compare: called CC=9 SCAR=27.7
Pod documented
254 1 my ($a, $b) = @_;
255 1 ▶ return 1 unless blessed($b);
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($b) 0 1 1
256 1 ▶ return 1 unless ($b->does('Attean::API::Literal') or $b->does('Attean::API::Binding'));
Branch: 1 branch
BranchTrueFalseTotal
unless $b->does("Attean::API::Literal") or $b->does("Attean::API::Binding") 0 1 1
Condition33%1/3
$b->does("Attean::API::Literal") or $b->does("Attean::API::Binding")
l!l&&r!l&&!r
100
MC/DC0%0/2
$b->does("Attean::API::Literal") or $b->does("Attean::API::Binding")
$b->does("Attean::API::Literal") $b->does("Attean::API::Binding")
Truth table33%1/3
A or B
A= $b->does("Attean::API::Literal")B= $b->does("Attean::API::Binding")
ABresult
1X1
011
000
257 1 ▶ return -1 if ($b->does('Attean::API::Binding'));
Branch: 1 branch
BranchTrueFalseTotal
if $b->does("Attean::API::Binding") 0 1 1
258 1 ▶ my $c = ((($a->language // '') cmp ($b->language // '')) || ($a->datatype->value cmp $b->datatype->value) || ($a->value cmp $b->value));
Condition40%4/10
($a->language // '') cmp ($b->language // '') || $a->datatype->value cmp $b->datatype->value || $a->value cmp $b->value
l!l&&r!l&&!r
010
($a->language // "") cmp ($b->language // "") or $a->datatype->value cmp $b->datatype->value
l!l&&r!l&&!r
001
$a->language // ""
l!l
01
$b->language // ""
l!l
01
MC/DC0%0/3
($a->language // '') cmp ($b->language // '') || $a->datatype->value cmp $b->datatype->value || $a->value cmp $b->value
$a->language $a->datatype->value cmp $b->datatype->value $a->value cmp $b->value
MC/DC0%0/1
$b->language // ""
$b->language
Truth table25%1/4
A or B || C
A= $a->languageB= $a->datatype->value cmp $b->datatype->valueC= $a->value cmp $b->value
ABCresult
1XX1
01X1
0011
0000
Truth table50%1/2
A
A= $b->language
Aresult
11
00
259 1 return $c;
260 }
261
262 144 ▶ sub equals {
Subroutine equals: called CC=8 SCAR=25.5
Pod undocumented
263 144 my $a = shift;
264 144 my $b = shift;
265 144 ▶ if ($a->as_string eq $b->as_string) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a->as_string eq $b->as_string) 10 134 144
266 10 return 1;
267 }
268 134 ▶ if ($a->can('datatype') and $b->can('datatype') and my $adt = $a->datatype and my $bdt = $b->datatype) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a->can("datatype") and $b->can("datatype") and my $adt = $a->datatype and my $bdt = $b->datatype) 134 0 134
Condition33%3/9
$a->can("datatype") and $b->can("datatype") and my $adt = $a->datatype and my $bdt = $b->datatype
!ll&&!rl&&r
00134
$a->can("datatype") and $b->can("datatype") and my $adt = $a->datatype
!ll&&!rl&&r
00134
$a->can("datatype") and $b->can("datatype")
!ll&&!rl&&r
00134
MC/DC0%0/4
$a->can("datatype") and $b->can("datatype") and my $adt = $a->datatype and my $bdt = $b->datatype
$a->can("datatype") $b->can("datatype") my $adt = $a->datatype my $bdt = $b->datatype
Truth table20%1/5
A and B and C and D
A= $a->can("datatype")B= $b->can("datatype")C= my $adt = $a->datatypeD= my $bdt = $b->datatype
ABCDresult
0XXX0
10XX0
110X0
11100
11111
269 134 ▶ if (!$a->is_recognized_type or !$b->is_recognized_type) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($a->is_recognized_type and $b->is_recognized_type) 0 134 134
Condition33%1/3
$a->is_recognized_type and $b->is_recognized_type
!ll&&!rl&&r
00134
MC/DC0%0/2
$a->is_recognized_type and $b->is_recognized_type
$a->is_recognized_type $b->is_recognized_type
Truth table33%1/3
A and B
A= $a->is_recognized_typeB= $b->is_recognized_type
ABresult
0X0
100
111
270 # Either different lexical values in the same datatype, or different
271 # datatypes. Either way, it's datatypes that were not caught by some
272 # some more-specific implementation of equals(). So we don't know
273 # anything about the value space, so we raise a type error, indicating
274 # that we can't say whether the values are equal or not.
275 0 die 'TypeError';
276 }
277 }
278 134 return 0;
279 }
280
281 =item C<< sameTerms( $other ) >>
282  
283 =cut
284  
285 0 ▶ sub sameTerms {
Subroutine sameTerms: not called CC=4 SCAR=30.0
Pod undocumented
286 0 my $lhs = shift;
287 0 my $rhs = shift;
288 0 ▶ return 0 unless ($rhs->does('Attean::API::Literal'));
Branch: 1 branch
BranchTrueFalseTotal
unless $rhs->does("Attean::API::Literal") 0 0 0
289 0 ▶ return 0 unless ($lhs->value eq $rhs->value);
Branch: 1 branch
BranchTrueFalseTotal
unless $lhs->value eq $rhs->value 0 0 0
290 0 ▶ return 0 unless ($lhs->datatype->value eq $rhs->datatype->value);
Branch: 1 branch
BranchTrueFalseTotal
unless $lhs->datatype->value eq $rhs->datatype->value 0 0 0
291 0 return 1;
292 }
293
294 50 ▶ if ($ENV{ATTEAN_TYPECHECK}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"ATTEAN_TYPECHECK"}) 0 50 50
295 0 my %map = (
296 language => Maybe[Str],
297 datatype => ConsumerOf['Attean::API::IRI'],
298 );
299 0 foreach my $method (keys %map) {
300 0 my $type = $map{$method};
301 0 ▶ around $method => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
302 0 my $orig = shift;
303 0 my $self = shift;
304 0 my $class = ref($self);
305 0 my $value = $self->$orig(@_);
306 0 my $err = $type->validate($value);
307 0 ▶ if ($err) {
Branch: 1 branch
BranchTrueFalseTotal
if ($err) 0 0 0
308 0 my $name = $type->display_name;
309 0 die "${class}'s $method failed conformance check for $name: $value";
310 }
311 0 return $value;
312 0 };
313 }
314 }
315
316 0 ▶ sub construct_args {
Subroutine construct_args: not called CC=3 SCAR=24.8
Pod undocumented
317 0 my $self = shift;
318 0 my %args;
319 0 ▶ $args{language} = $self->language if ($self->language);
Branch: 1 branch
BranchTrueFalseTotal
if $self->language 0 0 0
320 0 ▶ $args{datatype} = $self->datatype if ($self->datatype);
Branch: 1 branch
BranchTrueFalseTotal
if $self->datatype 0 0 0
321 0 return %args;
322 }
323
324 0 ▶ sub argument_compatible {
Subroutine argument_compatible: not called CC=14 SCAR=53.5
Pod undocumented
325 0 my $self = shift;
326 0 my @terms = @_;
327
328 0 ▶ if (my $l = $self->language) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $l = $self->language) { } 0 0 0
elsif ($self->datatype->value eq 'http://www.w3.org/2001/XMLSchema#string') { } 0 0 0
329 0 foreach my $t (@terms) {
330 0 ▶ return 0 unless ($t->does('Attean::API::Literal'));
Branch: 1 branch
BranchTrueFalseTotal
unless $t->does("Attean::API::Literal") 0 0 0
331 0 ▶ if ($t->language) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->language) { } 0 0 0
332 0 ▶ return 0 unless (defined($t->language));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $t->language 0 0 0
333 0 ▶ return 0 unless ($t->language eq $l);
Branch: 1 branch
BranchTrueFalseTotal
unless $t->language eq $l 0 0 0
334 } else {
335 0 ▶ return 0 unless ($t->datatype->value eq 'http://www.w3.org/2001/XMLSchema#string');
Branch: 1 branch
BranchTrueFalseTotal
unless $t->datatype->value eq "http://www.w3.org/2001/XMLSchema#string" 0 0 0
336 }
337 }
338 0 return 1;
339 } elsif ($self->datatype->value eq 'http://www.w3.org/2001/XMLSchema#string') {
340 0 foreach my $t (@terms) {
341 0 ▶ return 0 unless ($t->does('Attean::API::Literal'));
Branch: 1 branch
BranchTrueFalseTotal
unless $t->does("Attean::API::Literal") 0 0 0
342 0 ▶ return 0 if ($t->language);
Branch: 1 branch
BranchTrueFalseTotal
if $t->language 0 0 0
343 0 ▶ return 0 unless (blessed($t->datatype));
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($t->datatype) 0 0 0
344 0 ▶ return 0 unless ($t->datatype->value eq 'http://www.w3.org/2001/XMLSchema#string');
Branch: 1 branch
BranchTrueFalseTotal
unless $t->datatype->value eq "http://www.w3.org/2001/XMLSchema#string" 0 0 0
345 }
346 0 return 1;
347 }
348
349 0 return 0;
350 }
351
352 63 ▶ sub _ntriples_string {
Subroutine _ntriples_string: called CC=4 SCAR=17.9
353 63 my $self = shift;
354 63 my $str = sprintf('"%s"', $self->__ntriples_string);
355 63 ▶ if (my $l = $self->language) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $l = $self->language) { } 0 63 63
356 0 ▶ if (my $d = $self->base_dir) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $d = $self->base_dir) { } 0 0 0
357 0 return join('', $str, '@', $l, '--', $d);
358 } else {
359 0 return join('@', $str, $l);
360 }
361 } else {
362 63 my $dt = $self->datatype;
363 63 ▶ if ($dt->value eq 'http://www.w3.org/2001/XMLSchema#string') {
Branch: 1 branch
BranchTrueFalseTotal
if ($dt->value eq 'http://www.w3.org/2001/XMLSchema#string') { } 0 63 63
364 0 return $str;
365 } else {
366 63 return join('^^', $str, $dt->ntriples_string);
367 }
368 }
369 }
370  
371 0 ▶ around as_sparql => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
372 0 my $orig = shift;
373 0 my $self = shift;
374 0 my $s = $self->$orig(@_);
375
376 0 ▶ if ($s =~ m[^"(true|false)"\^\^<http://www[.]w3[.]org/2001/XMLSchema#boolean>$]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ m[^"(true|false)"\^\^<http://www[.]w3[.]org/2001/XMLSchema#boolean>$]u) 0 0 0
377 0 return $1;
378 }
379
380 0 return $s;
381 50 };
382  
383 1449 ▶ sub has_base_dir {
Subroutine has_base_dir: called CC=2 SCAR=7.6
Pod undocumented
384 1449 my $self = shift;
385 1449 my $base_dir = $self->base_dir;
386 1449 ▶ return (defined($base_dir) and length($base_dir) > 0);
Condition33%1/3
defined $base_dir && length $base_dir > 0
!ll&&!rl&&r
144900
MC/DC0%0/2
defined $base_dir && length $base_dir > 0
defined $base_dir length $base_dir > 0
Truth table33%1/3
A && B
A= defined $base_dirB= length $base_dir > 0
ABresult
0X0
100
111
387 }
388  
389 0 ▶ sub lang_dir {
Subroutine lang_dir: not called CC=3 SCAR=24.8
Pod undocumented
390 0 my $self = shift;
391 0 my $lang_key = '';
392 0 ▶ if (my $l = $self->language) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $l = $self->language) 0 0 0
393 0 $lang_key = $l;
394 0 ▶ if (my $d = $self->base_dir) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $d = $self->base_dir) 0 0 0
395 0 $lang_key .= '--' . $d;
396 }
397 }
398 0 return $lang_key;
399 }
400  
401 }
402  
403 50 package Attean::API::DateTimeLiteral 0.040 {
404 50 ▶ use DateTime::Format::W3CDTF;
Subroutine BEGIN: called CC=1 SCAR=0.0
405  
406 50 ▶ use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
407  
408 3 ▶ sub datetime {
Subroutine datetime: called CC=3 SCAR=11.0
Pod undocumented
409 3 my $self = shift;
410 3 my $w3c = DateTime::Format::W3CDTF->new;
411 3 my $lex = $self->value;
412 3 my $add = 0;
413 3 ▶ if ($lex =~ /T24:00:00/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lex =~ /T24:00:00/u) 1 2 3
414 1 $add++;
415 1 $lex =~ s/24:00:00/00:00:00/;
416 }
417 3 my $dt = $w3c->parse_datetime( $lex );
418 3 ▶ if ($add) {
Branch: 1 branch
BranchTrueFalseTotal
if ($add) 1 2 3
419 1 $dt->add( days => 1 );
420 }
421 3 return $dt;
422 }
423
424 0 ▶ sub equals {
Subroutine equals: not called CC=3 SCAR=24.8
Pod undocumented
425 0 my $self = shift;
426 0 my $other = shift;
427 0 ▶ return 0 unless ($other->does('Attean::API::DateTimeLiteral'));
Branch: 1 branch
BranchTrueFalseTotal
unless $other->does("Attean::API::DateTimeLiteral") 0 0 0
428 0 my $dt = $self->datetime;
429 0 my $odt = $other->datetime;
430 0 ▶ return 0 if ($dt->time_zone->is_floating != $odt->time_zone->is_floating);
Branch: 1 branch
BranchTrueFalseTotal
if $dt->time_zone->is_floating != $odt->time_zone->is_floating 0 0 0
431 0 return (0 == $dt->compare($odt));
432 }
433  
434 0 ▶ sub compare {
Subroutine compare: not called CC=4 SCAR=30.0
Pod undocumented
435 0 my ($a, $b) = @_;
436 0 ▶ if ($b->does('Attean::API::DateTimeLiteral')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($b->does("Attean::API::DateTimeLiteral")) 0 0 0
437 0 ▶ if (my $adt = $a->datetime and my $bdt = $b->datetime) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $adt = $a->datetime and my $bdt = $b->datetime) 0 0 0
Condition0%0/3
my $adt = $a->datetime and my $bdt = $b->datetime
!ll&&!rl&&r
000
MC/DC0%0/2
my $adt = $a->datetime and my $bdt = $b->datetime
my $adt = $a->datetime my $bdt = $b->datetime
Truth table0%0/3
A and B
A= my $adt = $a->datetimeB= my $bdt = $b->datetime
ABresult
0X0
100
111
438 0 my $af = $adt->time_zone->is_floating;
439 0 my $bf = $bdt->time_zone->is_floating;
440 # TODO: handle case of one floating datetime
441 0 return DateTime->compare($adt, $bdt);
442 }
443 }
444 0 return $a->SUPER::compare($b);
445 }
446
447 }
448  
449 50 package Attean::API::CanonicalizingLiteral 0.040 {
450 50 ▶ use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
451 50 requires 'canonicalized_term';
452 50 requires 'canonicalized_term_strict';
453 }
454  
455 50 package Attean::API::BooleanLiteral 0.040 {
456 50 ▶ use Scalar::Util qw(blessed looks_like_number);
Subroutine BEGIN: called CC=1 SCAR=0.0
457  
458 50 ▶ use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
459  
460 0 ▶ sub canonicalized_term_strict {
Subroutine canonicalized_term_strict: not called CC=4 SCAR=30.0
Pod undocumented
461 0 my $self = shift;
462 0 my $value = $self->value;
463 0 ▶ if ($value =~ m/^(true|false|0|1)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^(true|false|0|1)$/u) { } 0 0 0
464 0 ▶ return ($value eq 'true' or $value eq '1')
Branch: 1 branch
BranchTrueFalseTotal
$value eq 'true' || $value eq '1' ? : 0 0 0
Condition0%0/3
$value eq "true" or $value eq 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$value eq "true" or $value eq 1
$value eq "true" $value eq 1
Truth table0%0/3
A or B
A= $value eq "true"B= $value eq 1
ABresult
1X1
011
000
465 ? Attean::Literal->true
466 : Attean::Literal->false;
467 } else {
468 0 die "Bad lexical form for xsd:boolean: '$value'";
469 }
470 }
471  
472 8 ▶ sub canonicalized_term {
Subroutine canonicalized_term: called CC=4 SCAR=16.4
Pod undocumented
473 8 my $self = shift;
474 8 my $value = $self->value;
475 8 ▶ if ($value =~ m/^(true|false|0|1)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^(true|false|0|1)$/u) { } 8 0 8
476 8 ▶ return ($value eq 'true' or $value eq '1')
Branch: 1 branch
BranchTrueFalseTotal
$value eq 'true' || $value eq '1' ? : 8 0 8
Condition33%1/3
$value eq "true" or $value eq 1
l!l&&r!l&&!r
800
MC/DC0%0/2
$value eq "true" or $value eq 1
$value eq "true" $value eq 1
Truth table33%1/3
A or B
A= $value eq "true"B= $value eq 1
ABresult
1X1
011
000
477 ? Attean::Literal->true
478 : Attean::Literal->false;
479 } else {
480 0 return $self;
481 }
482 }
483  
484 2 ▶ sub equals {
Subroutine equals: called CC=6 SCAR=24.7
Pod undocumented
485 2 my ($a, $b) = @_;
486 2 my $does_bool = $b->does('Attean::API::BooleanLiteral');
487 2 ▶ if ($b->does('Attean::API::Literal') and not($does_bool)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($b->does("Attean::API::Literal") and not $does_bool) 0 2 2
Condition33%1/3
$b->does("Attean::API::Literal") and not $does_bool
!ll&&!rl&&r
020
MC/DC0%0/2
$b->does("Attean::API::Literal") and not $does_bool
$b->does("Attean::API::Literal") not $does_bool
Truth table33%1/3
A and not(B)
A= $b->does("Attean::API::Literal")B= not $does_bool
ABresult
0X0
100
111
488 0 ▶ if (!$a->is_recognized_type or !$b->is_recognized_type) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($a->is_recognized_type and $b->is_recognized_type) 0 0 0
Condition0%0/3
$a->is_recognized_type and $b->is_recognized_type
!ll&&!rl&&r
000
MC/DC0%0/2
$a->is_recognized_type and $b->is_recognized_type
$a->is_recognized_type $b->is_recognized_type
Truth table0%0/3
A and B
A= $a->is_recognized_typeB= $b->is_recognized_type
ABresult
0X0
100
111
489 # Either different lexical values in the same datatype, or different
490 # datatypes. Either way, it's datatypes that were not caught by some
491 # some more-specific implementation of equals(). So we don't know
492 # anything about the value space, so we raise a type error, indicating
493 # that we can't say whether the values are equal or not.
494 0 die "TypeError: boolean and non-boolean literals are not comparable";
495 }
496 }
497 2 ▶ if ($does_bool) {
Branch: 1 branch
BranchTrueFalseTotal
if ($does_bool) 2 0 2
498 2 my $l = $a->canonicalized_term;
499 2 my $r = $b->canonicalized_term;
500 2 return $l->value eq $r->value;
501 }
502 0 return 0;
503 }
504  
505 50 with 'Attean::API::Literal', 'Attean::API::CanonicalizingLiteral';
506 }
507  
508 50 package Attean::API::NumericLiteral 0.040 {
509 50 ▶ use Scalar::Util qw(blessed looks_like_number);
Subroutine BEGIN: called CC=1 SCAR=0.0
510  
511 50 ▶ use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
512  
513 0 ▶ sub equals {
Subroutine equals: not called CC=8 SCAR=42.8
Pod undocumented
514 0 my ($a, $b) = @_;
515 0 my $does_num = $b->does('Attean::API::NumericLiteral');
516 0 ▶ if ($b->does('Attean::API::Literal') and not($does_num)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($b->does("Attean::API::Literal") and not $does_num) 0 0 0
Condition0%0/3
$b->does("Attean::API::Literal") and not $does_num
!ll&&!rl&&r
000
MC/DC0%0/2
$b->does("Attean::API::Literal") and not $does_num
$b->does("Attean::API::Literal") not $does_num
Truth table0%0/3
A and not(B)
A= $b->does("Attean::API::Literal")B= not $does_num
ABresult
0X0
100
111
517 0 ▶ if (!$a->is_recognized_type or !$b->is_recognized_type) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($a->is_recognized_type and $b->is_recognized_type) 0 0 0
Condition0%0/3
$a->is_recognized_type and $b->is_recognized_type
!ll&&!rl&&r
000
MC/DC0%0/2
$a->is_recognized_type and $b->is_recognized_type
$a->is_recognized_type $b->is_recognized_type
Truth table0%0/3
A and B
A= $a->is_recognized_typeB= $b->is_recognized_type
ABresult
0X0
100
111
518 # Either different lexical values in the same datatype, or different
519 # datatypes. Either way, it's datatypes that were not caught by some
520 # some more-specific implementation of equals(). So we don't know
521 # anything about the value space, so we raise a type error, indicating
522 # that we can't say whether the values are equal or not.
523 0 die "TypeError: numeric and non-numeric literals are not comparable";
524 }
525 }
526 0 ▶ return 0 unless ($b->does('Attean::API::NumericLiteral'));
Branch: 1 branch
BranchTrueFalseTotal
unless $b->does("Attean::API::NumericLiteral") 0 0 0
527 0 ▶ return 0 unless (defined $a->numeric_value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $a->numeric_value 0 0 0
528 0 ▶ return 0 unless (defined $b->numeric_value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $b->numeric_value 0 0 0
529 0 return $a->numeric_value == $b->numeric_value;
530 }
531  
532 1 ▶ sub compare {
Subroutine compare: called CC=8 SCAR=25.5
Pod undocumented
533 1 my ($a, $b) = @_;
534 1 my $does_num = $b->does('Attean::API::NumericLiteral');
535 1 ▶ if ($b->does('Attean::API::Literal') and not($does_num)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($b->does("Attean::API::Literal") and not $does_num) 0 1 1
Condition33%1/3
$b->does("Attean::API::Literal") and not $does_num
!ll&&!rl&&r
010
MC/DC0%0/2
$b->does("Attean::API::Literal") and not $does_num
$b->does("Attean::API::Literal") not $does_num
Truth table33%1/3
A and not(B)
A= $b->does("Attean::API::Literal")B= not $does_num
ABresult
0X0
100
111
536 0 die "TypeError: numeric and non-numeric literals are not comparable";
537 }
538 1 ▶ return 1 unless blessed($b);
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($b) 0 1 1
539 1 ▶ return 1 unless ($b->does('Attean::API::Literal') or $b->does('Attean::API::Binding'));
Branch: 1 branch
BranchTrueFalseTotal
unless $b->does("Attean::API::Literal") or $b->does("Attean::API::Binding") 0 1 1
Condition33%1/3
$b->does("Attean::API::Literal") or $b->does("Attean::API::Binding")
l!l&&r!l&&!r
100
MC/DC0%0/2
$b->does("Attean::API::Literal") or $b->does("Attean::API::Binding")
$b->does("Attean::API::Literal") $b->does("Attean::API::Binding")
Truth table33%1/3
A or B
A= $b->does("Attean::API::Literal")B= $b->does("Attean::API::Binding")
ABresult
1X1
011
000
540 1 ▶ return -1 if ($b->does('Attean::API::Binding'));
Branch: 1 branch
BranchTrueFalseTotal
if $b->does("Attean::API::Binding") 0 1 1
541 1 ▶ if ($b->does('Attean::API::NumericLiteral')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($b->does('Attean::API::NumericLiteral')) { } 1 0 1
542 1 return $a->numeric_value <=> $b->numeric_value;
543 } else {
544 0 return 1;
545 # Attean::API::Literal::compare($a, $b);
546 }
547 }
548  
549 4 ▶ sub canonicalized_term_strict {
Subroutine canonicalized_term_strict: called CC=1 SCAR=0.0
Pod undocumented
550 4 my $self = shift;
551 4 return $self->_canonicalized_term(1, @_);
552 }
553
554 1 ▶ sub canonicalized_term {
Subroutine canonicalized_term: called CC=1 SCAR=0.0
Pod undocumented
555 1 my $self = shift;
556 1 return $self->_canonicalized_term(0, @_);
557 }
558
559 5 ▶ sub _canonicalized_term {
Subroutine _canonicalized_term: called CC=36 SCAR=62.6
560 5 my $self = shift;
561 5 my $strict = shift;
562 5 my $value = $self->value;
563 5 my $type = $self->datatype->value;
564 5 $type =~ s/^.*#//;
565 5 ▶ if ($type eq 'integer') {
Branch: 6 branches
BranchTrueFalseTotal
if ($type eq 'integer') { } 1 4 5
elsif ($type eq 'negativeInteger') { } 0 4 4
elsif ($type eq 'decimal') { } 4 0 4
elsif ($type eq 'float') { } 0 0 0
elsif ($type eq 'boolean') { } 0 0 0
elsif ($type eq 'double') { } 0 0 0
566 1 ▶ if ($value =~ m/^([-+])?(\d+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^([-+])?(\d+)$/u) { } 1 0 1
567 1 ▶ my $sign = $1 || '';
Condition50%1/2
$1 || ''
l!l
10
MC/DC0%0/1
$1 || ''
$1
Truth table50%1/2
A
A= $1
Aresult
11
00
568 1 my $num = $2;
569 1 ▶ $sign = '' if ($sign eq '+');
Branch: 1 branch
BranchTrueFalseTotal
if $sign eq "+" 1 0 1
570 1 $num =~ s/^0+(\d)/$1/;
571 1 return Attean::Literal->integer("${sign}${num}");
572 } else {
573 0 ▶ die "Bad lexical form for xsd:integer: '$value'" if ($strict);
Branch: 1 branch
BranchTrueFalseTotal
if $strict 0 0 0
574 0 return $self;
575 }
576 } elsif ($type eq 'negativeInteger') {
577 0 ▶ if ($value =~ m/^-(\d+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^-(\d+)$/u) { } 0 0 0
578 0 my $num = $1;
579 0 $num =~ s/^0+(\d)/$1/;
580 0 return Attean::Literal->new(value => "-${num}", datatype => 'http://www.w3.org/2001/XMLSchema#negativeInteger');
581 } else {
582 0 ▶ die "Bad lexical form for xsd:integer: '$value'" if ($strict);
Branch: 1 branch
BranchTrueFalseTotal
if $strict 0 0 0
583 0 return $self;
584 }
585 } elsif ($type eq 'decimal') {
586 4 ▶ if ($value =~ m/^([-+])?((\d+)([.]\d*)?)$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($value =~ /^([-+])?((\d+)([.]\d*)?)$/u) { } 4 0 4
elsif ($value =~ /^([-+])?([.]\d+)$/u) { } 0 0 0
587 4 ▶ my $sign = $1 || '';
Condition50%1/2
$1 || ''
l!l
04
MC/DC0%0/1
$1 || ''
$1
Truth table50%1/2
A
A= $1
Aresult
11
00
588 4 my $num = $2;
589 4 my $int = $3;
590 4 my $frac = $4;
591 4 ▶ $sign = '' if ($sign eq '+');
Branch: 1 branch
BranchTrueFalseTotal
if $sign eq "+" 0 4 4
592 4 $num =~ s/^0+(\d)/$1/;
593 4 $num =~ s/[.](\d+)0+$/.$1/;
594 4 ▶ if ($num =~ /^[.]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($num =~ /^[.]/u) 0 4 4
595 0 $num = "0$num";
596 }
597 4 ▶ if ($num !~ /[.]/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($num =~ /[.]/u) 4 0 4
598 4 $num = "${num}.0";
599 }
600 4 return Attean::Literal->decimal("${sign}${num}");
601 } elsif ($value =~ m/^([-+])?([.]\d+)$/) {
602 0 ▶ my $sign = $1 || '';
Condition0%0/2
$1 || ''
l!l
00
MC/DC0%0/1
$1 || ''
$1
Truth table0%0/2
A
A= $1
Aresult
11
00
603 0 my $num = $2;
604 0 ▶ $sign = '' if ($sign eq '+');
Branch: 1 branch
BranchTrueFalseTotal
if $sign eq "+" 0 0 0
605 0 $num =~ s/^0+(.)/$1/;
606 0 return Attean::Literal->decimal("${sign}${num}");
607 } else {
608 0 ▶ die "Bad lexical form for xsd:deciaml: '$value'" if ($strict);
Branch: 1 branch
BranchTrueFalseTotal
if $strict 0 0 0
609 0 return $self;
610 }
611 } elsif ($type eq 'float') {
612 0 ▶ if ($value =~ m/^(?:([-+])?(?:(\d+(?:\.\d*)?|\.\d+)([Ee][-+]?\d+)?|(INF)))|(NaN)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^(?:([-+])?(?:(\d+(?:\.\d*)?|\.\d+)([Ee][-+]?\d+)?|(INF)))|(NaN)$/u) { } 0 0 0
613 0 my $sign = $1;
614 0 my $inf = $4;
615 0 my $nan = $5;
616 50 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
617 0 ▶ $sign = '' if ($sign eq '+');
Branch: 1 branch
BranchTrueFalseTotal
if $sign eq "+" 0 0 0
618 0 ▶ return Attean::Literal->float("${sign}$inf") if ($inf);
Branch: 1 branch
BranchTrueFalseTotal
if $inf 0 0 0
619 0 ▶ return Attean::Literal->float($nan) if ($nan);
Branch: 1 branch
BranchTrueFalseTotal
if $nan 0 0 0
620  
621 50 ▶ no warnings 'numeric';
Subroutine BEGIN: called CC=1 SCAR=0.0
622 0 $value = sprintf('%E', $value);
623 0 $value =~ m/^(?:([-+])?(?:(\d+(?:\.\d*)?|\.\d+)([Ee][-+]?\d+)?|(INF)))|(NaN)$/;
624 0 $sign = $1;
625 0 $inf = $4;
626 0 $nan = $5;
627 0 my $num = $2;
628 0 my $exp = $3;
629 0 $num =~ s/[.](\d+?)0+/.$1/;
630 0 $exp =~ tr/e/E/;
631 0 $exp =~ s/E[+]/E/;
632 0 $exp =~ s/E(-?)0+([1-9])$/E$1$2/;
633 0 $exp =~ s/E(-?)0+$/E${1}0/;
634 0 return Attean::Literal->float("${sign}${num}${exp}");
635 } else {
636 0 ▶ die "Bad lexical form for xsd:float: '$value'" if ($strict);
Branch: 1 branch
BranchTrueFalseTotal
if $strict 0 0 0
637 0 return $self;
638 }
639 } elsif ($type eq 'boolean') {
640 0 ▶ if ($value =~ m/^(true|false|0|1)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^(true|false|0|1)$/u) { } 0 0 0
641 0 ▶ return ($value eq 'true' or $value eq '1')
Branch: 1 branch
BranchTrueFalseTotal
$value eq 'true' || $value eq '1' ? : 0 0 0
Condition0%0/3
$value eq "true" or $value eq 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$value eq "true" or $value eq 1
$value eq "true" $value eq 1
Truth table0%0/3
A or B
A= $value eq "true"B= $value eq 1
ABresult
1X1
011
000
642 ? Attean::Literal->true
643 : Attean::Literal->false;
644 } else {
645 0 ▶ die "Bad lexical form for xsd:boolean: '$value'" if ($strict);
Branch: 1 branch
BranchTrueFalseTotal
if $strict 0 0 0
646 0 return $self;
647 }
648 } elsif ($type eq 'double') {
649 0 ▶ if ($value =~ m/^(?:([-+])?(?:(\d+(?:\.\d*)?|\.\d+)([Ee][-+]?\d+)?|(INF)))|(NaN)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^(?:([-+])?(?:(\d+(?:\.\d*)?|\.\d+)([Ee][-+]?\d+)?|(INF)))|(NaN)$/u) { } 0 0 0
650 0 my $sign = $1;
651 0 my $inf = $4;
652 0 my $nan = $5;
653 50 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
654 0 ▶ $sign = '' if ($sign eq '+');
Branch: 1 branch
BranchTrueFalseTotal
if $sign eq "+" 0 0 0
655 0 ▶ return Attean::Literal->double("${sign}$inf") if ($inf);
Branch: 1 branch
BranchTrueFalseTotal
if $inf 0 0 0
656 0 ▶ return Attean::Literal->double($nan) if ($nan);
Branch: 1 branch
BranchTrueFalseTotal
if $nan 0 0 0
657  
658 50 ▶ no warnings 'numeric';
Subroutine BEGIN: called CC=1 SCAR=0.0
659 0 $value = sprintf('%E', $value);
660 0 $value =~ m/^(?:([-+])?(?:(\d+(?:\.\d*)?|\.\d+)([Ee][-+]?\d+)?|(INF)))|(NaN)$/;
661 0 $sign = $1;
662 0 $inf = $4;
663 0 $nan = $5;
664 0 my $num = $2;
665 0 my $exp = $3;
666 0 $num =~ s/[.](\d+?)0+/.$1/;
667 0 $exp =~ tr/e/E/;
668 0 $exp =~ s/E[+]/E/;
669 0 $exp =~ s/E(-?)0+([1-9])$/E$1$2/;
670 0 $exp =~ s/E(-?)0+$/E${1}0/;
671 0 return Attean::Literal->double("${sign}${num}${exp}");
672 } else {
673 0 ▶ die "Bad lexical form for xsd:double: '$value'" if ($strict);
Branch: 1 branch
BranchTrueFalseTotal
if $strict 0 0 0
674 0 return $self;
675 }
676 } else {
677 0 warn "No canonicalization for type $type";
678 }
679 0 return $self;
680 }
681
682 29 ▶ sub is_integer_type {
Subroutine is_integer_type: called CC=1 SCAR=0.0
Pod undocumented
683 29 my $self = shift;
684 29 my $type = $self->datatype->value;
685 29 return scalar($type =~ qr<^http://www[.]w3[.]org/2001/XMLSchema#(?:integer|non(?:Positive|Negative)Integer|(?:positive|negative)Integer|long|int|short|byte|unsigned(?:Long|Int|Short|Byte))$>);
686 }
687
688 6 ▶ sub ebv {
Subroutine ebv: called CC=1 SCAR=0.0
Pod undocumented
689 6 my $self = shift;
690 6 return ($self->numeric_value != 0);
691 }
692  
693 50 ▶ sub numeric_value {
Subroutine numeric_value: called CC=2 SCAR=7.1
Pod undocumented
694 50 my $self = shift;
695 50 my $v = $self->value;
696 50 ▶ return (looks_like_number($v)) ? eval $v : undef;
Branch: 1 branch
BranchTrueFalseTotal
&looks_like_number($v) ? : 50 0 50
697 }
698  
699 {
700 50 my %type_hierarchy = (
701 'integer' => 'decimal',
702 'nonPositiveInteger' => 'integer',
703 'negativeInteger' => 'nonPositiveInteger',
704 'long' => 'integer',
705 'int' => 'long',
706 'short' => 'int',
707 'byte' => 'short',
708 'nonNegativeInteger' => 'integer',
709 'unsignedLong' => 'nonNegativeInteger',
710 'unsignedInt' => 'unsignedLong',
711 'unsignedShort' => 'unsignedInt',
712 'unsignedByte' => 'unsignedShort',
713 'positiveInteger' => 'nonNegativeInteger',
714 );
715 12 ▶ sub is_base_type {
Subroutine is_base_type: called CC=1 SCAR=0.0
Pod undocumented
716 12 my $type = shift;
717 12 return ($type =~ m/\b(integer|decimal|float|double)$/);
718 }
719 14 ▶ sub _lowest_base_type {
Subroutine _lowest_base_type: called CC=30 SCAR=44.0
720 14 my ($lhs, $rhs) = @_;
721 14 for ($lhs, $rhs) {
722 28 s/^.*#//;
723 }
724 14 ▶ if ($lhs eq $rhs) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lhs eq $rhs) 6 8 14
725 6 ▶ if (is_base_type($lhs)) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_base_type($lhs)) 6 0 6
726 6 return "http://www.w3.org/2001/XMLSchema#$lhs";
727 }
728 }
729 8 my $cur = $lhs;
730 8 my %ancestors;
731 do {
732 18 $ancestors{$cur}++;
733 18 ▶ if ($cur eq $rhs) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cur eq $rhs) 1 17 18
734 1 ▶ if (is_base_type($cur)) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_base_type($cur)) 1 0 1
735 1 return "http://www.w3.org/2001/XMLSchema#$cur";
736 }
737 }
738 8 ▶ } while ($cur = $type_hierarchy{$cur});
Branch: 1 branch
BranchTrueFalseTotal
$cur = $type_hierarchy{$cur} and do { do { ++$ancestors{$cur}; if ($cur eq $rhs) { if (is_base_type($cur)) { return "http://www.w3.org/2001/XMLSchema#$cur"; } ; } } } 10 7 17
739  
740 7 $cur = $rhs;
741 7 my $seen_float = 0;
742 7 my $seen_decimal = 0;
743
744 7 ▶ while ($cur = $type_hierarchy{$cur}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cur = $type_hierarchy{$cur}) 13 3 16
745 13 ▶ if (exists $ancestors{$cur}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ancestors{$cur}) 5 8 13
746 5 ▶ if (is_base_type($cur)) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_base_type($cur)) 3 2 5
747 3 return "http://www.w3.org/2001/XMLSchema#$cur";
748 }
749 }
750 10 ▶ if ($cur eq 'float') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cur eq "float") 0 10 10
751 0 $seen_float++;
752 0 ▶ if (my $r = _lowest_base_type($lhs, 'double')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $r = _lowest_base_type($lhs, "double")) 0 0 0
753 0 return $r;
754 }
755 }
756 10 ▶ if ($cur eq 'decimal') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cur eq "decimal") 1 9 10
757 1 $seen_decimal++;
758 1 ▶ if (my $r = _lowest_base_type($lhs, 'float')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $r = _lowest_base_type($lhs, "float")) 1 0 1
759 1 return $r;
760 }
761 0 ▶ if (my $r = _lowest_base_type($lhs, 'double')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $r = _lowest_base_type($lhs, "double")) 0 0 0
762 0 return $r;
763 }
764 }
765 }
766 3 ▶ if ($ancestors{'float'}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ancestors{'float'}) { } 2 1 3
elsif ($seen_float) { } 0 1 1
767 # seen a float type on the lhs
768 2 ▶ return "http://www.w3.org/2001/XMLSchema#double" if ($rhs eq 'float');
Branch: 1 branch
BranchTrueFalseTotal
if $rhs eq "float" 0 2 2
769 } elsif ($seen_float) {
770 # seen a float type on the rhs
771 0 ▶ return "http://www.w3.org/2001/XMLSchema#double" if (exists $ancestors{'float'});
Branch: 1 branch
BranchTrueFalseTotal
if exists $ancestors{"float"} 0 0 0
772 }
773 3 ▶ if ($ancestors{'decimal'}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ancestors{'decimal'}) { } 1 2 3
elsif ($seen_decimal) { } 0 2 2
774 # seen a decimal type on the lhs
775 1 ▶ return "http://www.w3.org/2001/XMLSchema#float" if ($rhs eq "float");
Branch: 1 branch
BranchTrueFalseTotal
if $rhs eq "float" 1 0 1
776 0 ▶ return "http://www.w3.org/2001/XMLSchema#double" if ($rhs eq "double");
Branch: 1 branch
BranchTrueFalseTotal
if $rhs eq "double" 0 0 0
777 } elsif ($seen_decimal) {
778 # seen a decimal type on the rhs
779 0 ▶ return "http://www.w3.org/2001/XMLSchema#float" if (exists $ancestors{"float"});
Branch: 1 branch
BranchTrueFalseTotal
if exists $ancestors{"float"} 0 0 0
780 0 ▶ return "http://www.w3.org/2001/XMLSchema#double" if (exists $ancestors{"double"});
Branch: 1 branch
BranchTrueFalseTotal
if exists $ancestors{"double"} 0 0 0
781 }
782 2 ▶ if ($rhs eq 'float') {
Branch: 2 branches
BranchTrueFalseTotal
if ($rhs eq 'float') { } 0 2 2
elsif ($rhs eq 'decimal') { } 1 1 2
783 0 $seen_float++;
784 0 ▶ if (my $r = _lowest_base_type($lhs, 'double')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $r = _lowest_base_type($lhs, "double")) 0 0 0
785 0 return $r;
786 }
787 } elsif ($rhs eq 'decimal') {
788 1 $seen_decimal++;
789 1 ▶ if (my $r = _lowest_base_type($lhs, 'float')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $r = _lowest_base_type($lhs, "float")) 1 0 1
790 1 return $r;
791 }
792 0 ▶ if (my $r = _lowest_base_type($lhs, 'double')) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $r = _lowest_base_type($lhs, "double")) 0 0 0
793 0 return $r;
794 }
795 }
796 1 return;
797 }
798 2 ▶ sub _lca {
Subroutine _lca: called CC=15 SCAR=42.5
799 2 my ($lhs, $rhs) = @_;
800 2 for ($lhs, $rhs) {
801 4 s/^.*#//;
802 }
803 2 ▶ return "http://www.w3.org/2001/XMLSchema#$lhs" if ($lhs eq $rhs);
Branch: 1 branch
BranchTrueFalseTotal
if $lhs eq $rhs 0 2 2
804 2 my $cur = $lhs;
805 2 my %ancestors = ($cur => 1);
806 2 ▶ while ($cur = $type_hierarchy{$cur}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cur = $type_hierarchy{$cur}) 0 2 2
807 0 $ancestors{$cur}++;
808 0 ▶ return "http://www.w3.org/2001/XMLSchema#$cur" if ($cur eq $rhs);
Branch: 1 branch
BranchTrueFalseTotal
if $cur eq $rhs 0 0 0
809 }
810 2 $cur = $rhs;
811 2 my $seen_float = 0;
812 2 my $seen_decimal = 0;
813 2 ▶ while ($cur = $type_hierarchy{$cur}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cur = $type_hierarchy{$cur}) 0 2 2
814 0 ▶ $seen_float++ if ($cur eq 'float');
Branch: 1 branch
BranchTrueFalseTotal
if $cur eq "float" 0 0 0
815 0 ▶ $seen_decimal++ if ($cur eq 'decimal');
Branch: 1 branch
BranchTrueFalseTotal
if $cur eq "decimal" 0 0 0
816 0 ▶ return "http://www.w3.org/2001/XMLSchema#$cur" if exists $ancestors{$cur};
Branch: 1 branch
BranchTrueFalseTotal
if exists $ancestors{$cur} 0 0 0
817 }
818 2 ▶ if ($ancestors{'decimal'}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ancestors{'decimal'}) { } 0 2 2
elsif ($seen_decimal) { } 0 2 2
819 # seen decimal on the lhs
820 0 ▶ return "http://www.w3.org/2001/XMLSchema#float" if ($rhs eq "float");
Branch: 1 branch
BranchTrueFalseTotal
if $rhs eq "float" 0 0 0
821 0 ▶ return "http://www.w3.org/2001/XMLSchema#double" if ($rhs eq "double");
Branch: 1 branch
BranchTrueFalseTotal
if $rhs eq "double" 0 0 0
822 } elsif ($seen_decimal) {
823 # seen decimal on the rhs
824 0 ▶ return "http://www.w3.org/2001/XMLSchema#float" if (exists $ancestors{"float"});
Branch: 1 branch
BranchTrueFalseTotal
if exists $ancestors{"float"} 0 0 0
825 0 ▶ return "http://www.w3.org/2001/XMLSchema#double" if (exists $ancestors{"double"});
Branch: 1 branch
BranchTrueFalseTotal
if exists $ancestors{"double"} 0 0 0
826 }
827 2 return;
828 }
829 27 ▶ sub binary_promotion_type {
Subroutine binary_promotion_type: called CC=12 SCAR=28.7
Pod undocumented
830 27 my $self = shift;
831 27 my $rhs = shift;
832 27 my $op = shift;
833
834 27 ▶ if ($op =~ m<^[-+*]$>) {
Branch: 2 branches
BranchTrueFalseTotal
if ($op =~ /^[-+*]$/u) { } 12 15 27
elsif ($op eq '/') { } 15 0 15
835 # return common numeric type
836 12 ▶ if (my $lbtype = _lowest_base_type($self->datatype->value, $rhs->datatype->value)) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $lbtype = _lowest_base_type($self->datatype->value, $rhs->datatype->value)) { } 11 1 12
elsif (my $lctype = _lca($self->datatype->value, $rhs->datatype->value)) { } 0 1 1
837 11 return $lbtype;
838 } elsif (my $lctype = _lca($self->datatype->value, $rhs->datatype->value)) {
839 0 return $lctype;
840 }
841 1 return 'http://www.w3.org/2001/XMLSchema#double';
842 } elsif ($op eq '/') {
843 15 ▶ if ($self->is_integer_type and $rhs->is_integer_type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_integer_type and $rhs->is_integer_type) 14 1 15
Condition66%2/3
$self->is_integer_type and $rhs->is_integer_type
!ll&&!rl&&r
1014
MC/DC50%1/2
$self->is_integer_type and $rhs->is_integer_type
$self->is_integer_type $rhs->is_integer_type
Truth table66%2/3
A and B
A= $self->is_integer_typeB= $rhs->is_integer_type
ABresult
0X0
100
111
844 # return xsd:decimal if both operands are integers
845 14 return 'http://www.w3.org/2001/XMLSchema#decimal';
846 }
847 1 ▶ if (my $type = _lca($self->datatype->value, $rhs->datatype->value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $type = _lca($self->datatype->value, $rhs->datatype->value)) { } 0 1 1
848 0 return $type;
849 } else {
850 1 my $lt = $self->datatype->value;
851 1 my $rt = $rhs->datatype->value;
852 1 ▶ if ($lt =~ /#double$/ or $rt =~ /#double$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($lt =~ /#double$/u or $rt =~ /#double$/u) { } 0 1 1
elsif ($lt =~ /#float$/u or $rt =~ /#float$/u) { } 1 0 1
Condition33%1/3
$lt =~ /#double$/u or $rt =~ /#double$/u
l!l&&r!l&&!r
001
MC/DC0%0/2
$lt =~ /#double$/u or $rt =~ /#double$/u
$lt =~ /#double$/u $rt =~ /#double$/u
Truth table33%1/3
A or B
A= $lt =~ /#double$/uB= $rt =~ /#double$/u
ABresult
1X1
011
000
853 0 return "http://www.w3.org/2001/XMLSchema#double";
854 ▶ } elsif ($lt =~ /#float$/ or $rt =~ /#float$/) {
Condition33%1/3
$lt =~ /#float$/u or $rt =~ /#float$/u
l!l&&r!l&&!r
100
MC/DC0%0/2
$lt =~ /#float$/u or $rt =~ /#float$/u
$lt =~ /#float$/u $rt =~ /#float$/u
Truth table33%1/3
A or B
A= $lt =~ /#float$/uB= $rt =~ /#float$/u
ABresult
1X1
011
000
855 1 return "http://www.w3.org/2001/XMLSchema#float";
856 }
857 }
858 0 return 'http://www.w3.org/2001/XMLSchema#double';
859 }
860 0 die "Unexpected numeric operation in binary_promotion_type: $op";
861 }
862 }
863 50 with 'Attean::API::Literal', 'Attean::API::CanonicalizingLiteral';
864 }
865  
866 50 package Attean::API::Blank 0.040 {
867 50 ▶ use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
868 50 ▶ use AtteanX::SPARQL::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
869 50 ▶ use AtteanX::SPARQL::Token;
Subroutine BEGIN: called CC=1 SCAR=0.0
870 50 ▶ use Attean::API::Query;
Subroutine BEGIN: called CC=1 SCAR=0.0
871  
872 50 ▶ use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
873
874 1 ▶ sub ebv {
Subroutine ebv: called CC=1 SCAR=0.0
Pod documented
875 1 die "TypeError: EBV of a blank";
876 }
877 50 with 'Attean::API::Term', 'Attean::API::BlankOrIRI', 'Attean::API::BlankOrIRIOrTriple';
878 ;
879 50 with 'Attean::API::SPARQLSerializable';
880
881 14 ▶ sub sparql_tokens {
Subroutine sparql_tokens: called CC=1 SCAR=0.0
Pod undocumented
882 14 my $self = shift;
883 14 my $t = AtteanX::SPARQL::Token->fast_constructor( BNODE, -1, -1, -1, -1, [$self->value] );
884 14 return Attean::ListIterator->new( values => [$t], item_type => 'AtteanX::SPARQL::Token' );
885 }
886
887 3 ▶ sub compare {
Subroutine compare: called CC=3 SCAR=11.4
Pod documented
888 3 my ($a, $b) = @_;
889 3 ▶ return 1 unless blessed($b);
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($b) 0 3 3
890 3 ▶ return -1 unless ($b->does('Attean::API::Blank'));
Branch: 1 branch
BranchTrueFalseTotal
unless $b->does("Attean::API::Blank") 0 3 3
891 3 return ($a->value cmp $b->value);
892 }
893  
894 =item C<< sameTerms( $other ) >>
895  
896 =cut
897  
898 0 ▶ sub sameTerms {
Subroutine sameTerms: not called CC=3 SCAR=24.8
Pod undocumented
899 0 my $lhs = shift;
900 0 my $rhs = shift;
901 0 ▶ return 0 unless ($rhs->does('Attean::API::Blank'));
Branch: 1 branch
BranchTrueFalseTotal
unless $rhs->does("Attean::API::Blank") 0 0 0
902 0 ▶ return 0 unless ($lhs->value eq $rhs->value);
Branch: 1 branch
BranchTrueFalseTotal
unless $lhs->value eq $rhs->value 0 0 0
903 0 return 1;
904 }
905 }
906  
907 50 package Attean::API::IRI 0.040 {
908 50 ▶ use IRI;
Subroutine BEGIN: called CC=1 SCAR=0.0
909 50 ▶ use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
910 50 ▶ use AtteanX::SPARQL::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
911 50 ▶ use AtteanX::SPARQL::Token;
Subroutine BEGIN: called CC=1 SCAR=0.0
912 50 ▶ use Attean::API::Query;
Subroutine BEGIN: called CC=1 SCAR=0.0
913  
914 50 ▶ use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
915
916 1 ▶ sub ebv {
Subroutine ebv: called CC=1 SCAR=0.0
Pod documented
917 1 die "TypeError: EBV of a blank";
918 }
919 50 with 'Attean::API::Term', 'Attean::API::BlankOrIRI', 'Attean::API::BlankOrIRIOrTriple';
920 50 with 'Attean::API::SPARQLSerializable';
921
922 248 ▶ sub sparql_tokens {
Subroutine sparql_tokens: called CC=2 SCAR=7.2
Pod undocumented
923 248 my $self = shift;
924 248 my @tokens;
925 248 ▶ if ($self->value eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->value eq '') { } 0 248 248
926 0 push(@tokens, AtteanX::Parser::Turtle::Token->a);
927 } else {
928 248 push(@tokens, AtteanX::SPARQL::Token->fast_constructor( IRI, -1, -1, -1, -1, [$self->value] ));
929 }
930 248 return Attean::ListIterator->new( values => \@tokens, item_type => 'AtteanX::SPARQL::Token' );
931 }
932
933 13 ▶ sub compare {
Subroutine compare: called CC=5 SCAR=18.1
Pod documented
934 13 my ($a, $b) = @_;
935 13 ▶ return 1 unless blessed($b);
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($b) 0 13 13
936 13 ▶ return -1 if ($b->does('Attean::API::Literal') or $b->does('Attean::API::Binding'));
Branch: 1 branch
BranchTrueFalseTotal
if $b->does("Attean::API::Literal") or $b->does("Attean::API::Binding") 0 13 13
Condition33%1/3
$b->does("Attean::API::Literal") or $b->does("Attean::API::Binding")
l!l&&r!l&&!r
0013
MC/DC0%0/2
$b->does("Attean::API::Literal") or $b->does("Attean::API::Binding")
$b->does("Attean::API::Literal") $b->does("Attean::API::Binding")
Truth table33%1/3
A or B
A= $b->does("Attean::API::Literal")B= $b->does("Attean::API::Binding")
ABresult
1X1
011
000
937 13 ▶ return 1 unless ($b->does('Attean::API::IRI'));
Branch: 1 branch
BranchTrueFalseTotal
unless $b->does("Attean::API::IRI") 0 13 13
938 13 return ($a->value cmp $b->value);
939 }
940
941 =item C<< sameTerms( $other ) >>
942  
943 =cut
944  
945 0 ▶ sub sameTerms {
Subroutine sameTerms: not called CC=3 SCAR=24.8
Pod undocumented
946 0 my $lhs = shift;
947 0 my $rhs = shift;
948 0 ▶ return 0 unless ($rhs->does('Attean::API::IRI'));
Branch: 1 branch
BranchTrueFalseTotal
unless $rhs->does("Attean::API::IRI") 0 0 0
949 0 ▶ return 0 unless ($lhs->value eq $rhs->value);
Branch: 1 branch
BranchTrueFalseTotal
unless $lhs->value eq $rhs->value 0 0 0
950 0 return 1;
951 }
952  
953 433 ▶ sub _ntriples_string {
Subroutine _ntriples_string: called CC=1 SCAR=0.0
954 433 my $self = shift;
955 433 return sprintf('<%s>', $self->__ntriples_string);
956 }
957  
958 1 ▶ around as_sparql => sub {
Subroutine __ANON__: called CC=2 SCAR=7.4
959 1 my $orig = shift;
960 1 my $self = shift;
961
962 1 ▶ if ($self->value eq 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->value eq "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") 0 1 1
963 0 return 'a';
964 }
965  
966 1 return $self->$orig(@_);
967 50 };
968 }
969  
970 50 1;
971  
972 __END__
« AtteanX/Functions/CompositeLists.pm ↑ Summary AtteanX/Parser/Turtle.pm »