@@ -8,8 +8,6 @@ module RDF::Util
88 module File
99 REMOTE_PATH = "https://w3c.github.io/rdf-tests/rdf/"
1010 LOCAL_PATH = ::File . expand_path ( "../w3c-rdf-tests/rdf/" , __FILE__ ) + '/'
11- REMOTE_PATH_STAR = "https://w3c.github.io/rdf-star/"
12- LOCAL_PATH_STAR = ::File . expand_path ( "../w3c-rdf-star/" , __FILE__ ) + '/'
1311
1412 class << self
1513 alias_method :original_open_file , :open_file
@@ -55,38 +53,6 @@ def self.open_file(filename_or_url, **options, &block)
5553 # For overriding content type from test data
5654 document_options [ :headers ] [ :content_type ] = options [ :contentType ] if options [ :contentType ]
5755
58- remote_document = RDF ::Util ::File ::RemoteDocument . new ( response . read , **document_options )
59- if block_given?
60- yield remote_document
61- else
62- remote_document
63- end
64- when ( filename_or_url . to_s =~ %r{^#{ REMOTE_PATH_STAR } } && Dir . exist? ( LOCAL_PATH_STAR ) )
65- #puts "attempt to open #{filename_or_url} locally"
66- localpath = filename_or_url . to_s . sub ( REMOTE_PATH_STAR , LOCAL_PATH_STAR )
67- response = begin
68- ::File . open ( localpath )
69- rescue Errno ::ENOENT => e
70- raise IOError , e . message
71- end
72- document_options = {
73- base_uri : RDF ::URI ( filename_or_url ) ,
74- charset : Encoding ::UTF_8 ,
75- code : 200 ,
76- headers : { }
77- }
78- #puts "use #{filename_or_url} locally"
79- document_options [ :headers ] [ :content_type ] = case filename_or_url . to_s
80- when /\. ttl$/ then 'text/turtle'
81- when /\. nt$/ then 'application/n-triples'
82- when /\. jsonld$/ then 'application/ld+json'
83- else 'unknown'
84- end
85-
86- document_options [ :headers ] [ :content_type ] = response . content_type if response . respond_to? ( :content_type )
87- # For overriding content type from test data
88- document_options [ :headers ] [ :content_type ] = options [ :contentType ] if options [ :contentType ]
89-
9056 remote_document = RDF ::Util ::File ::RemoteDocument . new ( response . read , **document_options )
9157 if block_given?
9258 yield remote_document
@@ -96,6 +62,8 @@ def self.open_file(filename_or_url, **options, &block)
9662 else
9763 original_open_file ( filename_or_url , **options , &block )
9864 end
65+ rescue IOError => e
66+ raise IOError , "Error opening #{ filename_or_url . inspect } : #{ e . message } "
9967 end
10068 end
10169end
@@ -112,6 +80,7 @@ module SuiteTest
11280 "rdft": "http://www.w3.org/ns/rdftest#",
11381
11482 "label": "rdfs:label",
83+ "baseIri": {"@id": "mf:assumedTestBase", "@type": "@id"},
11584 "comment": "rdfs:comment",
11685 "entries": {"@id": "mf:entries", "@container": "@list"},
11786 "name": "mf:name",
@@ -125,6 +94,8 @@ module SuiteTest
12594 "rdft:TestTurtleNegativeSyntax",
12695 "rdft:TestNTriplesPositiveSyntax",
12796 "rdft:TestNTriplesNegativeSyntax",
97+ "rdft:TestNTriplesPositiveC14N",
98+ "rdft:TestNTriplesNegativeC14N",
12899 "rdft:TestTurtleEval",
129100 "rdft:TestTurtleNegativeEval"
130101 ]
@@ -150,15 +121,20 @@ def self.from_jsonld(json)
150121
151122 def entries
152123 # Map entries to resources
153- attributes [ 'entries' ] . map { |e | Entry . new ( e ) }
124+ attributes [ 'entries' ] . map { |e | Entry . new ( e , base_iri : attributes [ 'baseIri' ] ) }
154125 end
155126 end
156127
157128 class Entry < JSON ::LD ::Resource
158129 attr_accessor :logger
159130
131+ def initialize ( json , base_iri :)
132+ @base_iri = base_iri
133+ super
134+ end
135+
160136 def base
161- RDF ::URI ( action )
137+ RDF ::URI ( @base_iri || action )
162138 end
163139
164140 # Alias data and query
@@ -167,23 +143,23 @@ def input
167143 end
168144
169145 def expected
170- @expected ||= RDF ::Util ::File . open_file ( result ) { |f | f . read }
146+ @expected ||= RDF ::Util ::File . open_file ( result ) { |f | f . read } if result
171147 end
172148
173149 def evaluate?
174150 Array ( attributes [ '@type' ] ) . join ( " " ) . match ( /Eval/ )
175151 end
176152
177153 def syntax?
178- Array ( attributes [ '@type' ] ) . join ( " " ) . match ( /Syntax/ )
154+ !! Array ( attributes [ '@type' ] ) . join ( " " ) . match ( /Syntax/ )
179155 end
180156
181157 def entailment?
182- Array ( attributes [ '@type' ] ) . join ( " " ) . match ( /Entailment/ )
158+ !! Array ( attributes [ '@type' ] ) . join ( " " ) . match ( /Entailment/ )
183159 end
184160
185161 def ntriples?
186- Array ( attributes [ '@type' ] ) . join ( " " ) . match ( /NTriples/ )
162+ !! Array ( attributes [ '@type' ] ) . join ( " " ) . match ( /NTriples/ )
187163 end
188164
189165 def positive_test?
@@ -194,6 +170,10 @@ def negative_test?
194170 !positive_test?
195171 end
196172
173+ def c14n?
174+ !!Array ( attributes [ '@type' ] ) . join ( " " ) . match ( /C14N/ )
175+ end
176+
197177 def inspect
198178 super . sub ( '>' , "\n " +
199179 " syntax?: #{ syntax? . inspect } \n " +
0 commit comments