diff options
Diffstat (limited to 'test/run.scm')
-rw-r--r-- | test/run.scm | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/run.scm b/test/run.scm index 6d8f9f0..a2a515b 100644 --- a/test/run.scm +++ b/test/run.scm @@ -74,6 +74,21 @@ (test-assert "json-object-contains-key? should be met when the associated value is json-null" (json-object-contains-key? (json-object `(x . ,json-null)) 'x)) +(test-equal "json-ref should get a value associated with a key in an object" + 5 (json-ref (json-object '(x . 5)) 'x)) + +(test-equal "json-ref should get the value at an index of a list" + 5 (json-ref (json-object '(x . 5) '(y . #t)) 'x)) + +(test-equal "json-ref should get the value at an index of a list" + 2 (json-ref (json-list 1 2 3) 1)) + +(test-equal "json-ref should recursively get a value in a list in an object" + json-null (json-ref (json-object `(x . ,(json-list #t json-null #f))) 'x 1)) + +(test-equal "json-ref should recursively get a value in an object in a list" + 5 (json-ref (json-list (json-object) (json-object '(a . 4) '(b . 5) '(c . 6)) #t) 1 'b)) + ;; (json (object)) ; => {} ;; (json (list)) ; => [] |