| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 495 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | my @chars = split(//, $value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | my $string = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | ▶ | while (scalar(@chars)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 20 | my $c = shift(@chars); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 20 | my $o = ord($c); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 20 | ▶ | if ($o < 0x8) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 12 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 268 | my $type = $dt->value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 268 | ▶ | if ($type eq 'http://www.w3.org/2001/XMLSchema#string') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition66%2/3
$self->does("Attean::API::NumericLiteral") and $dt->value eq "http://www.w3.org/2001/XMLSchema#integer"
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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 16 | ▶ | if ($self->value =~ /^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 6 | my $lex = "$lang"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 6 | ▶ | if (my $d = $self->base_dir) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 26 | ▶ | if ($value eq 'true' or $value eq '1') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$value eq "true" or $value eq 1
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 14 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | ▶ | } elsif ($value eq 'false' or $value eq '0') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$value eq "false" or $value eq 0
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 1 | ▶ | return 1 unless ($b->does('Attean::API::Literal') or $b->does('Attean::API::Binding')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$b->does("Attean::API::Literal") or $b->does("Attean::API::Binding")
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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 1 | ▶ | return -1 if ($b->does('Attean::API::Binding')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
($a->language // "") cmp ($b->language // "") or $a->datatype->value cmp $b->datatype->value
$a->language // ""
$b->language // ""
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
Truth table50%1/2
A
A= $b->language
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%3/9
$a->can("datatype") and $b->can("datatype") and my $adt = $a->datatype and my $bdt = $b->datatype
$a->can("datatype") and $b->can("datatype") and my $adt = $a->datatype
$a->can("datatype") and $b->can("datatype")
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 134 | ▶ | if (!$a->is_recognized_type or !$b->is_recognized_type) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$a->is_recognized_type and $b->is_recognized_type
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | return 0 unless ($lhs->value eq $rhs->value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | return 0 unless ($lhs->datatype->value eq $rhs->datatype->value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 50 | ▶ | if ($ENV{ATTEAN_TYPECHECK}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | $args{datatype} = $self->datatype if ($self->datatype); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | foreach my $t (@terms) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | return 0 unless ($t->does('Attean::API::Literal')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | if ($t->language) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | return 0 unless (defined($t->language)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | return 0 unless ($t->language eq $l); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | return 0 unless ($t->datatype->value eq 'http://www.w3.org/2001/XMLSchema#string'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | return 0 if ($t->language); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | return 0 unless (blessed($t->datatype)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | return 0 unless ($t->datatype->value eq 'http://www.w3.org/2001/XMLSchema#string'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | if (my $d = $self->base_dir) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | $lang_key = $l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | if (my $d = $self->base_dir) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | if (my $adt = $a->datetime and my $bdt = $b->datetime) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
my $adt = $a->datetime and my $bdt = $b->datetime
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | return ($value eq 'true' or $value eq '1') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$value eq "true" or $value eq 1
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 8 | ▶ | return ($value eq 'true' or $value eq '1') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$value eq "true" or $value eq 1
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
$b->does("Attean::API::Literal") and not $does_bool
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | if (!$a->is_recognized_type or !$b->is_recognized_type) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$a->is_recognized_type and $b->is_recognized_type
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
$b->does("Attean::API::Literal") and not $does_num
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | if (!$a->is_recognized_type or !$b->is_recognized_type) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$a->is_recognized_type and $b->is_recognized_type
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | return 0 unless (defined $a->numeric_value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | ▶ | return 0 unless (defined $b->numeric_value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
$b->does("Attean::API::Literal") and not $does_num
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | die "TypeError: numeric and non-numeric literals are not comparable"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 1 | ▶ | return 1 unless blessed($b); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 1 | ▶ | return 1 unless ($b->does('Attean::API::Literal') or $b->does('Attean::API::Binding')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$b->does("Attean::API::Literal") or $b->does("Attean::API::Binding")
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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 1 | ▶ | return -1 if ($b->does('Attean::API::Binding')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 1 | ▶ | if ($b->does('Attean::API::NumericLiteral')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 1 | ▶ | if ($value =~ m/^([-+])?(\d+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 1 | ▶ | my $sign = $1 || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$1 || ''
MC/DC0%0/1
$1 || ''
$1
Truth table50%1/2
A
A= $1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 1 | my $num = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 1 | ▶ | $sign = '' if ($sign eq '+'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | } elsif ($type eq 'negativeInteger') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | ▶ | if ($value =~ m/^-(\d+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | } elsif ($type eq 'decimal') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 4 | ▶ | if ($value =~ m/^([-+])?((\d+)([.]\d*)?)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 4 | ▶ | my $sign = $1 || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$1 || ''
MC/DC0%0/1
$1 || ''
$1
Truth table50%1/2
A
A= $1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 4 | my $num = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 4 | my $int = $3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 4 | my $frac = $4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 4 | ▶ | $sign = '' if ($sign eq '+'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 4 | $num =~ s/^0+(\d)/$1/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 4 | $num =~ s/[.](\d+)0+$/.$1/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 4 | ▶ | if ($num =~ /^[.]/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | $num = "0$num"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 4 | ▶ | if ($num !~ /[.]/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 || ''
MC/DC0%0/1
$1 || ''
$1
Truth table0%0/2
A
A= $1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | my $num = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | ▶ | $sign = '' if ($sign eq '+'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | ▶ | return Attean::Literal->float("${sign}$inf") if ($inf); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | ▶ | return Attean::Literal->float($nan) if ($nan); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | } elsif ($type eq 'boolean') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | if ($value =~ m/^(true|false|0|1)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | ▶ | return ($value eq 'true' or $value eq '1') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$value eq "true" or $value eq 1
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | ▶ | return Attean::Literal->double("${sign}$inf") if ($inf); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | return Attean::Literal->double($nan) if ($nan); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 6 | ▶ | if (is_base_type($lhs)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 1 | ▶ | if (is_base_type($cur)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 1 | return "http://www.w3.org/2001/XMLSchema#$cur"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 8 | ▶ | } while ($cur = $type_hierarchy{$cur}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 13 | ▶ | if (exists $ancestors{$cur}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 5 | ▶ | if (is_base_type($cur)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 3 | return "http://www.w3.org/2001/XMLSchema#$cur"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 10 | ▶ | if ($cur eq 'float') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | $seen_float++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | ▶ | if (my $r = _lowest_base_type($lhs, 'double')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 10 | ▶ | if ($cur eq 'decimal') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 1 | $seen_decimal++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 1 | ▶ | if (my $r = _lowest_base_type($lhs, 'float')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 1 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | ▶ | if (my $r = _lowest_base_type($lhs, 'double')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 3 | ▶ | if ($ancestors{'float'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 3 | ▶ | if ($ancestors{'decimal'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | ▶ | return "http://www.w3.org/2001/XMLSchema#double" if ($rhs eq "double"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | ▶ | return "http://www.w3.org/2001/XMLSchema#double" if (exists $ancestors{"double"}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 2 | ▶ | if ($rhs eq 'float') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | $seen_float++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | ▶ | if (my $r = _lowest_base_type($lhs, 'double')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 1 | return $r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | ▶ | if (my $r = _lowest_base_type($lhs, 'double')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 2 | my $cur = $lhs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 2 | my %ancestors = ($cur => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 2 | ▶ | while ($cur = $type_hierarchy{$cur}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | $ancestors{$cur}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | ▶ | return "http://www.w3.org/2001/XMLSchema#$cur" if ($cur eq $rhs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | ▶ | $seen_float++ if ($cur eq 'float'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | ▶ | $seen_decimal++ if ($cur eq 'decimal'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | ▶ | return "http://www.w3.org/2001/XMLSchema#$cur" if exists $ancestors{$cur}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 2 | ▶ | if ($ancestors{'decimal'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | # seen decimal on the lhs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | ▶ | return "http://www.w3.org/2001/XMLSchema#float" if ($rhs eq "float"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | ▶ | return "http://www.w3.org/2001/XMLSchema#double" if ($rhs eq "double"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | ▶ | return "http://www.w3.org/2001/XMLSchema#double" if (exists $ancestors{"double"}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | # return common numeric type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 12 | ▶ | if (my $lbtype = _lowest_base_type($self->datatype->value, $rhs->datatype->value)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition66%2/3
$self->is_integer_type and $rhs->is_integer_type
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
$lt =~ /#double$/u or $rt =~ /#double$/u
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 3 | ▶ | return -1 unless ($b->does('Attean::API::Blank')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | ▶ | return 0 unless ($lhs->value eq $rhs->value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 13 | ▶ | return -1 if ($b->does('Attean::API::Literal') or $b->does('Attean::API::Binding')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$b->does("Attean::API::Literal") or $b->does("Attean::API::Binding")
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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 13 | ▶ | return 1 unless ($b->does('Attean::API::IRI')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | ▶ | return 0 unless ($lhs->value eq $rhs->value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | return 'a'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 1 | return $self->$orig(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 50 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 50 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||