diff options
author | David Robillard <d@drobilla.net> | 2019-12-18 19:09:49 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-10-27 13:13:59 +0100 |
commit | 7f508b89230b339684a4013dbbad741d9e16e40a (patch) | |
tree | 1c366ec60c6fcac68f96e01df06e4dc3c142f1ab /tests | |
parent | b6b777a0c0145449bce9855bc3851ad1b5edf409 (diff) | |
download | serd-7f508b89230b339684a4013dbbad741d9e16e40a.tar.gz serd-7f508b89230b339684a4013dbbad741d9e16e40a.tar.bz2 serd-7f508b89230b339684a4013dbbad741d9e16e40a.zip |
Add support for parsing variables
This adds a reader flag and serdi option for extending a syntax with support
for SPARQL-like variables, for storing things like patterns or simple queries.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bad/bad-var.ttl | 2 | ||||
-rw-r--r-- | tests/bad/manifest.ttl | 6 | ||||
-rw-r--r-- | tests/overflow_test.c | 5 | ||||
-rw-r--r-- | tests/pattern/bad-pattern.nq | 1 | ||||
-rw-r--r-- | tests/pattern/bad-pattern.ttl | 2 | ||||
-rw-r--r-- | tests/pattern/manifest.ttl | 35 | ||||
-rw-r--r-- | tests/pattern/test-pattern.nt | 6 | ||||
-rw-r--r-- | tests/pattern/test-pattern.ttl | 10 |
8 files changed, 65 insertions, 2 deletions
diff --git a/tests/bad/bad-var.ttl b/tests/bad/bad-var.ttl new file mode 100644 index 00000000..29b5b008 --- /dev/null +++ b/tests/bad/bad-var.ttl @@ -0,0 +1,2 @@ +?s + <http://example.org/p> <http://example.org/o> . diff --git a/tests/bad/manifest.ttl b/tests/bad/manifest.ttl index e8ecb396..1bcf6611 100644 --- a/tests/bad/manifest.ttl +++ b/tests/bad/manifest.ttl @@ -70,6 +70,7 @@ <#bad-string> <#bad-subject> <#bad-uri-escape> + <#bad-var> <#bad-verb> <#invalid-char-in-local> <#invalid-char-in-prefix> @@ -394,6 +395,11 @@ mf:name "bad-uri-escape" ; mf:action <bad-uri-escape.ttl> . +<#bad-var> + rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "bad-var" ; + mf:action <bad-var.ttl> . + <#bad-verb> rdf:type rdft:TestTurtleNegativeSyntax ; mf:name "bad-verb" ; diff --git a/tests/overflow_test.c b/tests/overflow_test.c index 918f1cc4..847884de 100644 --- a/tests/overflow_test.c +++ b/tests/overflow_test.c @@ -24,8 +24,8 @@ static SerdStatus test(SerdWorld* world, SerdSink* sink, const char* str, size_t stack_size) { - SerdReader* reader = - serd_reader_new(world, SERD_TURTLE, 0, sink, stack_size); + SerdReader* reader = serd_reader_new( + world, SERD_TURTLE, SERD_READ_VARIABLES, sink, stack_size); serd_reader_start_string(reader, str, NULL); const SerdStatus st = serd_reader_read_document(reader); @@ -54,6 +54,7 @@ main(void) {":s :p \"literal\"", sizes + 264}, {":s :p \"verb\"", sizes + 263}, {":s :p _:blank .", sizes + 276}, + {":s :p ?o .", sizes + 295}, {":s :p true .", sizes + 295}, {":s :p true .", sizes + 329}, {":s :p \"\"@en .", sizes + 302}, diff --git a/tests/pattern/bad-pattern.nq b/tests/pattern/bad-pattern.nq new file mode 100644 index 00000000..a7e0c994 --- /dev/null +++ b/tests/pattern/bad-pattern.nq @@ -0,0 +1 @@ +<http://example.org/s> ?pµ <http://example.org/o> . diff --git a/tests/pattern/bad-pattern.ttl b/tests/pattern/bad-pattern.ttl new file mode 100644 index 00000000..5f3dbfdd --- /dev/null +++ b/tests/pattern/bad-pattern.ttl @@ -0,0 +1,2 @@ +?sµ + <http://example.org/p> <http://example.org/o> . diff --git a/tests/pattern/manifest.ttl b/tests/pattern/manifest.ttl new file mode 100644 index 00000000..a179a64d --- /dev/null +++ b/tests/pattern/manifest.ttl @@ -0,0 +1,35 @@ +@prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix rdft: <http://www.w3.org/ns/rdftest#> . + +<> + rdf:type mf:Manifest ; + rdfs:comment "Serd pattern syntax test cases" ; + mf:entries ( + <#bad-pattern-nq> + <#bad-pattern-ttl> + <#test-pattern-nt> + <#test-pattern-ttl> + ) . + +<#bad-pattern-nq> + rdf:type rdft:TestNQuadsNegativeSyntax ; + mf:name "bad-pattern-nq" ; + mf:action <bad-pattern.nq> . + +<#bad-pattern-ttl> + rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "bad-pattern" ; + mf:action <bad-pattern.ttl> . + +<#test-pattern-nt> + rdf:type rdft:TestNTriplesPositiveSyntax ; + mf:name "test-pattern-nt" ; + mf:action <test-pattern.nt> . + +<#test-pattern-ttl> + rdf:type rdft:TestTurtleEval ; + mf:name "test-pattern" ; + mf:action <test-pattern.ttl> ; + mf:result <test-pattern.nt> . diff --git a/tests/pattern/test-pattern.nt b/tests/pattern/test-pattern.nt new file mode 100644 index 00000000..ddfe6d3c --- /dev/null +++ b/tests/pattern/test-pattern.nt @@ -0,0 +1,6 @@ +?s <http://example.org/p1> <http://example.org/o1> . +<http://example.org/s> ?p <http://example.org/o1> . +<http://example.org/s> <http://example.org/p1> ?o . +<http://example.org/s> <http://example.org/p2> _:b1 . +_:b1 ?2p <http://example.org/o2> . +_:b1 <http://example.org/p3> ?_o . diff --git a/tests/pattern/test-pattern.ttl b/tests/pattern/test-pattern.ttl new file mode 100644 index 00000000..3742e5ed --- /dev/null +++ b/tests/pattern/test-pattern.ttl @@ -0,0 +1,10 @@ +?s + <http://example.org/p1> <http://example.org/o1> . + +<http://example.org/s> + ?p <http://example.org/o1> ; + <http://example.org/p1> ?o ; + <http://example.org/p2> [ + ?2p <http://example.org/o2> ; + <http://example.org/p3> ?_o + ] . |