diff options
Diffstat (limited to 'src/clojure')
-rw-r--r-- | src/clojure/contrib/json/read.clj | 26 | ||||
-rw-r--r-- | src/clojure/contrib/json/write.clj | 14 |
2 files changed, 20 insertions, 20 deletions
diff --git a/src/clojure/contrib/json/read.clj b/src/clojure/contrib/json/read.clj index 8b4f69c0..03ccde42 100644 --- a/src/clojure/contrib/json/read.clj +++ b/src/clojure/contrib/json/read.clj @@ -19,7 +19,7 @@ (ns clojure.contrib.json.read (:import (java.io PushbackReader StringReader EOFException)) - (:use [clojure.contrib.test-is :only (deftest is)])) + (:use [clojure.contrib.test-is :only (deftest- is)])) (declare read-json) @@ -127,44 +127,44 @@ ;;; TESTS -(deftest can-read-numbers +(deftest- can-read-numbers (is (= 42 (read-json-string "42"))) (is (= -3 (read-json-string "-3"))) (is (= 3.14159 (read-json-string "3.14159"))) (is (= 6.022e23 (read-json-string "6.022e23")))) -(deftest can-read-null +(deftest- can-read-null (is (= nil (read-json-string "null")))) -(deftest can-read-strings +(deftest- can-read-strings (is (= "Hello, World!" (read-json-string "\"Hello, World!\"")))) -(deftest can-read-booleans +(deftest- can-read-booleans (is (= true (read-json-string "true"))) (is (= false (read-json-string "false")))) -(deftest can-ignore-whitespace +(deftest- can-ignore-whitespace (is (= nil (read-json-string "\r\n null")))) -(deftest can-read-arrays +(deftest- can-read-arrays (is (= [1 2 3] (read-json-string "[1,2,3]"))) (is (= ["Ole" "Lena"] (read-json-string "[\"Ole\", \r\n \"Lena\"]")))) -(deftest can-read-objects +(deftest- can-read-objects (is (= {"a" 1, "b" 2} (read-json-string "{\"a\": 1, \"b\": 2}")))) -(deftest can-read-nested-structures +(deftest- can-read-nested-structures (is (= {"a" [1 2 {"b" [3 "four"]} 5.5]} (read-json-string "{\"a\":[1,2,{\"b\":[3,\"four\"]},5.5]}")))) -(deftest disallows-non-string-keys +(deftest- disallows-non-string-keys (is (thrown? Exception (read-json-string "{26:\"z\"")))) -(deftest disallows-barewords +(deftest- disallows-barewords (is (thrown? Exception (read-json-string " foo ")))) -(deftest disallows-unclosed-arrays +(deftest- disallows-unclosed-arrays (is (thrown? Exception (read-json-string "[1, 2, ")))) -(deftest disallows-unclosed-objects +(deftest- disallows-unclosed-objects (is (thrown? Exception (read-json-string "{\"a\":1, ")))) diff --git a/src/clojure/contrib/json/write.clj b/src/clojure/contrib/json/write.clj index 4b6a1f9a..c9e6852b 100644 --- a/src/clojure/contrib/json/write.clj +++ b/src/clojure/contrib/json/write.clj @@ -18,7 +18,7 @@ (ns clojure.contrib.json.write - (:use [clojure.contrib.test-is :only (deftest is)])) + (:use [clojure.contrib.test-is :only (deftest- is)])) (defmulti #^{:doc "Prints Clojure data types as JSON. Nil becomes JSON null. @@ -76,26 +76,26 @@ ;; Bind clojure.contrib.test-is/*load-tests* to false to omit these ;; tests from production code. -(deftest can-print-json-strings +(deftest- can-print-json-strings (is (= "\"Hello, World!\"" (json-str "Hello, World!"))) (is (= "\"\\\"Embedded\\\" Quotes\"" (json-str "\"Embedded\" Quotes")))) -(deftest can-print-json-null +(deftest- can-print-json-null (is (= "null" (json-str nil)))) -(deftest can-print-json-arrays +(deftest- can-print-json-arrays (is (= "[1,2,3]" (json-str [1 2 3]))) (is (= "[1,2,3]" (json-str (list 1 2 3)))) (is (= "[1,2,3]" (json-str (sorted-set 1 2 3)))) (is (= "[1,2,3]" (json-str (seq [1 2 3]))))) -(deftest can-print-empty-arrays +(deftest- can-print-empty-arrays (is (= "[]" (json-str []))) (is (= "[]" (json-str (list)))) (is (= "[]" (json-str #{})))) -(deftest can-print-json-objects +(deftest- can-print-json-objects (is (= "{\"a\":1,\"b\":2}" (json-str (sorted-map :a 1 :b 2))))) -(deftest can-print-empty-objects +(deftest- can-print-empty-objects (is (= "{}" (json-str {})))) |