I'm trying to make a test with thrown?
as described here, but I get the error below.
7 | (deftest exception-test
8 | (is (thrown? ArithmeticException (/ 1 0)))
----------------------^---------------------------------------------------------
Use of undeclared Var demo.app-test/ArithmeticException
--------------------------------------------------------------------------------
9 | )
I guess that I have to import it somehow, but haven't been able to figure it out. The namespace looks like this:
(ns demo.app-test
(:require [cljs.test :refer (deftest is)]))
I'm using shadow-cljs.
Javascript and so ClojureScript has no ArithmethicException
- this test there
most likely is taken from a Java/Clojure example. Dividing by zero in
JavaScript gives you "infinity" (no exception thrown).
There is a clear difference between Clojure and ClojureScript what they can do
and use. There are ways to use the same source code (e.g. cljc
) for both
platforms, but you have to deal with specifics to the platform yourself (there
are reader macros in cljc to help with that).
Note: you have access to the ArithmethicException in CLJS if you are writing macros, which again are just Clojure running at compile time, but that is just a nuance to the "will never work" answer.