Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to resolve symbol: thrown?

What is the proper way to do the following in clojure?

(ns todo.test.models.task
  (:use [clojure.test]))

(deftest main-test
  (is (thrown? Exception (throw Exception "stuff")))
  (is (not (thrown? Exception (+ 2 3))))
)

First testcase runs fine but the whole snippet returns "Unable to resolve symbol: thrown?"

like image 383
Juliusz Avatar asked Jun 27 '12 17:06

Juliusz


1 Answers

is is a macro that looks for the symbol thrown? in its body and build tests. thrown? is not actually a function you can call. The default behaviour of is fails the test if an exception is thrown that was not beeing looked for, so you can just remove the (not (thrown? from the above example and get the result you are looking for.

like image 98
Arthur Ulfeldt Avatar answered Sep 28 '22 04:09

Arthur Ulfeldt