aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorpukkamustard <pukkamustard@posteo.net>2021-06-07 13:17:34 +0200
committerpukkamustard <pukkamustard@posteo.net>2021-06-07 13:17:34 +0200
commit75b65e94c4245f4626d224a3c5341096da4b6707 (patch)
treeedbaae47535a2752c1f57b9886efe859f308e538 /test
parente4a7e4f906f60941944c8adb7c44d3c78c9d1a03 (diff)
Rdf_datalog: Remove library.
It seems easier to implement Datalog (bindings to existing Datalog) in the `ocaml-dmc` repository. Code has been moved there.
Diffstat (limited to 'test')
-rw-r--r--test/datalog/dune13
-rw-r--r--test/datalog/main.ml36
-rw-r--r--test/datalog/parser.ml116
3 files changed, 0 insertions, 165 deletions
diff --git a/test/datalog/dune b/test/datalog/dune
deleted file mode 100644
index 1ca70ed..0000000
--- a/test/datalog/dune
+++ /dev/null
@@ -1,13 +0,0 @@
-(executables
- (names parser main)
- (libraries rdf_datalog
- rdf_alcotest
- angstrom alcotest))
-
-(rule
- (alias runtest)
- (action (run ./main.exe)))
-
-(rule
- (alias runtest)
- (action (run ./parser.exe)))
diff --git a/test/datalog/main.ml b/test/datalog/main.ml
deleted file mode 100644
index ad6e295..0000000
--- a/test/datalog/main.ml
+++ /dev/null
@@ -1,36 +0,0 @@
-(*
- * SPDX-FileCopyrightText: 2021 petites singularit├ęs <ps-dream@lesoiseaux.io>
- * SPDX-FileCopyrightText: 2021 pukkamustard <pukkamustard@posteo.netq>
- *
- * SPDX-License-Identifier: AGPL-3.0-or-later
- *)
-
-module Parser = Rdf_datalog.Parser
-module Term = Rdf_datalog.Term
-module Literal = Rdf_datalog.Literal
-module Clause = Rdf_datalog.Clause
-module Theory = Rdf_datalog.Theory
-
-let example =
- {example|
-
- edge("a", "b").
- edge("b", "c").
- edge("c", "d").
-
- path(?a,?b) :- edge(?a,?b).
- path(?a,?c) :- edge(?a,?b), path(?b,?c).
-|example}
-
-let parse p string =
- Angstrom.parse_string
- ~consume:Angstrom.Consume.All
- p string
- |> Result.get_ok
-
-let parse_theory = parse Parser.theory
-let parse_query = parse Parser.query
-
-let () =
- Format.printf "%a" (Fmt.list Literal.pp) @@
- Theory.prove (parse_theory example) (parse_query {q|path(?a,?b)?|q})
diff --git a/test/datalog/parser.ml b/test/datalog/parser.ml
deleted file mode 100644
index 7c100dc..0000000
--- a/test/datalog/parser.ml
+++ /dev/null
@@ -1,116 +0,0 @@
-(*
- * SPDX-FileCopyrightText: 2021 petites singularit├ęs <ps-dream@lesoiseaux.io>
- * SPDX-FileCopyrightText: 2021 pukkamustard <pukkamustard@posteo.netq>
- *
- * SPDX-License-Identifier: AGPL-3.0-or-later
- *)
-
-module Parser = Rdf_datalog.Parser
-module Term = Rdf_datalog.Term
-module Literal = Rdf_datalog.Literal
-module Clause = Rdf_datalog.Clause
-
-open Alcotest
-
-let parse p =
- Angstrom.parse_string
- ~consume:Angstrom.Consume.All
- p
-
-let xsd_string_test_case =
- test_case "xsd_string" `Quick
- (fun () ->
- check (result Rdf_alcotest.literal string)
- "can parse"
- (parse Parser.xsd_string "\"Hello World\"")
- (Result.ok @@ Rdf.Literal.make "Hello World" @@ Rdf.Namespace.xsd "string")
- )
-
-let iri_test_case =
- test_case "iri" `Quick
- (fun () ->
- check (result Rdf_alcotest.iri string)
- "can parse"
- (parse Parser.iri "<http://example.com>")
- (Result.ok @@ Rdf.Iri.of_string "http://example.com")
- )
-
-let variable_test_case =
- test_case "variable" `Quick
- (fun () -> check (result string string)
- "can parse"
- (parse Parser.variable "?abc")
- (Result.ok @@ "abc"))
-
-let term_testable =
- testable Term.pp Term.equal
-
-let term_test_case =
- let cases =
- ["?abc", Term.variable "abc";
- "?a", Term.variable "a";
- "<http://example.com>", "http://example.com" |> Rdf.Iri.of_string |> Rdf.Term.of_iri |> Term.constant;
- "\"blups\"", Rdf.Literal.make "blups" (Rdf.Namespace.xsd "string") |> Rdf.Term.of_literal |> Term.constant;
- ] in
-
- test_case "term" `Quick
- (fun () ->
- List.iter
- (fun (enc, v) ->
- check (result term_testable string)
- "can parse"
- (parse Parser.term enc)
- (Result.ok v))
- cases)
-
-let literal_testable =
- testable Literal.pp Literal.equal
-
-let literal_test_case =
- let cases = [
- "p(?a,?b)", Literal.make "p" [Term.variable "a"; Term.variable "b"];
- "graph(?a,<http://example.com>)", Literal.make "graph" [Term.variable "a";
- "http://example.com" |> Rdf.Iri.of_string |> Rdf.Term.of_iri |> Term.constant]
- ] in
- test_case "literal" `Quick
- (fun () ->
- List.iter
- (fun (enc, v) ->
- check (result literal_testable string)
- "can parse"
- (parse Parser.literal enc)
- (Result.ok v))
- cases)
-
-let clause_testable =
- testable Clause.pp Clause.equal
-
-let clause_test_case =
- let cases = [
- "p(?a, ?b).", Literal.make "p" [Term.variable "a"; Term.variable "b"] |> Clause.fact;
- "p(?a, ?b) :- q(?a,?b).", Clause.make
- (Literal.make "p" [Term.variable "a"; Term.variable "b"])
- [(Literal.make "q" [Term.variable "a"; Term.variable "b"])] ;
- ] in
- test_case "clause" `Quick
- (fun () ->
- List.iter
- (fun (enc, v) ->
- check (result clause_testable string)
- "can parse"
- (parse Parser.clause enc)
- (Result.ok v))
- cases)
-
-let () =
- Alcotest.run "Rdf_datalog.Parser"
- [
- "Basic parsers", [
- xsd_string_test_case;
- iri_test_case;
- variable_test_case;
- term_test_case;
- literal_test_case;
- clause_test_case;
- ]
- ]