我有一个函数定义为:
(defn strict-get
[m key]
{:pre [(is (contains? m key))]}
(get m key))
然后我对其进行了测试:
(is (thrown? java.lang.AssertionError (strict-get {} :abc)))
但是,此测试失败:
;; FAIL in () (myfile.clj:189)
;; throws exception when key is not present
;; expected: (contains? m key)
;; actual: (not (contains? {} :abc))
需要什么来检查断言是否会引发错误?