aboutsummaryrefslogtreecommitdiff
path: root/test/turtle/main.ml
diff options
context:
space:
mode:
authorarie <arie@alleycat.cc>2021-06-29 11:01:39 +0200
committerarie <arie@alleycat.cc>2021-06-29 11:01:39 +0200
commitbf545602512662d2f7735992a81ead9352d426c0 (patch)
tree75299a873ae579e54fdca9ac3181ebcf3fede6f5 /test/turtle/main.ml
parente6bbf3a31f2d7c9a6975af6631d50771c7b01fa8 (diff)
Rdf turtle tests.
Fix a little bug in the xsd:string uri in rdf_turtle. There was a < which shouldn't have been there. All the tests work now, except for the last one. I think the reason is that @base uri's are not taken into account yet.
Diffstat (limited to 'test/turtle/main.ml')
-rw-r--r--test/turtle/main.ml67
1 files changed, 50 insertions, 17 deletions
diff --git a/test/turtle/main.ml b/test/turtle/main.ml
index 5f2d97f..411e7a9 100644
--- a/test/turtle/main.ml
+++ b/test/turtle/main.ml
@@ -444,10 +444,12 @@ let turtle_test_case =
(* TODO This test works as follows: we take a turtle string and create a graph out of it using rdf_turtle.decode,
* which is the composition of the turtle parser, and the transformation which transforms instances of the turtle type into a graph.
* We compare the result to a graph which the empty graph with a number of triples added.
+ * The triples are added using the transformation from "https://www.easyrdf.org/converter"
+ * and some from the tests from "https://w3c.github.io/rdf-tests/turtle/".
* We have some helper functions to reduce the amount of code.
* One issue with this approach is, is that when there are tests that don't pass. it is not
* immediately clear where the problems lie, since the decode function is a composition of other
- * (already quite complicated) funtions. *)
+ * (already quite complicated) functions. *)
let turtle_to_graph_test_case =
(* A triple of three Iri's *)
let triple_of_iri_iri_iri sub pred obj =
@@ -705,22 +707,53 @@ let turtle_to_graph_test_case =
"https://www.w3.org/ns/activitystreams#preferredUsername"
"alice")
;
- (* TODO *)
- (* " @base <http://example.org/> . *)
- (* @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . *)
- (* @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . *)
- (* @prefix foaf: <http://xmlns.com/foaf/0.1/> . *)
- (* *)
- (* <#green-goblin> *)
- (* rel:enemyOf <#spiderman> ; #LET us put a comment here *)
- (* a foaf:Person ; *)
- (* foaf:name \"Green Goblin\" . *)
- (* *)
- (* @prefix rel: <http://www.perceive.net/schemas/relationship/> . *)
- (* <#spiderman> *)
- (* rel:enemyOf <#green-goblin> ; *)
- (* a foaf:Person ; *)
- (* foaf:name \"Spiderman\", \"Человек-паук\"@ru . ", *)
+ (* TODO: this test fails. That is because the base uri is not used yet, I think. *)
+ (* " @base <http://example.org/> .
+ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+ @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+ @prefix foaf: <http://xmlns.com/foaf/0.1/> .
+ @prefix rel: <http://www.perceive.net/schemas/relationship/> .
+
+ <#green-goblin>
+ rel:enemyOf <#spiderman> ; #LET us put a comment here
+ a foaf:Person ;
+ foaf:name \"Green Goblin\" .
+
+ <#spiderman>
+ rel:enemyOf <#green-goblin> ;
+ a foaf:Person ;
+ foaf:name \"Spiderman\", \"Человек-паук\"@ru . ",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add (triple_of_iri_iri_iri
+ "http://example.org/#green-goblin"
+ "http://www.perceive.net/schemas/relationship/enemyOf"
+ "http://example.org/#spiderman")
+ |> Rdf.Graph.add (triple_of_iri_iri_iri
+ "http://example.org/#green-goblin"
+ a_pred
+ "http://xmlns.com/foaf/0.1/Person")
+ |> Rdf.Graph.add (triple_of_iri_iri_literal
+ "http://example.org/#green-goblin"
+ "http://xmlns.com/foaf/0.1/name"
+ "Green Goblin")
+ |> Rdf.Graph.add (triple_of_iri_iri_iri
+ "http://example.org/#spiderman"
+ "http://www.perceive.net/schemas/relationship/enemyOf"
+ "http://example.org/#green-goblin")
+ |> Rdf.Graph.add (triple_of_iri_iri_iri
+ "http://example.org/#spiderman"
+ a_pred
+ "http://xmlns.com/foaf/0.1/Person")
+ |> Rdf.Graph.add (triple_of_iri_iri_literal
+ "http://example.org/#spiderman"
+ "http://xmlns.com/foaf/0.1/name"
+ "Spiderman")
+ |> Rdf.Graph.add (triple_of_iri_iri_literal
+ "http://example.org/#spiderman"
+ "http://xmlns.com/foaf/0.1/name"
+ ~obj_language:"ru"
+ "Человек-паук")
+ ; *)
] in
test_case "turtle parser and transform" `Quick
(fun () ->