Last active
October 29, 2018 09:55
-
-
Save borkdude/a7c38295f19a0dd2a68a7da21d634661 to your computer and use it in GitHub Desktop.
instrument/unstrument in cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; run with: | |
;; clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:git/url "https://github.com/clojure/clojurescript" :sha "4fb83eff87cc456600a3fd21c111e99a41c61285"}}}' -m cljs.main -re node -i repro_test.cljs | |
(ns repro-test | |
(:require | |
[clojure.spec.alpha :as s] | |
[clojure.spec.test.alpha :as stest] | |
[clojure.test :as t :refer [deftest is testing]])) | |
(defn foo [n] | |
"ret") | |
(s/fdef foo | |
:args (s/cat :n number?) | |
:ret number?) | |
(deftest repro-test | |
(testing "unstrument in finally works" | |
(is (= "oops" | |
(try | |
(stest/instrument `foo) | |
(foo "string") | |
(catch js/Error e "oops") | |
(finally | |
(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 | |
)))) | |
(t/run-tests) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment