aboutsummaryrefslogtreecommitdiff
path: root/test/turtle/main.ml
diff options
context:
space:
mode:
authorpukkamustard <pukkamustard@posteo.net>2021-11-19 11:24:34 +0100
committerpukkamustard <pukkamustard@posteo.net>2021-11-19 11:24:34 +0100
commit9b64260828ac45d3491987f0bdcd677219d6247f (patch)
treec9bfc1c5b8c26de4eb9f02b217361565df42186d /test/turtle/main.ml
parent881d76f510f90c8e9b0050a8ca7bc5a98f5bdc53 (diff)
Rdf_alcotest: Move testables for Turtle AST to the Turtle tests
This removes dependency of rdf_turtle from rdf_alcotest, allowing usage of rdf_alcotest without rdf_turtle.
Diffstat (limited to 'test/turtle/main.ml')
-rw-r--r--test/turtle/main.ml1547
1 files changed, 834 insertions, 713 deletions
diff --git a/test/turtle/main.ml b/test/turtle/main.ml
index 411e7a9..9830646 100644
--- a/test/turtle/main.ml
+++ b/test/turtle/main.ml
@@ -1,445 +1,559 @@
module Parser = Rdf_turtle.Parser
module Turtle = Rdf_turtle.Ast
-
open Turtle
open Alcotest
-let parse p =
- Angstrom.parse_string
- ~consume:Angstrom.Consume.All
- p
+(* Alcotest testables for Turtle AS *)
+
+let ast_iriref_testable =
+ Alcotest.testable Rdf_turtle.Ast.Iriref.pp Rdf_turtle.Ast.Iriref.equal
+
+let ast_language_testable =
+ Alcotest.testable Rdf_turtle.Ast.Language.pp Rdf_turtle.Ast.Language.equal
+
+let ast_prefixed_name_testable =
+ Alcotest.testable Rdf_turtle.Ast.Prefixed_name.pp
+ Rdf_turtle.Ast.Prefixed_name.equal
+
+let ast_blank_node_testable =
+ Alcotest.testable Rdf_turtle.Ast.Blank_node.pp Rdf_turtle.Ast.Blank_node.equal
+
+let ast_iri_testable =
+ Alcotest.testable Rdf_turtle.Ast.Iri.pp Rdf_turtle.Ast.Iri.equal
+
+let ast_literal_testable =
+ Alcotest.testable Rdf_turtle.Ast.Literal.pp Rdf_turtle.Ast.Literal.equal
+
+let ast_predicate_testable =
+ Alcotest.testable Rdf_turtle.Ast.Predicate.pp Rdf_turtle.Ast.Predicate.equal
+
+let ast_object_testable =
+ Alcotest.testable Rdf_turtle.Ast.object_pp Rdf_turtle.Ast.object_equal
+
+let ast_collection_testable =
+ Alcotest.testable Rdf_turtle.Ast.collection_pp Rdf_turtle.Ast.collection_equal
+
+let ast_subject_testable =
+ Alcotest.testable Rdf_turtle.Ast.subject_pp Rdf_turtle.Ast.subject_equal
+
+let ast_bnodps_testable =
+ Alcotest.testable Rdf_turtle.Ast.bnodps_pp Rdf_turtle.Ast.bnodps_equal
+
+let ast_predobjs_testable =
+ Alcotest.testable Rdf_turtle.Ast.predobjs_pp Rdf_turtle.Ast.predobjs_equal
+
+let ast_triple_testable =
+ Alcotest.testable Rdf_turtle.Ast.Triple.pp Rdf_turtle.Ast.Triple.equal
+
+let ast_directive_testable =
+ Alcotest.testable Rdf_turtle.Ast.Directive.pp Rdf_turtle.Ast.Directive.equal
+
+let ast_statement_testable =
+ Alcotest.testable Rdf_turtle.Ast.Statement.pp Rdf_turtle.Ast.Statement.equal
+
+let ast_turtle_testable =
+ Alcotest.testable Rdf_turtle.Ast.Turtle.pp Rdf_turtle.Ast.Turtle.equal
+
+let parse p = Angstrom.parse_string ~consume:Angstrom.Consume.All p
let iriref_test_case =
- let cases = [
- "<http://one.example/subject1>",
- Iriref.of_string "http://one.example/subject1" ;
- ] in
- test_case "iriref" `Quick
- (fun () ->
- List.iter
- (fun (enc, v) ->
- check (result Rdf_alcotest.ast_iriref string)
- "can parse"
- (parse Parser.iriref enc)
- (Result.ok @@ v))
- cases)
+ let cases =
+ [
+ ( "<http://one.example/subject1>",
+ Iriref.of_string "http://one.example/subject1" );
+ ]
+ in
+
+ test_case "iriref" `Quick (fun () ->
+ List.iter
+ (fun (enc, v) ->
+ check
+ (result ast_iriref_testable string)
+ "can parse" (parse Parser.iriref enc) (Result.ok @@ v))
+ cases)
let language_test_case =
- test_case "language" `Quick
- (fun () ->
- check (result Rdf_alcotest.ast_language string)
- "can parse"
- (parse Parser.language "@fr-be")
- (Result.ok @@ Language.of_string "fr-be")
- )
+ test_case "language" `Quick (fun () ->
+ check
+ (result ast_language_testable string)
+ "can parse"
+ (parse Parser.language "@fr-be")
+ (Result.ok @@ Language.of_string "fr-be"))
let prefixed_name_test_case =
- let cases = [
- "rdf:first",
- Prefixed_name.of_strings "rdf" "first" ;
- ":first",
- Prefixed_name.of_strings "" "first" ;
- ] in
- test_case "prefixed_name" `Quick
- (fun () ->
- List.iter
- (fun (enc, v) ->
- check (result Rdf_alcotest.ast_prefixed_name string)
- "can parse"
- (parse Parser.prefixed_name enc)
- (Result.ok @@ v))
- cases)
+ let cases =
+ [
+ ("rdf:first", Prefixed_name.of_strings "rdf" "first");
+ (":first", Prefixed_name.of_strings "" "first");
+ ]
+ in
+ test_case "prefixed_name" `Quick (fun () ->
+ List.iter
+ (fun (enc, v) ->
+ check
+ (result ast_prefixed_name_testable string)
+ "can parse"
+ (parse Parser.prefixed_name enc)
+ (Result.ok @@ v))
+ cases)
let blank_node_test_case =
- test_case "blank_node" `Quick
- (fun () ->
- check (result Rdf_alcotest.ast_blank_node string)
- "can parse"
- (parse Parser.blank_node "_:alice")
- (Result.ok @@ Blank_node.of_string "alice")
- )
+ test_case "blank_node" `Quick (fun () ->
+ check
+ (result ast_blank_node_testable string)
+ "can parse"
+ (parse Parser.blank_node "_:alice")
+ (Result.ok @@ Blank_node.of_string "alice"))
let iri_test_case =
- let cases = [
- "<http://one.example/subject1>",
- Iri.of_iriref @@ Iriref.of_string "http://one.example/subject1" ;
- "p:subject3",
- Iri.of_prefixed_name @@ Prefixed_name.of_strings "p" "subject3" ;
- ] in
- test_case "iri" `Quick
- (fun () ->
- List.iter
- (fun (enc, v) ->
- check (result Rdf_alcotest.ast_iri string)
- "can parse"
- (parse Parser.iri enc)
- (Result.ok @@ v))
- cases)
+ let cases =
+ [
+ ( "<http://one.example/subject1>",
+ Iri.of_iriref @@ Iriref.of_string "http://one.example/subject1" );
+ ( "p:subject3",
+ Iri.of_prefixed_name @@ Prefixed_name.of_strings "p" "subject3" );
+ ]
+ in
+ test_case "iri" `Quick (fun () ->
+ List.iter
+ (fun (enc, v) ->
+ check
+ (result ast_iri_testable string)
+ "can parse" (parse Parser.iri enc) (Result.ok @@ v))
+ cases)
let literal_test_case =
- let cases = [
- "\"That Seventies Show\"^^xsd:string",
- Literal.make
- ("That Seventies Show")
- (Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string") ;
- "\"That Seventies Show\"^^<http://www.w3.org/2001/XMLSchema#string>",
- Literal.make
- ("That Seventies Show")
- (Iri.of_iriref @@ Iriref.of_string "http://www.w3.org/2001/XMLSchema#string");
- "\"That Seventies Show\"",
- Literal.make
- ("That Seventies Show")
- (Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string") ;
- "\"Cette Série des Années Septantei\"@fr-be",
- Literal.make
- "Cette Série des Années Septantei"
- (Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string")
- ~language:"fr-be" ;
- ] in
- test_case "literal" `Quick
- (fun () ->
- List.iter
- (fun (enc, v) ->
- check (result Rdf_alcotest.ast_literal string)
- "can parse"
- (parse Parser.literal enc)
- (Result.ok @@ v))
- cases)
+ let cases =
+ [
+ ( "\"That Seventies Show\"^^xsd:string",
+ Literal.make "That Seventies Show"
+ (Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string") );
+ ( "\"That Seventies Show\"^^<http://www.w3.org/2001/XMLSchema#string>",
+ Literal.make "That Seventies Show"
+ (Iri.of_iriref
+ @@ Iriref.of_string "http://www.w3.org/2001/XMLSchema#string") );
+ ( "\"That Seventies Show\"",
+ Literal.make "That Seventies Show"
+ (Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string") );
+ ( "\"Cette Série des Années Septantei\"@fr-be",
+ Literal.make "Cette Série des Années Septantei"
+ (Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string")
+ ~language:"fr-be" );
+ ]
+ in
+ test_case "literal" `Quick (fun () ->
+ List.iter
+ (fun (enc, v) ->
+ check
+ (result ast_literal_testable string)
+ "can parse" (parse Parser.literal enc) (Result.ok @@ v))
+ cases)
let predicate_test_case =
- let cases = [
- "<http://one.example/subject1>",
- Predicate.of_iri @@ Iri.of_iriref @@ Iriref.of_string "http://one.example/subject1" ;
- "p:subject3",
- Predicate.of_iri @@ Iri.of_prefixed_name @@ Prefixed_name.of_strings "p" "subject3" ;
- ] in
- test_case "predicate" `Quick
- (fun () ->
- List.iter
- (fun (enc, v) ->
- check (result Rdf_alcotest.ast_predicate string)
- "can parse"
- (parse Parser.predicate enc)
- (Result.ok @@ v))
- cases)
+ let cases =
+ [
+ ( "<http://one.example/subject1>",
+ Predicate.of_iri @@ Iri.of_iriref
+ @@ Iriref.of_string "http://one.example/subject1" );
+ ( "p:subject3",
+ Predicate.of_iri @@ Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "p" "subject3" );
+ ]
+ in
+ test_case "predicate" `Quick (fun () ->
+ List.iter
+ (fun (enc, v) ->
+ check
+ (result ast_predicate_testable string)
+ "can parse"
+ (parse Parser.predicate enc)
+ (Result.ok @@ v))
+ cases)
let object_test_case =
- let cases = [
- (* Literal *)
- "\"That Seventies Show\"^^xsd:string",
- Literal.make
- ("That Seventies Show")
- (Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string")
- |> (fun lit -> Obj_literal lit) ;
- (* Iri *)
- "xsd:string",
- Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string"
- |> (fun iri -> Obj_iri iri) ;
- (* Iri *)
- ":q",
- Iri.of_prefixed_name @@ Prefixed_name.of_strings "" "q"
- |> (fun iri -> Obj_iri iri) ;
- (* Blank_node *)
- "_:string",
- Obj_blank_node (Blank_node.of_string "string") ;
- (* Blank_node *)
- "_:string",
- Obj_blank_node (Blank_node.of_string "string") ;
- (* Collection *)
- "( \"apple\" \"banana\" )",
- Obj_coll (
- Collection (
- [
- Obj_literal (
- Literal.make
- ("apple")
- (Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string")) ;
- Obj_literal (
- Literal.make
- ("banana")
- (Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string")) ;
- ]
- )
- ) ;
- (* BNodePlist *)
- "[ foaf:name \"Bob\" ]",
- Obj_bnodps (BnodPs ([ Predicate.of_iri @@ Iri.of_prefixed_name @@ Prefixed_name.of_strings "foaf" "name",
- [ Obj_literal ( Literal.make
- ("Bob")
- (Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string"))
- ]
- ]))
- ;
- ] in
- test_case "object" `Quick
- (fun () ->
- List.iter
- (fun (enc, v) ->
- check (result Rdf_alcotest.ast_object string)
- "can parse"
- (parse Parser.object' enc)
- (Result.ok @@ v))
- cases)
+ let cases =
+ [
+ (* Literal *)
+ ( "\"That Seventies Show\"^^xsd:string",
+ Literal.make "That Seventies Show"
+ (Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string")
+ |> fun lit -> Obj_literal lit );
+ (* Iri *)
+ ( "xsd:string",
+ Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string"
+ |> fun iri -> Obj_iri iri );
+ (* Iri *)
+ ( ":q",
+ Iri.of_prefixed_name @@ Prefixed_name.of_strings "" "q" |> fun iri ->
+ Obj_iri iri );
+ (* Blank_node *)
+ ("_:string", Obj_blank_node (Blank_node.of_string "string"));
+ (* Blank_node *)
+ ("_:string", Obj_blank_node (Blank_node.of_string "string"));
+ (* Collection *)
+ ( "( \"apple\" \"banana\" )",
+ Obj_coll
+ (Collection
+ [
+ Obj_literal
+ (Literal.make "apple"
+ (Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "xsd" "string"));
+ Obj_literal
+ (Literal.make "banana"
+ (Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "xsd" "string"));
+ ]) );
+ (* BNodePlist *)
+ ( "[ foaf:name \"Bob\" ]",
+ Obj_bnodps
+ (BnodPs
+ [
+ ( Predicate.of_iri @@ Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "foaf" "name",
+ [
+ Obj_literal
+ (Literal.make "Bob"
+ (Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "xsd" "string"));
+ ] );
+ ]) );
+ ]
+ in
+ test_case "object" `Quick (fun () ->
+ List.iter
+ (fun (enc, v) ->
+ check
+ (result ast_object_testable string)
+ "can parse" (parse Parser.object' enc) (Result.ok @@ v))
+ cases)
let bnodps_test_case =
- let cases = [
- "[ foaf:name \"Bob\" ]",
- BnodPs ([ Predicate.of_iri @@ Iri.of_prefixed_name @@ Prefixed_name.of_strings "foaf" "name",
- [ Obj_literal ( Literal.make
- ("Bob")
- (Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string"))
- ]
- ])
- ;
- "[:p :WWWW]",
- BnodPs ([ Predicate.of_iri @@ Iri.of_prefixed_name @@ Prefixed_name.of_strings "" "p",
- [ Obj_iri (Iri.of_prefixed_name @@ Prefixed_name.of_strings "" "WWWW"); ] ; ]
- );
- ]
+ let cases =
+ [
+ ( "[ foaf:name \"Bob\" ]",
+ BnodPs
+ [
+ ( Predicate.of_iri @@ Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "foaf" "name",
+ [
+ Obj_literal
+ (Literal.make "Bob"
+ (Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "xsd" "string"));
+ ] );
+ ] );
+ ( "[:p :WWWW]",
+ BnodPs
+ [
+ ( Predicate.of_iri @@ Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "" "p",
+ [
+ Obj_iri
+ (Iri.of_prefixed_name @@ Prefixed_name.of_strings "" "WWWW");
+ ] );
+ ] );
+ ]
in
- test_case "bnodps" `Quick
- (fun () ->
- List.iter
- (fun (enc, v) ->
- check (result Rdf_alcotest.ast_bnodps string)
- "can parse"
- (parse Parser.bnodps enc)
- (Result.ok @@ v))
- cases)
+ test_case "bnodps" `Quick (fun () ->
+ List.iter
+ (fun (enc, v) ->
+ check
+ (result ast_bnodps_testable string)
+ "can parse" (parse Parser.bnodps enc) (Result.ok @@ v))
+ cases)
let predobjs_test_case =
- let cases = [
- ":p :WWWWWWWWWWWWWWWWWWWwwW",
- [ Predicate.of_iri @@ Iri.of_prefixed_name @@ Prefixed_name.of_strings "" "p",
- [ Obj_iri (Iri.of_prefixed_name @@ Prefixed_name.of_strings "" "WWWWWWWWWWWWWWWWWWWwwW"); ] ; ]
- ;
- " foaf:name \"Bob\" ",
- [ Predicate.of_iri @@ Iri.of_prefixed_name @@ Prefixed_name.of_strings "foaf" "name",
- [ Obj_literal ( Literal.make
- ("Bob")
- (Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string"))
- ]
+ let cases =
+ [
+ ( ":p :WWWWWWWWWWWWWWWWWWWwwW",
+ [
+ ( Predicate.of_iri @@ Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "" "p",
+ [
+ Obj_iri
+ (Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "" "WWWWWWWWWWWWWWWWWWWwwW");
+ ] );
+ ] );
+ ( " foaf:name \"Bob\" ",
+ [
+ ( Predicate.of_iri @@ Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "foaf" "name",
+ [
+ Obj_literal
+ (Literal.make "Bob"
+ (Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "xsd" "string"));
+ ] );
+ ] );
+ ( "rel:enemyOf <#green-goblin> ;\n\
+ \ a foaf:Person ;\n\
+ \ foaf:name \"Spiderman\", \"Человек-паук\"@ru",
+ [
+ ( Predicate.of_iri @@ Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "rel" "enemyOf",
+ [ Obj_iri (Iri.of_iriref (Iriref.of_string "#green-goblin")) ] );
+ ( Predicate.a,
+ [
+ Obj_iri
+ (Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "foaf" "Person");
+ ] );
+ ( Predicate.of_iri @@ Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "foaf" "name",
+ [
+ Obj_literal
+ (Literal.make "Spiderman"
+ (Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "xsd" "string"));
+ Obj_literal
+ (Literal.make "Человек-паук"
+ (Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "xsd" "string")
+ ~language:"ru");
+ ] );
+ ] );
+ (* "<http://www.perceive.net/schemas/relationship/enemyOf> \"LITERAL\" ", *)
+ (* "<http://www.perceive.net/schemas/relationship/enemyOf> .", *)
+ (* [ Predicate.of_iri @@ Iri.of_prefixed_name @@ Prefixed_name.of_strings "" "p", *)
+ (* [ Obj_iri (Iri.of_prefixed_name @@ Prefixed_name.of_strings "" "WWWWWWWWWWWWWWWWWWWwwW"); ] ; ] *)
+ (* ; *)
]
- ;
- "rel:enemyOf <#green-goblin> ;
- a foaf:Person ;
- foaf:name \"Spiderman\", \"Человек-паук\"@ru",
- [ Predicate.of_iri @@ Iri.of_prefixed_name @@ Prefixed_name.of_strings "rel" "enemyOf",
- [ Obj_iri ( Iri.of_iriref (Iriref.of_string "#green-goblin"));]
- ;
- Predicate.a,
- [ Obj_iri (Iri.of_prefixed_name @@ Prefixed_name.of_strings "foaf" "Person");]
- ;
- Predicate.of_iri @@ Iri.of_prefixed_name @@ Prefixed_name.of_strings "foaf" "name",
- [ Obj_literal ( Literal.make
- ("Spiderman")
- (Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string"));
- Obj_literal ( Literal.make
- ("Человек-паук")
- (Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string")
- ~language:"ru");
- ]
- ] ;
-(* "<http://www.perceive.net/schemas/relationship/enemyOf> \"LITERAL\" ", *)
-(* "<http://www.perceive.net/schemas/relationship/enemyOf> .", *)
-(* [ Predicate.of_iri @@ Iri.of_prefixed_name @@ Prefixed_name.of_strings "" "p", *)
-(* [ Obj_iri (Iri.of_prefixed_name @@ Prefixed_name.of_strings "" "WWWWWWWWWWWWWWWWWWWwwW"); ] ; ] *)
-(* ; *)
- ] in
- test_case "predobjs" `Quick
- (fun () ->
- List.iter
- (fun (enc, v) ->
- check (result Rdf_alcotest.ast_predobjs string)
- "can parse"
- (parse Parser.predobjs enc)
- (Result.ok @@ v))
- cases)
+ in
+ test_case "predobjs" `Quick (fun () ->
+ List.iter
+ (fun (enc, v) ->
+ check
+ (result ast_predobjs_testable string)
+ "can parse"
+ (parse Parser.predobjs enc)
+ (Result.ok @@ v))
+ cases)
let subject_test_case =
- let cases = [
- (* Iri *)
- "<http://one.example/>",
- Sub_iri (Iri.of_iriref (Iriref.of_string "http://one.example/"));
- (* Collection *)
- "(\"1\" [:p :q] ( \"2\" ) )",
- Sub_coll (
- Collection (
- [
- Obj_literal (
- Literal.make
- ("1")
- (Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string")) ;
- Obj_bnodps (
- BnodPs (
- [ Predicate.of_iri @@ Iri.of_prefixed_name @@ Prefixed_name.of_strings "" "p",
- [ Obj_iri (Iri.of_prefixed_name @@ Prefixed_name.of_strings "" "q"); ] ; ]
- )
- ) ;
- Obj_coll (
- Collection (
- [ Obj_literal (
- Literal.make
- ("2")
- (Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string")) ;
- ]
- )
- )
- ]
- )
- ) ;
- ] in
- test_case "subject" `Quick
- (fun () ->
- List.iter
- (fun (enc, v) ->
- check (result Rdf_alcotest.ast_subject string)
- "can parse"
- (parse Parser.subject enc)
- (Result.ok @@ v))
- cases)
+ let cases =
+ [
+ (* Iri *)
+ ( "<http://one.example/>",
+ Sub_iri (Iri.of_iriref (Iriref.of_string "http://one.example/")) );
+ (* Collection *)
+ ( "(\"1\" [:p :q] ( \"2\" ) )",
+ Sub_coll
+ (Collection
+ [
+ Obj_literal
+ (Literal.make "1"
+ (Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "xsd" "string"));
+ Obj_bnodps
+ (BnodPs
+ [
+ ( Predicate.of_iri @@ Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "" "p",
+ [
+ Obj_iri
+ (Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "" "q");
+ ] );
+ ]);
+ Obj_coll
+ (Collection
+ [
+ Obj_literal
+ (Literal.make "2"
+ (Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "xsd" "string"));
+ ]);
+ ]) );
+ ]
+ in
+ test_case "subject" `Quick (fun () ->
+ List.iter
+ (fun (enc, v) ->
+ check
+ (result ast_subject_testable string)
+ "can parse" (parse Parser.subject enc) (Result.ok @@ v))
+ cases)
let triple_test_case =
- let cases = [
- "<http://example.org/#spiderman> <http://www.perceive.net/schemas/relationship/enemyOf> <http://example.org/#green-goblin>",
- Triple.of_subject_and_predobjs
- (Sub_iri (Iri.of_iriref (Iriref.of_string @@ "http://example.org/#spiderman")))
- ([ Predicate.of_iri @@ Iri.of_iriref "http://www.perceive.net/schemas/relationship/enemyOf",
- [ Obj_iri (Iri.of_iriref "http://example.org/#green-goblin"); ] ; ])
- ;
-(* TODO why does this test fail? *)
-(* "[ foaf:name \"Bob\" ]", *)
-(* Triple.of_bnodps ( *)
-(* BnodPs ([ Predicate.of_iri @@ Iri.of_prefixed_name @@ Prefixed_name.of_strings "foaf" "name", *)
-(* [ Obj_literal ( Literal.make *)
-(* ("Bob") *)
-(* (Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string")) *)
-(* ] *)
-(* ])) *)
-(* ; *)
- ] in
- test_case "triple" `Quick
- (fun () ->
- List.iter
- (fun (enc, v) ->
- check (result Rdf_alcotest.ast_triple string)
- "can parse"
- (parse Parser.triple enc)
- (Result.ok @@ v))
- cases)
+ let cases =
+ [
+ ( "<http://example.org/#spiderman> \
+ <http://www.perceive.net/schemas/relationship/enemyOf> \
+ <http://example.org/#green-goblin>",
+ Triple.of_subject_and_predobjs
+ (Sub_iri
+ (Iri.of_iriref
+ (Iriref.of_string @@ "http://example.org/#spiderman")))
+ [
+ ( Predicate.of_iri
+ @@ Iri.of_iriref
+ "http://www.perceive.net/schemas/relationship/enemyOf",
+ [ Obj_iri (Iri.of_iriref "http://example.org/#green-goblin") ] );
+ ] );
+ (* TODO why does this test fail? *)
+ (* "[ foaf:name \"Bob\" ]", *)
+ (* Triple.of_bnodps ( *)
+ (* BnodPs ([ Predicate.of_iri @@ Iri.of_prefixed_name @@ Prefixed_name.of_strings "foaf" "name", *)
+ (* [ Obj_literal ( Literal.make *)
+ (* ("Bob") *)
+ (* (Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string")) *)
+ (* ] *)
+ (* ])) *)
+ (* ; *)
+ ]
+ in
+ test_case "triple" `Quick (fun () ->
+ List.iter
+ (fun (enc, v) ->
+ check
+ (result ast_triple_testable string)
+ "can parse" (parse Parser.triple enc) (Result.ok @@ v))
+ cases)
let directive_test_case =
- let cases = [
- "@base <http://one.example/>",
- Directive.of_iriref (Iriref.of_string "http://one.example/")
- ;
- "@prefix foaf: <http://xmlns.com/foaf/0.1/> ",
- Directive.of_string_and_iriref
- "foaf"
- (Iriref.of_string "http://xmlns.com/foaf/0.1/")
- ;
- ] in
- test_case "directive" `Quick
- (fun () ->
- List.iter
- (fun (enc, v) ->
- check (result Rdf_alcotest.ast_directive string)
- "can parse"
- (parse Parser.directive enc)
- (Result.ok @@ v))
- cases)
+ let cases =
+ [
+ ( "@base <http://one.example/>",
+ Directive.of_iriref (Iriref.of_string "http://one.example/") );
+ ( "@prefix foaf: <http://xmlns.com/foaf/0.1/> ",
+ Directive.of_string_and_iriref "foaf"
+ (Iriref.of_string "http://xmlns.com/foaf/0.1/") );
+ ]
+ in
+ test_case "directive" `Quick (fun () ->
+ List.iter
+ (fun (enc, v) ->
+ check
+ (result ast_directive_testable string)
+ "can parse"
+ (parse Parser.directive enc)
+ (Result.ok @@ v))
+ cases)
let statement_test_case =
- let cases = [
- "@prefix foaf: <http://xmlns.com/foaf/0.1/> .",
- Statement.of_directive (
- Directive.of_string_and_iriref
- "foaf"
- (Iriref.of_string "http://xmlns.com/foaf/0.1/"))
- ;
- "<http://example.org/#spiderman>
- <http://www.perceive.net/schemas/relationship/enemyOf> <http://example.org/#green-goblin> .",
- Statement.of_triple (
- Triple.of_subject_and_predobjs
- (Sub_iri (Iri.of_iriref (Iriref.of_string @@ "http://example.org/#spiderman")))
- ([ Predicate.of_iri @@ Iri.of_iriref "http://www.perceive.net/schemas/relationship/enemyOf",
- [ Obj_iri (Iri.of_iriref "http://example.org/#green-goblin"); ] ; ]))
- ;
-(* "<http://example.org/#spiderman> <http://www.perceive.net/schemas/relationship/enemyOf> \"literal\" .", *)
- "<http://example.org/#spiderman>
- <http://www.perceive.net/schemas/relationship/enemyOf> <http://example.org/#green-goblin> .",
- Statement.of_triple (
- Triple.of_subject_and_predobjs
- (Sub_iri (Iri.of_iriref (Iriref.of_string @@ "http://example.org/#spiderman")))
- ([ Predicate.of_iri @@ Iri.of_iriref "http://www.perceive.net/schemas/relationship/enemyOf",
- [ Obj_iri (Iri.of_iriref "http://example.org/#green-goblin"); ] ; ]))
- ;
- "<http://example.org/#spiderman> <http://www.perceive.net/schemas/relationship/enemyOf> \"literal\" .",
- Statement.of_triple (
- Triple.of_subject_and_predobjs
- (Sub_iri (Iri.of_iriref (Iriref.of_string @@ "http://example.org/#spiderman")))
- ([ Predicate.of_iri @@ Iri.of_iriref "http://www.perceive.net/schemas/relationship/enemyOf",
- [ Obj_literal ( Literal.make
- "literal"
- (Iri.of_prefixed_name @@ Prefixed_name.of_strings "xsd" "string")
- )]]))
- ;
- ] in
- test_case "statement" `Quick
- (fun () ->
- List.iter
- (fun (enc, v) ->
- check (result Rdf_alcotest.ast_statement string)
- "can parse"
- (parse Parser.statement enc)
- (Result.ok @@ v))
- cases)
+ let cases =
+ [
+ ( "@prefix foaf: <http://xmlns.com/foaf/0.1/> .",
+ Statement.of_directive
+ (Directive.of_string_and_iriref "foaf"
+ (Iriref.of_string "http://xmlns.com/foaf/0.1/")) );
+ ( "<http://example.org/#spiderman>\n\
+ \ <http://www.perceive.net/schemas/relationship/enemyOf> \
+ <http://example.org/#green-goblin> .",
+ Statement.of_triple
+ (Triple.of_subject_and_predobjs
+ (Sub_iri
+ (Iri.of_iriref
+ (Iriref.of_string @@ "http://example.org/#spiderman")))
+ [
+ ( Predicate.of_iri
+ @@ Iri.of_iriref
+ "http://www.perceive.net/schemas/relationship/enemyOf",
+ [ Obj_iri (Iri.of_iriref "http://example.org/#green-goblin") ]
+ );
+ ]) );
+ (* "<http://example.org/#spiderman> <http://www.perceive.net/schemas/relationship/enemyOf> \"literal\" .", *)
+ ( "<http://example.org/#spiderman>\n\
+ \ <http://www.perceive.net/schemas/relationship/enemyOf> \
+ <http://example.org/#green-goblin> .",
+ Statement.of_triple
+ (Triple.of_subject_and_predobjs
+ (Sub_iri
+ (Iri.of_iriref
+ (Iriref.of_string @@ "http://example.org/#spiderman")))
+ [
+ ( Predicate.of_iri
+ @@ Iri.of_iriref
+ "http://www.perceive.net/schemas/relationship/enemyOf",
+ [ Obj_iri (Iri.of_iriref "http://example.org/#green-goblin") ]
+ );
+ ]) );
+ ( "<http://example.org/#spiderman> \
+ <http://www.perceive.net/schemas/relationship/enemyOf> \"literal\" .",
+ Statement.of_triple
+ (Triple.of_subject_and_predobjs
+ (Sub_iri
+ (Iri.of_iriref
+ (Iriref.of_string @@ "http://example.org/#spiderman")))
+ [
+ ( Predicate.of_iri
+ @@ Iri.of_iriref
+ "http://www.perceive.net/schemas/relationship/enemyOf",
+ [
+ Obj_literal
+ (Literal.make "literal"
+ (Iri.of_prefixed_name
+ @@ Prefixed_name.of_strings "xsd" "string"));
+ ] );
+ ]) );
+ ]
+ in
+ test_case "statement" `Quick (fun () ->
+ List.iter
+ (fun (enc, v) ->
+ check
+ (result ast_statement_testable string)
+ "can parse"
+ (parse Parser.statement enc)
+ (Result.ok @@ v))
+ cases)
let turtle_test_case =
- let cases = [
- "@prefix foaf: <http://xmlns.com/foaf/0.1/> .",
- Turtle.of_statement_lst (
- [Statement.of_directive (
- Directive.of_string_and_iriref
- "foaf"
- (Iriref.of_string "http://xmlns.com/foaf/0.1/"))])
- ;
- "<http://example.org/#spiderman> <http://www.perceive.net/schemas/relationship/enemyOf> <http://example.org/#green-goblin> .",
- Turtle.of_statement_lst (
- [Statement.of_triple (
- Triple.of_subject_and_predobjs
- (Sub_iri (Iri.of_iriref (Iriref.of_string @@ "http://example.org/#spiderman")))
- ([ Predicate.of_iri @@ Iri.of_iriref "http://www.perceive.net/schemas/relationship/enemyOf",
- [ Obj_iri (Iri.of_iriref "http://example.org/#green-goblin"); ] ; ]))])
- ;
- "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix show: <http://example.org/vocab/show/> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .",
- Turtle.of_statement_lst (
- [ Statement.of_directive (
- Directive.of_string_and_iriref
- "rdfs"
- (Iriref.of_string "http://www.w3.org/2000/01/rdf-schema#"))
- ;
- Statement.of_directive (
- Directive.of_string_and_iriref
- "show"
- (Iriref.of_string "http://example.org/vocab/show/"))
- ;
- Statement.of_directive (
- Directive.of_string_and_iriref
- "xsd"
- (Iriref.of_string "http://www.w3.org/2001/XMLSchema#"))
- ])
- ;
- ] in
- test_case "turtle" `Quick
- (fun () ->
- List.iter
- (fun (enc, v) ->
- check (result Rdf_alcotest.ast_turtle string)
- "can parse"
- (parse Parser.turtle enc)
- (Result.ok @@ v))
- cases)
+ let cases =
+ [
+ ( "@prefix foaf: <http://xmlns.com/foaf/0.1/> .",
+ Turtle.of_statement_lst
+ [
+ Statement.of_directive
+ (Directive.of_string_and_iriref "foaf"
+ (Iriref.of_string "http://xmlns.com/foaf/0.1/"));
+ ] );
+ ( "<http://example.org/#spiderman> \
+ <http://www.perceive.net/schemas/relationship/enemyOf> \
+ <http://example.org/#green-goblin> .",
+ Turtle.of_statement_lst
+ [
+ Statement.of_triple
+ (Triple.of_subject_and_predobjs
+ (Sub_iri
+ (Iri.of_iriref
+ (Iriref.of_string @@ "http://example.org/#spiderman")))
+ [
+ ( Predicate.of_iri
+ @@ Iri.of_iriref
+ "http://www.perceive.net/schemas/relationship/enemyOf",
+ [
+ Obj_iri
+ (Iri.of_iriref "http://example.org/#green-goblin");
+ ] );
+ ]);
+ ] );
+ ( "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix show: \
+ <http://example.org/vocab/show/> . @prefix xsd: \
+ <http://www.w3.org/2001/XMLSchema#> .",
+ Turtle.of_statement_lst
+ [
+ Statement.of_directive
+ (Directive.of_string_and_iriref "rdfs"
+ (Iriref.of_string "http://www.w3.org/2000/01/rdf-schema#"));
+ Statement.of_directive
+ (Directive.of_string_and_iriref "show"
+ (Iriref.of_string "http://example.org/vocab/show/"));
+ Statement.of_directive
+ (Directive.of_string_and_iriref "xsd"
+ (Iriref.of_string "http://www.w3.org/2001/XMLSchema#"));
+ ] );
+ ]
+ in
+ test_case "turtle" `Quick (fun () ->
+ List.iter
+ (fun (enc, v) ->
+ check
+ (result ast_turtle_testable string)
+ "can parse" (parse Parser.turtle enc) (Result.ok @@ v))
+ cases)
(* 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.
@@ -451,338 +565,345 @@ let turtle_test_case =
* immediately clear where the problems lie, since the decode function is a composition of other
* (already quite complicated) functions. *)
let turtle_to_graph_test_case =
-(* A triple of three Iri's *)
+ (* A triple of three Iri's *)
let triple_of_iri_iri_iri sub pred obj =
- (Rdf.Triple.make
- (Rdf.Triple.Subject.of_iri @@ Rdf.Iri.of_string sub)
- (Rdf.Triple.Predicate.of_iri @@ Rdf.Iri.of_string pred)
- (Rdf.Triple.Object.of_iri @@ Rdf.Iri.of_string obj))
+ Rdf.Triple.make
+ (Rdf.Triple.Subject.of_iri @@ Rdf.Iri.of_string sub)
+ (Rdf.Triple.Predicate.of_iri @@ Rdf.Iri.of_string pred)
+ (Rdf.Triple.Object.of_iri @@ Rdf.Iri.of_string obj)
in
-(* A triple of an iri, an iri, and a blank_node *)
+ (* A triple of an iri, an iri, and a blank_node *)
let triple_of_iri_iri_bnode sub pred obj =
- (Rdf.Triple.make
- (Rdf.Triple.Subject.of_iri @@ Rdf.Iri.of_string sub)
- (Rdf.Triple.Predicate.of_iri @@ Rdf.Iri.of_string pred)
- (Rdf.Triple.Object.of_blank_node @@ Rdf.Blank_node.of_string obj))
+ Rdf.Triple.make
+ (Rdf.Triple.Subject.of_iri @@ Rdf.Iri.of_string sub)
+ (Rdf.Triple.Predicate.of_iri @@ Rdf.Iri.of_string pred)
+ (Rdf.Triple.Object.of_blank_node @@ Rdf.Blank_node.of_string obj)
in
-(* A triple of a blank_node, an iri, and an iri *)
+ (* A triple of a blank_node, an iri, and an iri *)
let triple_of_bnode_iri_iri sub pred obj =
- (Rdf.Triple.make
- (Rdf.Triple.Subject.of_blank_node @@ Rdf.Blank_node.of_string sub)
- (Rdf.Triple.Predicate.of_iri @@ Rdf.Iri.of_string pred)
- (Rdf.Triple.Object.of_iri @@ Rdf.Iri.of_string obj))
+ Rdf.Triple.make
+ (Rdf.Triple.Subject.of_blank_node @@ Rdf.Blank_node.of_string sub)
+ (Rdf.Triple.Predicate.of_iri @@ Rdf.Iri.of_string pred)
+ (Rdf.Triple.Object.of_iri @@ Rdf.Iri.of_string obj)
in
-(* A triple of a blank_node, an iri, and a blank_node *)
+ (* A triple of a blank_node, an iri, and a blank_node *)
let triple_of_bnode_iri_bnode sub pred obj =
- (Rdf.Triple.make
- (Rdf.Triple.Subject.of_blank_node @@ Rdf.Blank_node.of_string sub)
- (Rdf.Triple.Predicate.of_iri @@ Rdf.Iri.of_string pred)
- (Rdf.Triple.Object.of_blank_node @@ Rdf.Blank_node.of_string obj))
+ Rdf.Triple.make
+ (Rdf.Triple.Subject.of_blank_node @@ Rdf.Blank_node.of_string sub)
+ (Rdf.Triple.Predicate.of_iri @@ Rdf.Iri.of_string pred)
+ (Rdf.Triple.Object.of_blank_node @@ Rdf.Blank_node.of_string obj)
in
-(* A triple of a blank_node, an iri, and a literal
- * The language and value are optional since a lot of literals are given by
- * their value, and nothing else. *)
+ (* A triple of a blank_node, an iri, and a literal
+ * The language and value are optional since a lot of literals are given by
+ * their value, and nothing else. *)
let obj_literal ?obj_language ?obj_datatype obj_value =
- match obj_language, obj_datatype with
- | (Some lang), (Some datatype) ->
+ match (obj_language, obj_datatype) with
+ | Some lang, Some datatype ->
let obj_datatype_iri = Rdf.Iri.of_string datatype in
- Rdf.Literal.make
- obj_value
- ~language:lang
- obj_datatype_iri
- | (None), Some datatype ->
+ Rdf.Literal.make obj_value ~language:lang obj_datatype_iri
+ | None, Some datatype ->
let obj_datatype_iri = Rdf.Iri.of_string datatype in
Rdf.Literal.make obj_value obj_datatype_iri
- | Some lang, None ->
- let obj_datatype_iri = Rdf.Iri.of_string "http://www.w3.org/2001/XMLSchema#string" in
- Rdf.Literal.make
- obj_value
- ~language:lang
- obj_datatype_iri
- | None, None ->
+ | Some lang, None ->
+ let obj_datatype_iri =
+ Rdf.Iri.of_string "http://www.w3.org/2001/XMLSchema#string"
+ in
+ Rdf.Literal.make obj_value ~language:lang obj_datatype_iri
+ | None, None ->
Fmt.pr "DO YOU HEAR ME?";
- let obj_datatype_iri = Rdf.Iri.of_string "http://www.w3.org/2001/XMLSchema#string" in
+ let obj_datatype_iri =
+ Rdf.Iri.of_string "http://www.w3.org/2001/XMLSchema#string"
+ in
Rdf.Literal.make obj_value obj_datatype_iri
in
-(* A triple of an iri, an iri, and a literal *)
+ (* A triple of an iri, an iri, and a literal *)
let triple_of_iri_iri_literal sub pred ?obj_language ?obj_datatype obj_value =
let obj_literal = obj_literal ?obj_language ?obj_datatype obj_value in
- (Rdf.Triple.make
- (Rdf.Triple.Subject.of_iri @@ Rdf.Iri.of_string sub)
- (Rdf.Triple.Predicate.of_iri @@ Rdf.Iri.of_string pred)
- (Rdf.Triple.Object.of_literal @@ obj_literal))
+ Rdf.Triple.make
+ (Rdf.Triple.Subject.of_iri @@ Rdf.Iri.of_string sub)
+ (Rdf.Triple.Predicate.of_iri @@ Rdf.Iri.of_string pred)
+ (Rdf.Triple.Object.of_literal @@ obj_literal)
in
- let triple_of_bnode_iri_literal sub pred ?obj_language ?obj_datatype obj_value =
+ let triple_of_bnode_iri_literal sub pred ?obj_language ?obj_datatype obj_value
+ =
let obj_literal = obj_literal ?obj_language ?obj_datatype obj_value in
- (Rdf.Triple.make
- (Rdf.Triple.Subject.of_blank_node @@ Rdf.Blank_node.of_string sub)
- (Rdf.Triple.Predicate.of_iri @@ Rdf.Iri.of_string pred)
- (Rdf.Triple.Object.of_literal @@ obj_literal))
+ Rdf.Triple.make
+ (Rdf.Triple.Subject.of_blank_node @@ Rdf.Blank_node.of_string sub)
+ (Rdf.Triple.Predicate.of_iri @@ Rdf.Iri.of_string pred)
+ (Rdf.Triple.Object.of_literal @@ obj_literal)
in
let nil = "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil" in
let first = "http://www.w3.org/1999/02/22-rdf-syntax-ns#first" in
let rest = "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest" in
let a_pred = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" in
- let cases = [
- "<sub> <pred> <obj> .",
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_iri_iri_iri "sub" "pred" "obj")
- ;
- (* SUBJECT = COLLECTION *)
- "() <http://a.example/p> <http://a.example/o> .",
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_iri_iri_iri nil "http://a.example/p" "http://a.example/o")
- ;
- "(\"hello\") <http://a.example/p> <http://a.example/o> .",
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" "http://a.example/p" "http://a.example/o")
- |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid1" first "hello")
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" rest nil)
- ;
- "('1' '2') <http://a.example/p> <http://a.example/o> .",
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" "http://a.example/p" "http://a.example/o")
- |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid1" first "1")
- |> Rdf.Graph.add (triple_of_bnode_iri_bnode "genid1" rest "genid2")
- |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid2" first "2")
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid2" rest nil)
- ;
- "('1' '2' '3') <http://a.example/p> <http://a.example/o> .",
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" "http://a.example/p" "http://a.example/o")
- |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid1" first "1")
- |> Rdf.Graph.add (triple_of_bnode_iri_bnode "genid1" rest "genid2")
- |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid2" first "2")
- |> Rdf.Graph.add (triple_of_bnode_iri_bnode "genid2" rest "genid3")
- |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid3" first "3")
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid3" rest nil)
- ;
- (* OBJECT = COLLECTION *)
- "<http://a.example/s> <http://a.example/p> () .",
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_iri_iri_iri "http://a.example/s" "http://a.example/p" nil)
- ;
- "<http://a.example/s> <http://a.example/p> ('1') .",
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_iri_iri_bnode "http://a.example/s" "http://a.example/p" "genid1")
- |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid1" first "1")
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" rest nil)
- ;
- "<http://a.example/s> <http://a.example/p> ('1' '2') .",
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_iri_iri_bnode "http://a.example/s" "http://a.example/p" "genid1")
- |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid1" first "1")
- |> Rdf.Graph.add (triple_of_bnode_iri_bnode "genid1" rest "genid2")
- |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid2" first "2")
- |> Rdf.Graph.add (triple_of_bnode_iri_iri"genid2" rest nil)
- ;
- "<http://a.example/s> <http://a.example/p> ('1' '2' '3') .",
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_iri_iri_bnode "http://a.example/s" "http://a.example/p" "genid1")
- |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid1" first "1")
- |> Rdf.Graph.add (triple_of_bnode_iri_bnode "genid1" rest "genid2")
- |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid2" first "2")
- |> Rdf.Graph.add (triple_of_bnode_iri_bnode"genid2" rest "genid3")
- |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid3" first "3")
- |> Rdf.Graph.add (triple_of_bnode_iri_iri"genid3" rest nil)
- ;
- (* SUBJECT = BNODPS, this works *)
- "[] <http://a.example/p> <http://a.example/o> .",
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" "http://a.example/p" "http://a.example/o")
- ;
- "
- @prefix as: <https://www.w3.org/ns/activitystreams#> .
- [ a as:Person ; ]
- <http://a.example/p> <http://a.example/o> .",
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_bnode_iri_iri
- "genid1"
- a_pred
- "https://www.w3.org/ns/activitystreams#Person")
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" "http://a.example/p" "http://a.example/o")
- ;
- "
- @prefix as: <https://www.w3.org/ns/activitystreams#> .
- @prefix ldp: <http://www.w3.org/ns/ldp#> .
- [ a as:Person ;
- ldp:inbox <http://localhost:4000/users/alice/inbox> ;
- ]
- <http://a.example/p> <http://a.example/o> .",
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_bnode_iri_iri
- "genid1"
- a_pred
- "https://www.w3.org/ns/activitystreams#Person")
- |> Rdf.Graph.add (triple_of_bnode_iri_iri
- "genid1"
- "http://www.w3.org/ns/ldp#inbox"
- "http://localhost:4000/users/alice/inbox")
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" "http://a.example/p" "http://a.example/o")
- ;
- (* TRIPLE / OBJECT = BNODPS *)
- "[<pred> <obj>] .",
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" "pred" "obj")
- ;
- "<sub> <pred> [] .",
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_iri_iri_bnode "sub" "pred" "genid1")
- ;
- "<sub> <pred> [<pred2> <obj2>] .",
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_iri_iri_bnode "sub" "pred" "genid1")
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" "pred2" "obj2")
- ;
- "<sub> <pred> [<pred2> <obj2>, <obj3> ; <pred3> <obj4>, <obj5>] .",
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_iri_iri_bnode "sub" "pred" "genid1")
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" "pred2" "obj2")
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" "pred2" "obj3")
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" "pred3" "obj4")
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" "pred3" "obj5")
- ;
- (* NESTED BNODPS (in subject) *)
- "[ <http://a.example/p1> [ <http://a.example/p2> <http://a.example/o2> ] ; <http://a.example/p> <http://a.example/o> ].",
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_bnode_iri_bnode "genid1" "http://a.example/p1" "genid2")
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid2" "http://a.example/p2" "http://a.example/o2")
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" "http://a.example/p" "http://a.example/o")
- ;
- (* BNODPS (as triple) CONTAINING COLLECTION *)
- "[ <http://a.example/p1> ('1') ] .",
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_bnode_iri_bnode "genid1" "http://a.example/p1" "genid2")
- |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid2" first "1")
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid2" rest nil)
- ;
- (* NESTED COLLECTIONS *)
- "<http://a.example/s> <http://a.example/p> (('1')) .",
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_iri_iri_bnode "http://a.example/s" "http://a.example/p" "genid1")
- |> Rdf.Graph.add (triple_of_bnode_iri_bnode "genid1" first "genid2")
- |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid2" first "1")
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid2" rest nil)
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" rest nil)
- ;
- "<http://a.example/s> <http://a.example/p> ('1' ('2')) .",
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_iri_iri_bnode "http://a.example/s" "http://a.example/p" "genid1")
- |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid1" first "1")
- |> Rdf.Graph.add (triple_of_bnode_iri_bnode "genid1" rest "genid2")
- |> Rdf.Graph.add (triple_of_bnode_iri_bnode "genid2" first "genid3")
- |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid3" first "2")
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid3" rest nil)
- |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid2" rest nil)
- ;
- (* A MORE REALISTIC EXAMPLE *)
- "@prefix as: <https://www.w3.org/ns/activitystreams#> .
- @prefix foaf: <http://xmlns.com/foaf/0.1/> .
- @prefix ldp: <http://www.w3.org/ns/ldp#> .
- @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
- @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
- @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
-
- <http://localhost:4000/users/alice>
- a as:Person ;
- ldp:inbox <http://localhost:4000/users/alice/inbox> ;
- as:outbox <http://localhost:4000/users/alice/outbox> ;
- as:preferredUsername \"alice\" .
- " ,
- Rdf.Graph.empty
- |> Rdf.Graph.add (triple_of_iri_iri_iri
- "http://localhost:4000/users/alice"
- a_pred
- "https://www.w3.org/ns/activitystreams#Person")
- |> Rdf.Graph.add (triple_of_iri_iri_iri
- "http://localhost:4000/users/alice"
- "http://www.w3.org/ns/ldp#inbox"
- "http://localhost:4000/users/alice/inbox")
- |> Rdf.Graph.add (triple_of_iri_iri_iri
- "http://localhost:4000/users/alice"
- "https://www.w3.org/ns/activitystreams#outbox"
- "http://localhost:4000/users/alice/outbox")
- |> Rdf.Graph.add (triple_of_iri_iri_literal
- "http://localhost:4000/users/alice"
- "https://www.w3.org/ns/activitystreams#preferredUsername"
- "alice")
- ;
- (* 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 () ->
- List.iter
- (fun (enc, v) ->
- check (Rdf_alcotest.graph)
- "can parse and transform"
- (Rdf_turtle.decode enc)
- (v))
- cases)
+ let cases =
+ [
+ ( "<sub> <pred> <obj> .",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add (triple_of_iri_iri_iri "sub" "pred" "obj") );
+ (* SUBJECT = COLLECTION *)
+ ( "() <http://a.example/p> <http://a.example/o> .",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add
+ (triple_of_iri_iri_iri nil "http://a.example/p"
+ "http://a.example/o") );
+ ( "(\"hello\") <http://a.example/p> <http://a.example/o> .",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add
+ (triple_of_bnode_iri_iri "genid1" "http://a.example/p"
+ "http://a.example/o")
+ |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid1" first "hello")
+ |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" rest nil) );
+ ( "('1' '2') <http://a.example/p> <http://a.example/o> .",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add
+ (triple_of_bnode_iri_iri "genid1" "http://a.example/p"
+ "http://a.example/o")
+ |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid1" first "1")
+ |> Rdf.Graph.add (triple_of_bnode_iri_bnode "genid1" rest "genid2")
+ |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid2" first "2")
+ |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid2" rest nil) );
+ ( "('1' '2' '3') <http://a.example/p> <http://a.example/o> .",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add
+ (triple_of_bnode_iri_iri "genid1" "http://a.example/p"
+ "http://a.example/o")
+ |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid1" first "1")
+ |> Rdf.Graph.add (triple_of_bnode_iri_bnode "genid1" rest "genid2")
+ |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid2" first "2")
+ |> Rdf.Graph.add (triple_of_bnode_iri_bnode "genid2" rest "genid3")
+ |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid3" first "3")
+ |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid3" rest nil) );
+ (* OBJECT = COLLECTION *)
+ ( "<http://a.example/s> <http://a.example/p> () .",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add
+ (triple_of_iri_iri_iri "http://a.example/s" "http://a.example/p"
+ nil) );
+ ( "<http://a.example/s> <http://a.example/p> ('1') .",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add
+ (triple_of_iri_iri_bnode "http://a.example/s" "http://a.example/p"
+ "genid1")
+ |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid1" first "1")
+ |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" rest nil) );
+ ( "<http://a.example/s> <http://a.example/p> ('1' '2') .",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add
+ (triple_of_iri_iri_bnode "http://a.example/s" "http://a.example/p"
+ "genid1")
+ |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid1" first "1")
+ |> Rdf.Graph.add (triple_of_bnode_iri_bnode "genid1" rest "genid2")
+ |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid2" first "2")
+ |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid2" rest nil) );
+ ( "<http://a.example/s> <http://a.example/p> ('1' '2' '3') .",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add
+ (triple_of_iri_iri_bnode "http://a.example/s" "http://a.example/p"
+ "genid1")
+ |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid1" first "1")
+ |> Rdf.Graph.add (triple_of_bnode_iri_bnode "genid1" rest "genid2")
+ |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid2" first "2")
+ |> Rdf.Graph.add (triple_of_bnode_iri_bnode "genid2" rest "genid3")
+ |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid3" first "3")
+ |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid3" rest nil) );
+ (* SUBJECT = BNODPS, this works *)
+ ( "[] <http://a.example/p> <http://a.example/o> .",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add
+ (triple_of_bnode_iri_iri "genid1" "http://a.example/p"
+ "http://a.example/o") );
+ ( "\n\
+ \ @prefix as: <https://www.w3.org/ns/activitystreams#> .\n\
+ \ [ a as:Person ; ]\n\
+ \ <http://a.example/p> <http://a.example/o> .",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add
+ (triple_of_bnode_iri_iri "genid1" a_pred
+ "https://www.w3.org/ns/activitystreams#Person")
+ |> Rdf.Graph.add
+ (triple_of_bnode_iri_iri "genid1" "http://a.example/p"
+ "http://a.example/o") );
+ ( "\n\
+ \ @prefix as: <https://www.w3.org/ns/activitystreams#> .\n\
+ \ @prefix ldp: <http://www.w3.org/ns/ldp#> .\n\
+ \ [ a as:Person ;\n\
+ \ ldp:inbox <http://localhost:4000/users/alice/inbox> ;\n\
+ \ ]\n\
+ \ <http://a.example/p> <http://a.example/o> .",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add
+ (triple_of_bnode_iri_iri "genid1" a_pred
+ "https://www.w3.org/ns/activitystreams#Person")
+ |> Rdf.Graph.add
+ (triple_of_bnode_iri_iri "genid1" "http://www.w3.org/ns/ldp#inbox"
+ "http://localhost:4000/users/alice/inbox")
+ |> Rdf.Graph.add
+ (triple_of_bnode_iri_iri "genid1" "http://a.example/p"
+ "http://a.example/o") );
+ (* TRIPLE / OBJECT = BNODPS *)
+ ( "[<pred> <obj>] .",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" "pred" "obj") );
+ ( "<sub> <pred> [] .",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add (triple_of_iri_iri_bnode "sub" "pred" "genid1") );
+ ( "<sub> <pred> [<pred2> <obj2>] .",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add (triple_of_iri_iri_bnode "sub" "pred" "genid1")
+ |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" "pred2" "obj2") );
+ ( "<sub> <pred> [<pred2> <obj2>, <obj3> ; <pred3> <obj4>, <obj5>] .",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add (triple_of_iri_iri_bnode "sub" "pred" "genid1")
+ |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" "pred2" "obj2")
+ |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" "pred2" "obj3")
+ |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" "pred3" "obj4")
+ |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" "pred3" "obj5") );
+ (* NESTED BNODPS (in subject) *)
+ ( "[ <http://a.example/p1> [ <http://a.example/p2> <http://a.example/o2> \
+ ] ; <http://a.example/p> <http://a.example/o> ].",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add
+ (triple_of_bnode_iri_bnode "genid1" "http://a.example/p1" "genid2")
+ |> Rdf.Graph.add
+ (triple_of_bnode_iri_iri "genid2" "http://a.example/p2"
+ "http://a.example/o2")
+ |> Rdf.Graph.add
+ (triple_of_bnode_iri_iri "genid1" "http://a.example/p"
+ "http://a.example/o") );
+ (* BNODPS (as triple) CONTAINING COLLECTION *)
+ ( "[ <http://a.example/p1> ('1') ] .",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add
+ (triple_of_bnode_iri_bnode "genid1" "http://a.example/p1" "genid2")
+ |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid2" first "1")
+ |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid2" rest nil) );
+ (* NESTED COLLECTIONS *)
+ ( "<http://a.example/s> <http://a.example/p> (('1')) .",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add
+ (triple_of_iri_iri_bnode "http://a.example/s" "http://a.example/p"
+ "genid1")
+ |> Rdf.Graph.add (triple_of_bnode_iri_bnode "genid1" first "genid2")
+ |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid2" first "1")
+ |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid2" rest nil)
+ |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid1" rest nil) );
+ ( "<http://a.example/s> <http://a.example/p> ('1' ('2')) .",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add
+ (triple_of_iri_iri_bnode "http://a.example/s" "http://a.example/p"
+ "genid1")
+ |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid1" first "1")
+ |> Rdf.Graph.add (triple_of_bnode_iri_bnode "genid1" rest "genid2")
+ |> Rdf.Graph.add (triple_of_bnode_iri_bnode "genid2" first "genid3")
+ |> Rdf.Graph.add (triple_of_bnode_iri_literal "genid3" first "2")
+ |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid3" rest nil)
+ |> Rdf.Graph.add (triple_of_bnode_iri_iri "genid2" rest nil) );
+ (* A MORE REALISTIC EXAMPLE *)
+ ( "@prefix as: <https://www.w3.org/ns/activitystreams#> .\n\
+ \ @prefix foaf: <http://xmlns.com/foaf/0.1/> .\n\
+ \ @prefix ldp: <http://www.w3.org/ns/ldp#> .\n\
+ \ @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n\
+ \ @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n\
+ \ @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n\n\
+ \ <http://localhost:4000/users/alice>\n\
+ \ a as:Person ;\n\
+ \ ldp:inbox <http://localhost:4000/users/alice/inbox> ;\n\
+ \ as:outbox <http://localhost:4000/users/alice/outbox> ;\n\
+ \ as:preferredUsername \"alice\" .\n\
+ \ ",
+ Rdf.Graph.empty
+ |> Rdf.Graph.add
+ (triple_of_iri_iri_iri "http://localhost:4000/users/alice" a_pred
+ "https://www.w3.org/ns/activitystreams#Person")
+ |> Rdf.Graph.add
+ (triple_of_iri_iri_iri "http://localhost:4000/users/alice"
+ "http://www.w3.org/ns/ldp#inbox"
+ "http://localhost:4000/users/alice/inbox")
+ |> Rdf.Graph.add
+ (triple_of_iri_iri_iri "http://localhost:4000/users/alice"
+ "https://www.w3.org/ns/activitystreams#outbox"
+ "http://localhost:4000/users/alice/outbox")
+ |> Rdf.Graph.add
+ (triple_of_iri_iri_literal "http://localhost:4000/users/alice"
+ "https://www.w3.org/ns/activitystreams#preferredUsername"
+ "alice") );
+ (* 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 () ->
+ List.iter
+ (fun (enc, v) ->
+ check Rdf_alcotest.graph "can parse and transform"
+ (Rdf_turtle.decode enc) v)
+ cases)
let () =
- Alcotest.run "Turtle" [
- "Turtle parsers", [
- iriref_test_case;
- language_test_case;
- prefixed_name_test_case;
- blank_node_test_case;
- iri_test_case;
- literal_test_case;
- predicate_test_case;
- object_test_case;
- bnodps_test_case;
- predobjs_test_case;
- subject_test_case;
- triple_test_case;
- directive_test_case;
- statement_test_case;
- turtle_test_case;
- turtle_to_graph_test_case;
+ Alcotest.run "Turtle"
+ [
+ ( "Turtle parsers",
+ [
+ iriref_test_case;
+ language_test_case;
+ prefixed_name_test_case;
+ blank_node_test_case;
+ iri_test_case;
+ literal_test_case;
+ predicate_test_case;
+ object_test_case;
+ bnodps_test_case;
+ predobjs_test_case;
+ subject_test_case;
+ triple_test_case;
+ directive_test_case;
+ statement_test_case;
+ turtle_test_case;
+ turtle_to_graph_test_case;
+ ] );
]
- ]