Skip to content

Commit 416f322

Browse files
mfikesdnolen
authored and
dnolen
committed
CLJS-1687: Self-host: cljs.spec: inst-in-range? and int-in-range? need qualification
1 parent 0336696 commit 416f322

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/main/cljs/cljs/spec.cljc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ specified, return speced vars from all namespaces."
422422
`(let [st# (inst-ms ~start)
423423
et# (inst-ms ~end)
424424
mkdate# (fn [d#] (js/Date. d#))]
425-
(spec (and inst? #(inst-in-range? ~start ~end %))
425+
(spec (and inst? #(cljs.spec/inst-in-range? ~start ~end %))
426426
:gen (fn []
427427
(gen/fmap mkdate#
428428
(gen/large-integer* {:min st# :max et#}))))))
@@ -431,7 +431,7 @@ specified, return speced vars from all namespaces."
431431
"Returns a spec that validates longs in the range from start
432432
(inclusive) to end (exclusive)."
433433
[start end]
434-
`(spec (and c/int? #(int-in-range? ~start ~end %))
434+
`(spec (and c/int? #(cljs.spec/int-in-range? ~start ~end %))
435435
:gen #(gen/large-integer* {:min ~start :max (dec ~end)})))
436436

437437
(defmacro instrument

src/test/cljs/cljs/spec_test.cljs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@
4343
(is (= "good" (testmm {:type :good})))
4444
(is (thrown? js/Error (testmm "foo"))))
4545

46+
(deftest int-in-test
47+
(is (s/valid? (s/int-in 1 3) 2))
48+
(is (not (s/valid? (s/int-in 1 3) 0))))
49+
50+
(deftest inst-in-test
51+
(is (s/valid? (s/inst-in #inst "1999" #inst "2001") #inst "2000"))
52+
(is (not (s/valid? (s/inst-in #inst "1999" #inst "2001") #inst "1492"))))
53+
4654
(comment
4755

4856
(s/conform s2 [42 11 13 15 {:a 1 :b 2 :c 3} 1 2 3 42 43 44 11])

0 commit comments

Comments
 (0)