Skip to content

Commit

Permalink
Added SPARQL unicode numeric codepoint escape tests
Browse files Browse the repository at this point in the history
Added four (marked-as-xfail) unicode numeric codepoint escape tests
to the RDFLib-specific SPARQL test suite `test/data/suites/rdflib/sparql`.

Also:
- Fix the base URI in the RDFLib SPARQL test manifest.
  • Loading branch information
Graham Higgins authored and aucampia committed May 14, 2022
1 parent 7d496bc commit 03e8cac
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 1 deletion.
40 changes: 39 additions & 1 deletion test/data/suites/rdflib/sparql/manifest.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@prefix dawgt: <http://www.w3.org/2001/sw/DataAccess/tests/test-dawg#> .

@prefix : <http://raw.github.com/RDFLib/rdflib/master/test/DAWG/rdflib/manifest.ttl#> .
@prefix : <http://raw.github.com/RDFLib/rdflib/master/test/data/rdflib-sparql/manifest.ttl#> .

<> a mf:Manifest ;
rdfs:label "RDFLib Extra SPARQL tests" ;
Expand Down Expand Up @@ -41,6 +41,12 @@
:bnode-ppath-mix-g
:bnode-ppath-mix-h

:test-codepoint-escape-01
:test-codepoint-escape-02
:test-codepoint-escape-03
:test-codepoint-escape-04
:test-codepoint-escape-bad

) .


Expand Down Expand Up @@ -363,3 +369,35 @@ From https://github.com/RDFLib/rdflib/issues/615, contributed by https://github.
qt:data <bnode-ppath-mix.ttl> ] ;
mf:result <bnode-ppath-mix.srx>
.

:test-codepoint-escape-01 rdf:type mf:PositiveSyntaxTest11 ;
dawgt:approval dawgt:Proposed ;
mf:name "\\U unicode codepoint escaping in literal" ;
rdfs:comment """From https://github.com/RDFLib/rdflib/issues/1884, contributed by https://github.com/gjhiggins""" ;
mf:action <syn-codepoint-escape-01.rq> ;.

:test-codepoint-escape-02 rdf:type mf:PositiveSyntaxTest11 ;
dawgt:approval dawgt:Proposed ;
rdfs:comment """From https://github.com/RDFLib/rdflib/issues/1884, contributed by https://github.com/gjhiggins""" ;
mf:name "\\u unicode codepoint escaping in literal" ;
mf:action <syn-codepoint-escape-02.rq> ;.

:test-codepoint-escape-03 rdf:type mf:PositiveSyntaxTest11 ;
dawgt:approval dawgt:Proposed ;
rdfs:comment """From https://github.com/RDFLib/rdflib/issues/1884, contributed by https://github.com/gjhiggins""" ;
mf:name "\\u and \\U unicode codepoint escaping in literal" ;
mf:action <syn-codepoint-escape-03.rq> ;.

:test-codepoint-escape-04 rdf:type mf:PositiveSyntaxTest11 ;
dawgt:approval dawgt:Proposed ;
rdfs:comment """From https://github.com/RDFLib/rdflib/issues/1884, contributed by https://github.com/gjhiggins""" ;
mf:name "\\U and \\U unicode codepoints escaping in literal" ;
mf:action <syn-codepoint-escape-04.rq> ;.

:test-codepoint-escape-bad rdf:type mf:NegativeSyntaxTest11 ;
dawgt:approval dawgt:Proposed ;
rdfs:comment """From https://github.com/RDFLib/rdflib/issues/1884, contributed by https://github.com/gjhiggins""" ;
mf:name "Invalid multi-pass codepoint escaping (\\u then \\U)" ;
mf:description "Unescaping one escape sequence must not produce content that is used in another escape sequence" ;
mf:action <syn-codepoint-escape-bad.rq> ;.

3 changes: 3 additions & 0 deletions test/data/suites/rdflib/sparql/syn-codepoint-escape-01.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s ?p "\U0001f46a" .
}
3 changes: 3 additions & 0 deletions test/data/suites/rdflib/sparql/syn-codepoint-escape-02.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s ?p "\u00a71234" .
}
3 changes: 3 additions & 0 deletions test/data/suites/rdflib/sparql/syn-codepoint-escape-03.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s ?p "\U0001f46a\u00a71234" .
}
3 changes: 3 additions & 0 deletions test/data/suites/rdflib/sparql/syn-codepoint-escape-04.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s ?p "\U0001f46afoo\U0000005c" .
}
3 changes: 3 additions & 0 deletions test/data/suites/rdflib/sparql/syn-codepoint-escape-bad.rq
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT * WHERE {
?s ?p "\U0001HHHH" .
}
13 changes: 13 additions & 0 deletions test/test_w3c_spec/test_sparql_w3c.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,22 @@ def test_dawg_data_sparql11(rdf_test_uri: URIRef, type: Node, rdf_test: RDFTest)
testers[type](rdf_test)


EXPECTED_FAILURES: Dict[str, str] = {}

for test in [
"test-codepoint-escape-02",
"test-codepoint-escape-03",
"test-codepoint-escape-04",
]:
EXPECTED_FAILURES[test] = "known codepoint escape issue"


@pytest.mark.parametrize(
"rdf_test_uri, type, rdf_test",
read_manifest("test/data/suites/rdflib/sparql/manifest.ttl"),
)
def test_dawg_rdflib(rdf_test_uri: URIRef, type: Node, rdf_test: RDFTest):
suffix = rdf_test_uri.split("#")[1]
if suffix in EXPECTED_FAILURES:
pytest.xfail(EXPECTED_FAILURES[suffix])
testers[type](rdf_test)

0 comments on commit 03e8cac

Please sign in to comment.