lunit-assert-2 instead of lunit-assert.
(test-riece-resolve-addons-2): Ditto.
- * test/lunit.el: Don't treat a failure as an Emacs error signal;
- count assertions in test-case methods.
+ * test/lunit.el: Count assertions in test-case methods.
(lunit-test-result): Add assert-count slot.
(lunit-make-test-result): Reset assert-count to 0.
- (lunit-test-result-run): Count assertions; collect failures at a
- time after test-case execution.
+ (lunit-test-result-run): Count assertions.
(lunit-test-result-failure): Abolished.
- (lunit-test-case): Add failures and assert-count slots; define
- internal accesssors for them.
+ (lunit-test-case): Add assert-count slot; define internal
+ accesssors for them.
(lunit-make-test-case): Reset assert-count to 0.
- (lunit-test-case-run): Don't handle failure signals.
- (lunit-assert): Define as a nop macro.
- (lunit-assert-2): New macro. Use this instead of lunit-assert.
+ (lunit-assert-2): New macro.
(lunit): Display assertion count.
2004-11-25 Daiki Ueno <ueno@unixuser.org>
(put 'lunit-error 'error-message "test error")
(put 'lunit-error 'error-conditions '(lunit-error error))
+(put 'lunit-failure 'error-message "test failure")
+(put 'lunit-failure 'error-conditions '(lunit-failure lunit-error error))
+
(eval-and-compile
(luna-define-class lunit-test-result ()
(errors
(luna-define-generic lunit-test-result-notify (result message &rest args)
"Report the current state of execution.")
-(luna-define-generic lunit-test-result-error (result case error)
- "Add error to the list of errors.")
-
(luna-define-generic lunit-test-result-add-listener (result listener)
"Add listener to the list of listeners.")
(lunit-test-result-notify result 'lunit-test-listener-start case)
(condition-case error
(lunit-test-case-run case)
+ (lunit-failure
+ (lunit-test-result-set-failures-internal
+ result
+ (nconc (lunit-test-result-failures-internal result)
+ (list (cons case (cdr failure)))))
+ (lunit-test-result-notify
+ result 'lunit-test-listener-failure case failure))
(lunit-error
- (lunit-test-result-error result case (cdr error))))
+ (lunit-test-result-set-errors-internal
+ result
+ (nconc (lunit-test-result-errors-internal result)
+ (list (cons case (cdr error)))))
+ (lunit-test-result-notify
+ result 'lunit-test-listener-error case error)))
(lunit-test-result-set-assert-count-internal
result
(+ (lunit-test-result-assert-count-internal result)
(lunit-test-case-assert-count-internal case)))
- (let ((failures
- (lunit-test-case-failures-internal case)))
- (when failures
- (lunit-test-result-set-failures-internal
- result
- (nconc (lunit-test-result-failures-internal result)
- (mapcar (lambda (failure)
- (prog1 (cons case failure)
- (lunit-test-result-notify
- result 'lunit-test-listener-failure
- case failure)))
- failures)))))
(lunit-test-result-notify result 'lunit-test-listener-end case))
-(luna-define-method lunit-test-result-error ((result lunit-test-result)
- case error)
- (let ((errors
- (lunit-test-result-errors-internal result)))
- (setq errors (nconc errors (list (cons case error))))
- (lunit-test-result-set-errors-internal result errors))
- (lunit-test-result-notify result 'lunit-test-listener-error case error))
-
(luna-define-method lunit-test-result-add-listener ((result lunit-test-result)
listener)
(let ((listeners
(eval-and-compile
(luna-define-class lunit-test-case (lunit-test)
- (failures
- assert-count))
+ (assert-count))
(luna-define-internal-accessors 'lunit-test-case))
(error "Method \"%S\" not found" name))
(condition-case error
(funcall (car functions) case)
+ (lunit-failure
+ (signal (car error)(cdr error)))
(error
(signal 'lunit-error error))))
(lunit-test-case-teardown case)))
(defmacro lunit-assert (condition-expr)
"Verify that CONDITION-EXPR returns non-nil; signal an error if not."
- (princ "`lunit-assert' is obsolete; use `lunit-assert-2' instead.\n"))
+ `(unless ,condition-expr
+ (signal 'lunit-failure (list ',condition-expr))))
(defmacro lunit-assert-2 (case condition-expr)
"In regard to CASE, verify that CONDITION-EXPR returns non-nil;
case
(1+ (lunit-test-case-assert-count-internal case)))
(unless ,condition-expr
- (lunit-test-case-set-failures-internal
- case
- (cons ',condition-expr
- (lunit-test-case-failures-internal case))))))
+ (signal 'lunit-failure (list ',condition-expr)))))
(luna-define-class lunit-test-printer (lunit-test-listener))