summary refs log tree commit diff
path: root/tests/reader.scm
diff options
context:
space:
mode:
Diffstat (limited to 'tests/reader.scm')
-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")