|
6 | 6 | describe "w3c turtle tests" do |
7 | 7 | require 'suite_helper' |
8 | 8 |
|
9 | | - Fixtures::SuiteTest::Manifest.open("https://w3c.github.io/rdf-star/tests/turtle/syntax/manifest.ttl") do |m| |
10 | | - describe m.comment do |
11 | | - m.entries.each do |t| |
12 | | - specify "#{t.name}: #{t.comment}" do |
13 | | - t.logger = RDF::Spec.logger |
14 | | - t.logger.info t.inspect |
15 | | - t.logger.info "source:\n#{t.input}" |
| 9 | + %w(nt/syntax turtle/syntax turtle/eval).each do |man| |
| 10 | + Fixtures::SuiteTest::Manifest.open("https://w3c.github.io/rdf-star/tests/#{man}/manifest.ttl") do |m| |
| 11 | + describe [m.label, m.comment].compact.join(': ') do |
| 12 | + m.entries.each do |t| |
| 13 | + specify "#{t.name}: #{t.comment}" do |
| 14 | + t.logger = RDF::Spec.logger |
| 15 | + t.logger.info t.inspect |
| 16 | + t.logger.info "source:\n#{t.input}" |
16 | 17 |
|
17 | | - reader = RDF::Turtle::Reader.new(t.input, |
18 | | - base_uri: t.base, |
19 | | - canonicalize: false, |
20 | | - validate: true, |
21 | | - rdfstar: true, |
22 | | - logger: t.logger) |
| 18 | + reader_class = t.ntriples? ? RDF::NTriples::Reader : RDF::Turtle::Reader |
23 | 19 |
|
24 | | - graph = RDF::Repository.new |
| 20 | + reader = reader_class.new(t.input, |
| 21 | + base_uri: t.base, |
| 22 | + canonicalize: false, |
| 23 | + validate: true, |
| 24 | + rdfstar: true, |
| 25 | + logger: t.logger) |
25 | 26 |
|
26 | | - if t.positive_test? |
27 | | - begin |
28 | | - graph << reader |
29 | | - rescue Exception => e |
30 | | - expect(e.message).to produce("Not exception #{e.inspect}", t) |
31 | | - end |
| 27 | + graph = RDF::Repository.new |
| 28 | + |
| 29 | + if t.positive_test? |
| 30 | + begin |
| 31 | + graph << reader |
| 32 | + rescue Exception => e |
| 33 | + expect(e.message).to produce("Not exception #{e.inspect}", t) |
| 34 | + end |
32 | 35 |
|
33 | | - if t.evaluate? |
34 | | - output_graph = RDF::Repository.load(t.result, format: :ntriples, base_uri: t.base) |
35 | | - expect(graph).to be_equivalent_graph(output_graph, t) |
| 36 | + if t.evaluate? |
| 37 | + output_graph = RDF::Repository.load(t.result, format: :ntriples, rdfstar: true, base_uri: t.base) |
| 38 | + expect(graph).to be_equivalent_graph(output_graph, t) |
| 39 | + else |
| 40 | + expect(graph).to be_a(RDF::Enumerable) |
| 41 | + end |
36 | 42 | else |
37 | | - expect(graph).to be_a(RDF::Enumerable) |
| 43 | + expect { |
| 44 | + graph << reader |
| 45 | + expect(graph.dump(:ntriples)).to produce("not this", t) |
| 46 | + }.to raise_error(RDF::ReaderError) |
38 | 47 | end |
39 | | - else |
40 | | - expect { |
41 | | - graph << reader |
42 | | - expect(graph.dump(:ntriples)).to produce("not this", t) |
43 | | - }.to raise_error(RDF::ReaderError) |
44 | 48 | end |
45 | 49 | end |
46 | 50 | end |
|
0 commit comments