Skip to content

Commit

Permalink
CLJS-2953: stest/with-instrument-disabled prints warning of private use
Browse files Browse the repository at this point in the history
  • Loading branch information
mfikes committed Nov 1, 2018
1 parent 6b9a37a commit e78d4fc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/cljs/cljs/spec/test/alpha.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ returns the set of all symbols naming vars in those nses."
(defmacro with-instrument-disabled
"Disables instrument's checking of calls, within a scope."
[& body]
`(binding [*instrument-enabled* nil]
~@body))
`(let [orig# @#'*instrument-enabled*]
(set! *instrument-enabled* nil)
(try
~@body
(finally
(set! *instrument-enabled* orig#)))))

(defmacro instrument-1
[[quote s] opts]
Expand Down
12 changes: 12 additions & 0 deletions src/test/cljs/cljs/spec/test_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,15 @@
(stest/enumerate-namespace 'cljs.spec.test.test-ns1)))
(is (= '#{cljs.spec.test.test-ns2/z}
(stest/enumerate-namespace 'cljs.spec.test.test-ns2))))

(defn fn-2953 [x] ::ret-val)

(s/fdef fn-2953 :args (s/cat :x int?))

(deftest test-cljs-2953
(stest/instrument `fn-2953)
(is @#'stest/*instrument-enabled*)
(is (= ::ret-val (stest/with-instrument-disabled
(is (nil? @#'stest/*instrument-enabled*))
(fn-2953 "abc"))))
(is @#'stest/*instrument-enabled*))

0 comments on commit e78d4fc

Please sign in to comment.