From: ueno Date: Fri, 26 Nov 2004 08:28:39 +0000 (+0000) Subject: * test/lunit.el: Undo the last change. X-Git-Tag: riece-1_0_6~19 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=8418f10a05b97da118a3276c114695a8bf99b494;p=elisp%2Friece.git * test/lunit.el: Undo the last change. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9f4b9aa..32bfc7c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -23,19 +23,15 @@ 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 diff --git a/lisp/test/lunit.el b/lisp/test/lunit.el index 12120a8..4d1108b 100644 --- a/lisp/test/lunit.el +++ b/lisp/test/lunit.el @@ -79,6 +79,9 @@ (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 @@ -94,9 +97,6 @@ (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.") @@ -115,34 +115,26 @@ (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 @@ -155,8 +147,7 @@ (eval-and-compile (luna-define-class lunit-test-case (lunit-test) - (failures - assert-count)) + (assert-count)) (luna-define-internal-accessors 'lunit-test-case)) @@ -195,6 +186,8 @@ NAME is name of the method to be tested." (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))) @@ -234,7 +227,8 @@ TESTS holds a number of instances of `lunit-test'." (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; @@ -244,10 +238,7 @@ signal an error if not." 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))