summaryrefslogtreecommitdiff
path: root/tests/schemantic/rdf/datalog.scm
diff options
context:
space:
mode:
Diffstat (limited to 'tests/schemantic/rdf/datalog.scm')
-rw-r--r--tests/schemantic/rdf/datalog.scm38
1 files changed, 37 insertions, 1 deletions
diff --git a/tests/schemantic/rdf/datalog.scm b/tests/schemantic/rdf/datalog.scm
index 5526b8f..8f7eac1 100644
--- a/tests/schemantic/rdf/datalog.scm
+++ b/tests/schemantic/rdf/datalog.scm
@@ -1,6 +1,6 @@
(define-module (tests schemantic rdf datalog)
#:use-module (schemantic rdf)
- #:use-module ((schemantic ns) #:select (rdf))
+ #:use-module ((schemantic ns) #:select (rdf rdfs))
#:use-module (schemantic serialization turtle)
#:use-module (schemantic graph vhash)
#:use-module (schemantic rdf datalog)
@@ -47,3 +47,39 @@
(set-contains? notes (vector (make-iri "https://test.example/notes/1"))))
(test-end)
+
+(test-begin "ρdf fragment (Simple and Efficient Minimal RDFS)")
+
+(define foods-ttl (make-vhash-graph))
+
+(turtle-transduce
+ (tmap identity)
+ (graph-radd foods-ttl)
+ (call-with-input-file "tests/data/foods.ttl" get-string-all)
+ (make-iri "urn:base-iri"))
+
+(define-namespace foods "http://example.org/foods#")
+
+(define foods-rhodf
+ (cdr
+ (vhash-assoc 'rhodf
+ (datalog-eval
+ (append
+ (list
+ ;; Define all triples as rhodf triples.
+ (:- (rhodf (lvar 's) (lvar 'p) (lvar 'o)) (graph-edb (lvar 's) (lvar 'p) (lvar 'o))))
+ ;; Add the Datalog clauses that define rhodf
+ rhodf)
+ #:edb (add-rdf-graph-to-edb 'graph-edb foods-ttl vlist-null)))))
+
+(test-assert "Subclass (b) (Margherita is Food)"
+ (set-contains?
+ foods-rhodf
+ (vector (foods "Margherita") (rdf "type") (foods "Food"))))
+
+(test-assert "Typing (a)"
+ (set-contains?
+ foods-rhodf
+ (vector (foods "Beer") (rdf "type") (foods "Beverage"))))
+
+(test-end)