changeset 2431:d1946cb32121

bool support
author drewp@bigasterisk.com
date Tue, 28 May 2024 15:34:21 -0700
parents 1082f0725c32
children b8a408caf115
files src/light9/typedgraph.py src/light9/typedgraph_test.py
diffstat 2 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/light9/typedgraph.py	Tue May 28 15:34:03 2024 -0700
+++ b/src/light9/typedgraph.py	Tue May 28 15:34:21 2024 -0700
@@ -44,6 +44,7 @@
     for outType, dtypes in [
         (float, (XSD['integer'], XSD['double'], XSD['decimal'])),
         (int, (XSD['integer'],)),
+        (bool, (XSD['boolean'],)), # todo tests
         (str, ()),
     ]:
         for t in _expandUnion(objType):
--- a/src/light9/typedgraph_test.py	Tue May 28 15:34:03 2024 -0700
+++ b/src/light9/typedgraph_test.py	Tue May 28 15:34:21 2024 -0700
@@ -19,6 +19,8 @@
         :float1 0.0;
         :float2 1.0e1;
         :float3 0.5;
+        :boolt true;
+        :boolf false;
         :color "#ffffff"^^:hexColor;
         :definitelyAString "hello" .
 '''))
@@ -89,6 +91,9 @@
         assert type(tv) == Literal
         assert tv.datatype == L9['hexColor']
 
+    def test_getsBoolean(self):
+        assert typedValue(bool, g, subj, L9['boolt'])
+        assert not typedValue(bool, g, subj, L9['boolf'])
 
 class TestTypedValueDoesntDoInappropriateUriStringConversions: