Skip to content

Instantly share code, notes, and snippets.

Last active Oct 29, 2018
What would you like to do?
instrument/unstrument in cljs
;; run with:
;; clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:git/url "" :sha "4fb83eff87cc456600a3fd21c111e99a41c61285"}}}' -m cljs.main -re node -i repro_test.cljs
(ns repro-test
[clojure.spec.alpha :as s]
[clojure.spec.test.alpha :as stest]
[clojure.test :as t :refer [deftest is testing]]))
(defn foo [n]
(s/fdef foo
:args (s/cat :n number?)
:ret number?)
(deftest repro-test
(testing "unstrument in finally works"
(is (= "oops"
(stest/instrument `foo)
(foo "string")
(catch js/Error e "oops")
(stest/unstrument `foo))))))
(testing "should be unstrumented after try/catch/finally"
(let [ret (try (foo "string")
(catch js/Error e "not-ret"))]
(is (= "ret" ret)) ;; FAILS
(testing "if ret wasn't ret, then foo was still instrumented. unstrumenting..."
(is (seq (s/unstrument `foo))) ;; FAILS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment