Skip to content

Commit

Permalink
More RDF-star tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Aug 28, 2024
1 parent be606f6 commit e105077
Showing 1 changed file with 134 additions and 7 deletions.
141 changes: 134 additions & 7 deletions spec/reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,6 @@
it name do
if nt.is_a?(String)
expect_graph = RDF::Graph.new {|g| g << RDF::NTriples::Reader.new(nt, rdfstar: true)}
g = parse(ttl, rdfstar: true, validate: true)
expect(parse(ttl, rdfstar: true, validate: true)).to be_equivalent_graph(expect_graph, logger: @logger)
else
expect { parse(ttl, rdfstar: true, validate: true) }.to raise_error(nt)
Expand All @@ -1040,6 +1039,15 @@

context "reified triples" do
{
"solo-iii" => [
%(
@prefix ex: <http://example/> .
<<ex:s1 ex:p1 ex:o1>> .
),
%(
_:anon <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<(<http://example/s1> <http://example/p1> <http://example/o1>)>> .
)
],
"subject-iii" => [
%(
@prefix ex: <http://example/> .
Expand Down Expand Up @@ -1211,11 +1219,17 @@
),
RDF::ReaderError
],
"list form of reifier": [
%(
@prefix ex: <http://example/> .
ex:s ex:p <<ex:s1 ex:p1 [] ~ (ex:r1 ex:r2) >> .
),
RDF::ReaderError
],
}.each do |name, (ttl, nt)|
it name do
if nt.is_a?(String)
expect_graph = RDF::Graph.new {|g| g << RDF::NTriples::Reader.new(nt, rdfstar: true)}
g = parse(ttl, rdfstar: true, validate: true)
expect(parse(ttl, rdfstar: true, validate: true)).to be_equivalent_graph(expect_graph, logger: @logger)
else
expect { parse(ttl, rdfstar: true, validate: true) }.to raise_error(nt)
Expand All @@ -1237,7 +1251,7 @@
_:anon <http://example/r> <http://example/z> .
)
],
"IRI identifier": [
"IRI reifier": [
%(
PREFIX : <http://example/>
:s :p :o ~:id {| :r :z |} .
Expand All @@ -1248,7 +1262,7 @@
<http://example/id> <http://example/r> <http://example/z> .
)
],
"BNode identifier": [
"BNode reifier": [
%(
PREFIX : <http://example/>
:s :p :o ~ _:id {| :r :z |} .
Expand All @@ -1259,7 +1273,58 @@
_:id <http://example/r> <http://example/z> .
)
],
'turtle-star-annotation-2' => [
'predicateObjectList after annotation' => [
%(
PREFIX : <http://example/>
:s :p :o {| :x :y |} ; :q :r .
),
%(
<http://example/s> <http://example/p> <http://example/o> .
_:anon <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<(<http://example/s> <http://example/p> <http://example/o>)>> .
_:anon <http://example/x> <http://example/y> .
<http://example/s> <http://example/q> <http://example/r> .
)
],
'reifier only': [
%(
PREFIX : <http://example/>
:s :p :o ~:e .
),
%(
<http://example/s> <http://example/p> <http://example/o> .
<http://example/e> <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<(<http://example/s> <http://example/p> <http://example/o>)>> .
)
],
'empty reifier': [
%(
PREFIX : <http://example/>
:s :p :o ~ .
),
%(
<http://example/s> <http://example/p> <http://example/o> .
_:anon <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<(<http://example/s> <http://example/p> <http://example/o>)>> .
)
],
'multiple statements': [
%(
PREFIX : <http://example/>
:s :p :o {| :q1 :r1 ; :q2 :r2 ; |} .
),
%(
<http://example/s> <http://example/p> <http://example/o> .
_:anon <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<(<http://example/s> <http://example/p> <http://example/o>)>> .
_:anon <http://example/q1> <http://example/r1> .
_:anon <http://example/q2> <http://example/r2> .
)
],
'no statements': [
%(
PREFIX : <http://example/>
:s :p :o {| |} .
),
RDF::ReaderError
],
'turtle-star-annotation-2': [
%(
PREFIX : <http://example/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
Expand All @@ -1283,7 +1348,7 @@
_:anno2 <http://example/date> "2020-12-31"^^<http://www.w3.org/2001/XMLSchema#date> .
)
],
'multiple annotations' => [
'multiple annotations with iri refiers': [
%(
PREFIX : <http://example/>
:s :p :o ~ :id1 {| :r :z |} ~ :id2 {| :s :w |}.
Expand All @@ -1296,7 +1361,20 @@
<http://example/id2> <http://example/s> <http://example/w> .
)
],
'multiple reifiers' => [
'multiple annotations with empty refiers': [
%(
PREFIX : <http://example/>
:s :p :o ~ {| :r :z |} ~ {| :s :w |}.
),
%(
<http://example/s> <http://example/p> <http://example/o> .
_:bn1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<(<http://example/s> <http://example/p> <http://example/o>)>> .
_:bn1 <http://example/r> <http://example/z> .
_:bn2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<(<http://example/s> <http://example/p> <http://example/o>)>> .
_:bn2 <http://example/s> <http://example/w> .
)
],
'multiple IRI reifiers': [
%(
PREFIX : <http://example/>
:s :p :o ~ :id1 ~:id2 ~ .
Expand All @@ -1308,6 +1386,55 @@
_:anon <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<(<http://example/s> <http://example/p> <http://example/o>)>> .
)
],
'multiple mixed reifiers': [
%(
PREFIX : <http://example/>
:s :p :o ~:e ~ .
),
%(
<http://example/s> <http://example/p> <http://example/o> .
<http://example/e> <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<(<http://example/s> <http://example/p> <http://example/o>)>> .
_:bn1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<(<http://example/s> <http://example/p> <http://example/o>)>> .
)
],
'empty reifier and empty reified annotation block': [
%(
PREFIX : <http://example/>
:s :p :o ~ ~ {| :y :z |} .
),
%(
<http://example/s> <http://example/p> <http://example/o> .
_:bn1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<(<http://example/s> <http://example/p> <http://example/o>)>> .
_:bn2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<(<http://example/s> <http://example/p> <http://example/o>)>> .
_:bn2 <http://example/y> <http://example/z> .
)
],
'mix of reifiers and annotation blocks': [
%(
PREFIX : <http://example/>
:s :p :o ~:e {| :q :r |} ~:r {| :q :r |} ~:r .
),
%(
<http://example/s> <http://example/p> <http://example/o> .
<http://example/e> <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<(<http://example/s> <http://example/p> <http://example/o>)>> .
<http://example/e> <http://example/q> <http://example/r> .
<http://example/r> <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<(<http://example/s> <http://example/p> <http://example/o>)>> .
<http://example/r> <http://example/q> <http://example/r> .
)
],
'mix of annotation blocks': [
%(
PREFIX : <http://example/>
:s :p :o {| :q :r |} {| :q :r |} .
),
%(
<http://example/s> <http://example/p> <http://example/o> .
_:bn1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<(<http://example/s> <http://example/p> <http://example/o>)>> .
_:bn1 <http://example/q> <http://example/r> .
_:bn2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies> <<(<http://example/s> <http://example/p> <http://example/o>)>> .
_:bn2 <http://example/q> <http://example/r> .
)
],
}.each do |name, (ttl, nt)|
it name do
if nt.is_a?(String)
Expand Down

0 comments on commit e105077

Please sign in to comment.