Skip to content

Instantly share code, notes, and snippets.

@artob
Created October 17, 2010 12:22
Show Gist options
  • Save artob/630798 to your computer and use it in GitHub Desktop.
Save artob/630798 to your computer and use it in GitHub Desktop.
DAWG test suite runner for SPARQL::Grammar::Parser
require File.join(File.dirname(__FILE__), 'spec_helper')
DAWG = RDF::Vocabulary.new('http://www.w3.org/2001/sw/DataAccess/tests/test-dawg#')
MF = RDF::Vocabulary.new('http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#')
QT = RDF::Vocabulary.new('http://www.w3.org/2001/sw/DataAccess/tests/test-query#')
RS = RDF::Vocabulary.new('http://www.w3.org/2001/sw/DataAccess/tests/result-set#')
describe SPARQL::Grammar::Parser do
file = File.expand_path('./spec/dawg-test-suite/data-r2/manifest-syntax.ttl')
url = RDF::URI("file://#{file}")
data = RDF::Repository.load(file, :base_uri => url)
manifests = RDF::List.new(data.query([url, MF.include]).first_object, data)
manifests.each do |manifest|
data = RDF::Repository.load(manifest.to_s[('file://'.size)..-1], :base_uri => manifest) # FIXME
manifest_comment = data.query([manifest, RDF::RDFS.comment]).first_object
context "when parsing the DAWG #{manifest_comment.to_s.downcase}" do
entries = RDF::List.new(data.query([manifest, MF.entries]).first_object, data)
entries.each do |entry|
entry_type = data.query([entry, RDF.type]).first_object
entry_name = data.query([entry, MF.name]).first_object
entry_comment = data.query([entry, RDF::RDFS.comment]).first_object
entry_action = data.query([entry, MF.action]).first_object
entry_approval = data.query([entry, DAWG.approval]).first_object
entry_query = File.read(entry_action.to_s[('file://'.size)..-1])
case entry_type
when MF.PositiveSyntaxTest
context "the #{entry.fragment} test" do
it "should accept the input #{entry_query.inspect}" do
# TODO
end
end
when MF.NegativeSyntaxTest
context "the #{entry.fragment} test" do
should = entry_comment ?
"should reject the input #{entry_query.inspect} (#{entry_comment})" :
"should reject the input #{entry_query.inspect}"
it should do
# TODO
end
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment