summaryrefslogtreecommitdiff
path: root/tests/schemantic/literal.scm
diff options
context:
space:
mode:
Diffstat (limited to 'tests/schemantic/literal.scm')
-rw-r--r--tests/schemantic/literal.scm64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/schemantic/literal.scm b/tests/schemantic/literal.scm
new file mode 100644
index 0000000..486ca08
--- /dev/null
+++ b/tests/schemantic/literal.scm
@@ -0,0 +1,64 @@
+; SPDX-FileCopyrightText: 2020 pukkamustard <pukkamustard@posteo.net>
+;
+; SPDX-License-Identifier: GPL-3.0-or-later
+
+(define-module (tests schemantic literal)
+ #:use-module (oop goops)
+ #:use-module (schemantic rdf)
+ #:use-module (schemantic xsd)
+ #:use-module ((schemantic ns) #:select (xsd))
+
+ #:use-module (srfi srfi-64))
+
+(define-namespace ex "http://example.com/#")
+
+(test-begin "generic literal")
+
+(test-assert "generic literal is a literal"
+ (literal?
+ (make-generic-literal 1.9 #:datatype (ex "my-datatype"))))
+
+(test-equal
+ (ex "my-datatype")
+ (literal-datatype
+ (make-generic-literal 1.9 #:datatype (ex "my-datatype"))))
+
+(test-end "generic literal")
+
+(test-begin "xsd:string")
+
+(test-assert "string is cast to a literal"
+ (literal? (make-literal "hello")))
+
+(test-assert "string is cast to a xsd:string"
+ (is-a? (make-literal "hello") <xsd:string> ))
+
+(test-equal "datatype is xsd:string"
+ (xsd "string") (literal-datatype (make-literal "hello")))
+
+(test-equal "value of xsd:string can be refed"
+ "hello"
+ (literal-value (make-literal "hello")))
+
+(test-end "xsd:string")
+
+(test-begin "xsd:integer")
+
+(test-assert "integer is cast to a literal"
+ (literal? (make-literal 42)))
+
+(test-assert "integer is cast to a xsd:integer"
+ (is-a? (make-literal 42) <xsd:integer>))
+
+(test-equal "datatype is xsd:integer"
+ (xsd "integer") (literal-datatype (make-literal 42)))
+
+(test-equal "value of xsd:integer can be refed"
+ 42
+ (literal-value (make-literal 42)))
+
+(test-equal "lexical value is string representatoin"
+ "42"
+ (literal-lexical (make-literal 42)))
+
+(test-end "xsd:integer")