Skip to content

Commit

Permalink
Use a form that throws in both clj & cljs
Browse files Browse the repository at this point in the history
Why would we use different forms if there are many forms
that throw on both platforms?
  • Loading branch information
nberger committed Sep 10, 2015
1 parent 6ea316c commit a9c6904
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 3 additions & 4 deletions test/com/gfredericks/test/chuck/exception_handling_test.cljc
Expand Up @@ -6,11 +6,10 @@
[com.gfredericks.test.chuck.clojure-test #?(:clj :refer :cljs :refer-macros) [checking]]))

(deftest this-test-should-crash-and-be-caught
(checking "you can divide four by numbers" 100 [i gen/pos-int]
(checking "subs on any string or nil" 100 [s (gen/one-of [gen/string (gen/return nil)])]
;; going for uncaught-error-not-in-assertion here
(let [n #?(:clj (/ 4 i)
:cljs (throw (js/Error. "Oops!")))]
(is n))))
(let [res (subs s 1 2)]
(is res))))

(defn capture-test-var [v]
(with-out-str (test-var v)))
Expand Down
5 changes: 2 additions & 3 deletions test/com/gfredericks/test/chuck/properties_test.cljc
Expand Up @@ -16,9 +16,8 @@
:cljs js/Error)
(:result
(tc/quick-check 100
(prop'/for-all [x gen/int]
#?(:clj (/ 4 0)
:cljs (throw (js/Error. "Oops")))))))))
(prop'/for-all [s (gen/one-of [gen/string (gen/return nil)])]
(subs s 1 2)))))))

(deftest reported-args-test
(let [p (prop'/for-all [x gen/nat]
Expand Down

0 comments on commit a9c6904

Please sign in to comment.