TLDR: What is the correct way to test for a thrown ex-info using clojure.test?
I have the following code which I’d like to write a test for using clojure.test
(fn [type functions]
(cond (= wrt :sigma)
:epsilon
(= wrt :epsilon)
:empty-set
:else
(throw (ex-info (format "cannot compute derivative of :sigma wrt %s because they intersecting" wrt)
{:type :derivative-error
:derivative {:expr expr
:type type
:wrt wrt
:functions functions}
:cause :intersecting-types
}))))
I see in the clojure.test documentation that I can use the idiom (is (thrown? ...))
. But it is not clear how to get the exception object using thrown?
and test for the keys of the hashmap which I’ve designated at the call to ex-info
.