diff --git a/spec/reader_spec.rb b/spec/reader_spec.rb index 2cf28ae..ca7b7b2 100644 --- a/spec/reader_spec.rb +++ b/spec/reader_spec.rb @@ -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) @@ -1040,6 +1039,15 @@ context "reified triples" do { + "solo-iii" => [ + %( + @prefix ex: . + <> . + ), + %( + _:anon <<( )>> . + ) + ], "subject-iii" => [ %( @prefix ex: . @@ -1211,11 +1219,17 @@ ), RDF::ReaderError ], + "list form of reifier": [ + %( + @prefix ex: . + ex:s ex:p <> . + ), + 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) @@ -1237,7 +1251,7 @@ _:anon . ) ], - "IRI identifier": [ + "IRI reifier": [ %( PREFIX : :s :p :o ~:id {| :r :z |} . @@ -1248,7 +1262,7 @@ . ) ], - "BNode identifier": [ + "BNode reifier": [ %( PREFIX : :s :p :o ~ _:id {| :r :z |} . @@ -1259,7 +1273,58 @@ _:id . ) ], - 'turtle-star-annotation-2' => [ + 'predicateObjectList after annotation' => [ + %( + PREFIX : + :s :p :o {| :x :y |} ; :q :r . + ), + %( + . + _:anon <<( )>> . + _:anon . + . + ) + ], + 'reifier only': [ + %( + PREFIX : + :s :p :o ~:e . + ), + %( + . + <<( )>> . + ) + ], + 'empty reifier': [ + %( + PREFIX : + :s :p :o ~ . + ), + %( + . + _:anon <<( )>> . + ) + ], + 'multiple statements': [ + %( + PREFIX : + :s :p :o {| :q1 :r1 ; :q2 :r2 ; |} . + ), + %( + . + _:anon <<( )>> . + _:anon . + _:anon . + ) + ], + 'no statements': [ + %( + PREFIX : + :s :p :o {| |} . + ), + RDF::ReaderError + ], + 'turtle-star-annotation-2': [ %( PREFIX : PREFIX xsd: @@ -1283,7 +1348,7 @@ _:anno2 "2020-12-31"^^ . ) ], - 'multiple annotations' => [ + 'multiple annotations with iri refiers': [ %( PREFIX : :s :p :o ~ :id1 {| :r :z |} ~ :id2 {| :s :w |}. @@ -1296,7 +1361,20 @@ . ) ], - 'multiple reifiers' => [ + 'multiple annotations with empty refiers': [ + %( + PREFIX : + :s :p :o ~ {| :r :z |} ~ {| :s :w |}. + ), + %( + . + _:bn1 <<( )>> . + _:bn1 . + _:bn2 <<( )>> . + _:bn2 . + ) + ], + 'multiple IRI reifiers': [ %( PREFIX : :s :p :o ~ :id1 ~:id2 ~ . @@ -1308,6 +1386,55 @@ _:anon <<( )>> . ) ], + 'multiple mixed reifiers': [ + %( + PREFIX : + :s :p :o ~:e ~ . + ), + %( + . + <<( )>> . + _:bn1 <<( )>> . + ) + ], + 'empty reifier and empty reified annotation block': [ + %( + PREFIX : + :s :p :o ~ ~ {| :y :z |} . + ), + %( + . + _:bn1 <<( )>> . + _:bn2 <<( )>> . + _:bn2 . + ) + ], + 'mix of reifiers and annotation blocks': [ + %( + PREFIX : + :s :p :o ~:e {| :q :r |} ~:r {| :q :r |} ~:r . + ), + %( + . + <<( )>> . + . + <<( )>> . + . + ) + ], + 'mix of annotation blocks': [ + %( + PREFIX : + :s :p :o {| :q :r |} {| :q :r |} . + ), + %( + . + _:bn1 <<( )>> . + _:bn1 . + _:bn2 <<( )>> . + _:bn2 . + ) + ], }.each do |name, (ttl, nt)| it name do if nt.is_a?(String)