Good Morning!
βοΈ π β
π
morning
morning
Moin!
morning
mΓ₯ning
morning
This mornings little fun:
(s/def ::json-number
(s/with-gen
number?
#(sgen/one-of [(sgen/large-integer) (sgen/double* {:infinite? false :NaN? false})])))
(s/def ::json-scalar (s/or :boolean boolean?
:number ::json-number
:string string?
:nil nil?))
(s/def ::json-value (s/or :object ::json-object
:array ::json-array
:scalar ::json-scalar))
(s/def ::json-array (s/coll-of ::json-value))
(s/def ::json-object (s/map-of string? ::json-value
:gen-max 10))
(s/fdef json/write-str
:args (s/cat :json ::json-value)
:ret string?
:fn #(= (->> % :args :json (s/unform ::json-value))
(json/read-str (-> % :ret))))
(deftest roundtrip
(let [results (stest/check `json/write-str)]
(is (every? nil? (mapv :failure results)))))
functions with inverses are really nice for generative testing.