Skip to content

Commit 639e1ce

Browse files
committed
fix test
1 parent bc07b92 commit 639e1ce

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

test/sci/core_test.cljc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,34 +1654,38 @@
16541654
(is (str/includes? (str st) "1:31"))))
16551655

16561656
(deftest sci-error-multiple-catches-test
1657-
#?(:clj
1658-
(testing "^:sci/error works with multiple catch clauses - specific catch first"
1659-
(let [result (sci/eval-string
1660-
"(defn foo [] (/ 1 0))
1657+
(testing "^:sci/error works with multiple catch clauses - specific catch first"
1658+
(let [result (sci/eval-string
1659+
(-> "(defn foo [] (/ 1 0))
16611660
(defn bar []
16621661
(try (foo)
16631662
(catch ArithmeticException e
16641663
{:caught :arithmetic :msg (ex-message e)})
16651664
(catch ^:sci/error Exception e
16661665
{:caught :exception})))
16671666
(bar)"
1668-
{:classes {'ArithmeticException ArithmeticException}})]
1669-
(is (= :arithmetic (:caught result)))
1670-
(is (str/includes? (:msg result) "Divide by zero")))))
1667+
#?(:cljs (str/replace "ArithmeticException" "js/RangeError"))
1668+
#?(:cljs (str/replace "Exception" "js/Error"))
1669+
#?(:cljs (str/replace "(/ 1 0)" "(js/Array. -1)")))
1670+
{:classes #?(:clj {'ArithmeticException ArithmeticException}
1671+
:cljs {:allow :all 'js js/global})})]
1672+
(is (= :arithmetic (:caught result)))
1673+
(is (str/includes? (:msg result) #?(:clj "Divide by zero"
1674+
:cljs "Invalid array length")))))
16711675
(testing "^:sci/error Exception catch still gets location info with multiple catches"
16721676
(let [result (sci/eval-string
16731677
(-> "(require '[sci.core :as sci])
16741678
(defn foo [] (assoc :foo :bar))
16751679
(defn bar []
16761680
(try (foo)
1677-
(catch java.io.FileNotFoundException e
1681+
(catch ArithmeticException e
16781682
{:caught :not-found})
16791683
(catch ^:sci/error Exception e
16801684
{:caught :exception :st (sci/format-stacktrace (sci/stacktrace e))})))
16811685
(bar)"
1682-
#?(:cljs (str/replace "java.io.FileNotFoundException" "js/RangeError"))
1686+
#?(:cljs (str/replace "ArithmeticException" "js/RangeError"))
16831687
#?(:cljs (str/replace "Exception" "js/Error")))
1684-
{:classes #?(:clj {'java.io.FileNotFoundException java.io.FileNotFoundException}
1688+
{:classes #?(:clj {'ArithmeticException ArithmeticException}
16851689
:cljs {:allow :all 'js js/global})
16861690
:namespaces {'sci.core {'stacktrace sci/stacktrace
16871691
'format-stacktrace sci/format-stacktrace}}})]

test/sci/test_utils.cljc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,3 @@
4040
(comment
4141
(eval* "*in*" {'*in* 1}) ;;=> 1
4242
)
43-

0 commit comments

Comments
 (0)