|
136 | 136 | lrange (s/int-in 7 42)
|
137 | 137 | drange (s/double-in :infinite? false :NaN? false :min 3.1 :max 3.2)
|
138 | 138 | irange (s/inst-in #inst "1939" #inst "1946")]
|
| 139 | + |
| 140 | + (when-not js/COMPILED |
| 141 | + ;; CLJS-2483: these won't work with both :advanced and :none optimization settings |
| 142 | + (are [spec x conformed ed] |
| 143 | + (let [co (s/conform spec x) |
| 144 | + e (::s/problems (s/explain-data spec x))] |
| 145 | + (when (not= conformed co) (println "conform fail\n\texpect=" conformed "\n\tactual=" co)) |
| 146 | + (when (not (every? true? (map submap? ed e))) |
| 147 | + (println "explain failures\n\texpect=" ed "\n\tactual failures=" e "\n\tsubmap?=" (map submap? ed e))) |
| 148 | + (and (= conformed co) (every? true? (map submap? ed e)))) |
| 149 | + keyword? nil ::s/invalid [{:pred `keyword? :val nil}] |
| 150 | + keyword? "abc" ::s/invalid [{:pred `keyword? :val "abc"}])) |
| 151 | + |
139 | 152 | (are [spec x conformed ed]
|
140 | 153 | (let [co (s/conform spec x)
|
141 | 154 | e (::s/problems (s/explain-data spec x))]
|
|
160 | 173 | ;; drange Double/NaN ::s/invalid {[] {:pred '(not (isNaN %)), :val Double/NaN}}
|
161 | 174 |
|
162 | 175 | keyword? :k :k nil
|
163 |
| - keyword? nil ::s/invalid [{:pred ::s/unknown :val nil}] |
164 |
| - keyword? "abc" ::s/invalid [{:pred ::s/unknown :val "abc"}] |
165 | 176 |
|
166 | 177 | a 6 6 nil
|
167 | 178 | a 3 ::s/invalid '[{:pred (cljs.core/fn [%] (cljs.core/> % 5)), :val 3}]
|
|
420 | 431 |
|
421 | 432 | (s/def ::cljs-2940-foo (s/cat :bar (s/nilable ::cljs-2940-foo)))
|
422 | 433 |
|
| 434 | +(deftest describing-evaled-specs |
| 435 | + (let [sp #{1 2}] |
| 436 | + (is (= (s/describe sp) (s/form sp) sp))) |
| 437 | + ;; won't work under advanced |
| 438 | + (when-not js/COMPILED |
| 439 | + (is (= (s/describe odd?) 'odd?)) |
| 440 | + (is (= (s/form odd?) 'cljs.core/odd?))) |
| 441 | + (is (= (s/describe #(odd? %)) ::s/unknown)) |
| 442 | + (is (= (s/form #(odd? %)) ::s/unknown))) |
| 443 | + |
423 | 444 | (comment
|
424 | 445 |
|
425 | 446 | (run-tests)
|
|
0 commit comments