summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorArun Isaac2025-11-24 00:24:08 +0000
committerArun Isaac2025-11-24 01:24:07 +0000
commitd22f48630c08ef79fe25c580126a8d9bd373c522 (patch)
tree75a41bbb646e8382914f11fc103c1fbafe90f701 /tests
parentc928d30bdefce4efde218311ef44caf190427efa (diff)
downloadravanan-d22f48630c08ef79fe25c580126a8d9bd373c522.tar.gz
ravanan-d22f48630c08ef79fe25c580126a8d9bd373c522.tar.lz
ravanan-d22f48630c08ef79fe25c580126a8d9bd373c522.zip
reader: Use CWL types in type coercion.
Diffstat (limited to 'tests')
-rw-r--r--tests/reader.scm51
1 files changed, 49 insertions, 2 deletions
diff --git a/tests/reader.scm b/tests/reader.scm
index 75d5ac8..8ac18ec 100644
--- a/tests/reader.scm
+++ b/tests/reader.scm
@@ -22,6 +22,7 @@
              (web uri)
              (ravanan reader)
              (ravanan work command-line-tool)
+             (ravanan work types)
              (ravanan work utils))
 
 (define normalize-formal-input
@@ -35,9 +36,55 @@
 
 (test-begin "reader")
 
-(test-equal "Coerce number to number"
+(test-equal "Coerce to boolean (true)"
+  #t
+  (coerce-type "true" 'boolean))
+
+(test-equal "Coerce to boolean (false)"
+  #f
+  (coerce-type "false" 'boolean))
+
+(test-equal "Coerce to int"
+  37
+  (coerce-type "37" 'int))
+
+(test-equal "Coerce to float"
+  37.1
+  (coerce-type "37.1" 'float))
+
+(test-equal "Coerce to double"
+  37.1
+  (coerce-type "37.1" 'double))
+
+(test-equal "Coerce to string"
+  "37"
+  (coerce-type "37" 'string))
+
+(test-equal "Coerce to File"
+  '(("class" . "File")
+    ("location" . "foo"))
+  (coerce-type '(("class" . "File")
+                 ("location" . "foo"))
+               'File))
+
+(test-equal "Coerce to array"
+  #(1 2 3)
+  (coerce-type #("1" "2" "3")
+               (cwl-array-type 'int)))
+
+(test-equal "Coerce to union type (int first)"
+  37
+  (coerce-type "37"
+               (cwl-union-type 'int 'string)))
+
+(test-equal "Coerce to union type (string first)"
+  "37"
+  (coerce-type "37"
+               (cwl-union-type 'string 'int)))
+
+(test-equal "Coerce int to int"
   37
-  (coerce-type 37 'number))
+  (coerce-type 37 'int))
 
 (test-equal "Normalize File type formal input"
   (canonicalize-json '(("type" . "File")