1.3.0 permalink Arrow_down_16x16
  • (is form)
  • (is form msg)
Generic assertion macro. 'form' is any predicate test.
'msg' is an optional message to attach to the assertion.

Example: (is (= 4 (+ 2 2)) "Two plus two should be 4")

Special forms:

(is (thrown? c body)) checks that an instance of c is thrown from
body, fails if not; then returns the thing thrown.

(is (thrown-with-msg? c re body)) checks that an instance of c is
thrown AND that the message on the exception matches (with
re-find) the regular expression re.

1 Example top

  • (use '[clojure.test :only [is]])
    
    user=> (is (true? true))
    true
    
    ;; false assertions print a message and evaluate to false
    
    user=> (is (true? false))
    FAIL in clojure.lang.PersistentList$EmptyList@1 (NO_SOURCE_FILE:1)
    expected: (true? false)
      actual: (not (true? false))
    false
    
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/test.clj:538 top

(defmacro is
  "Generic assertion macro.  'form' is any predicate test.
  'msg' is an optional message to attach to the assertion.
  
  Example: (is (= 4 (+ 2 2)) \"Two plus two should be 4\")

  Special forms:

  (is (thrown? c body)) checks that an instance of c is thrown from
  body, fails if not; then returns the thing thrown.

  (is (thrown-with-msg? c re body)) checks that an instance of c is
  thrown AND that the message on the exception matches (with
  re-find) the regular expression re."
  {:added "1.1"} 
  ([form] `(is ~form nil))
  ([form msg] `(try-expr ~msg ~form)))
Vars in clojure.test/is:
Used in 0 other vars

Comments top

No comments for is. Log in to add a comment.