Skip to content

Commit

Permalink
Additional NQuads tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Jan 8, 2024
1 parent a8a2bfe commit 1322f67
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
9 changes: 8 additions & 1 deletion script/tc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ def run_tc(tc, **options)
if tc.evaluate? && result.nil?
output_graph = RDF::Repository.load(tc.result, format: :nquads, base_uri: tc.base, rdfstar: true)
result = graph.isomorphic_with?(output_graph) ? "passed" : "failed"
elsif tc.c14n? && result.nil?
c14n = RDF::NQuads::Writer.buffer {|w| w << graph}
result = c14n == tc.expected ? "passed" : "failed"
else
result ||= "passed"
end
Expand Down Expand Up @@ -194,7 +197,11 @@ opts.each do |opt, arg|
end

manifests = if options[:nquads]
[Fixtures::SuiteTest::BASE + "rdf11/rdf-n-quads/"]
[
Fixtures::SuiteTest::BASE + "rdf11/rdf-n-quads/",
Fixtures::SuiteTest::BASE + "rdf12/rdf-n-quads/syntax/",
Fixtures::SuiteTest::BASE + "rdf12/rdf-n-quads/c14n/",
]
else
[
Fixtures::SuiteTest::BASE + "rdf11/rdf-trig/",
Expand Down
15 changes: 12 additions & 3 deletions spec/nquads_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
describe "w3c N-Quads tests" do
require 'suite_helper'

%w(rdf11/rdf-n-quads/manifest.ttl).each do |man|
%w(
rdf11/rdf-n-quads/manifest.ttl
rdf12/rdf-n-quads/syntax/manifest.ttl
rdf12/rdf-n-quads/c14n/manifest.ttl
).each do |man|
Fixtures::SuiteTest::Manifest.open(Fixtures::SuiteTest::BASE + man) do |m|
describe m.comment do
m.entries.each do |t|
Expand All @@ -15,7 +19,7 @@
t.logger.info t.inspect
t.logger.info "source:\n#{t.input}"

reader = RDF::NQuads::Reader.new(t.input, logger: t.logger, validate: true)
reader = RDF::NQuads::Reader.new(t.input, rdfstar: true, logger: t.logger, validate: true)

repo = RDF::Repository.new

Expand All @@ -29,7 +33,12 @@
expect {repo << reader}.to raise_error(RDF::ReaderError)
end

expect(repo).to be_a(RDF::Enumerable)
if t.c14n?
c14n = RDF::NQuads::Writer.buffer {|w| w << repo}
expect(c14n).to eql t.expected
else
expect(repo).to be_a(RDF::Enumerable)
end
end
end
end
Expand Down
6 changes: 5 additions & 1 deletion spec/suite_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ def positive_test?
def negative_test?
!positive_test?
end


def c14n?
!!Array(attributes['@type']).join(" ").match(/C14N/)
end

def inspect
super.sub('>', "\n" +
" syntax?: #{syntax?.inspect}\n" +
Expand Down

0 comments on commit 1322f67

Please sign in to comment.