From 53c699a7ed91f78c0e31b7bbd7deda671ca9df05 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Mon, 4 Aug 2003 12:28:46 +0000 Subject: [PATCH] r5451: *** empty log message *** --- assert.lisp | 26 +++++++++++++++----------- result.lisp | 4 ++-- tests.lisp | 10 +++++++--- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/assert.lisp b/assert.lisp index 269e797..460bb4d 100644 --- a/assert.lisp +++ b/assert.lisp @@ -2,7 +2,7 @@ ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; -;;;; ID: $Id: assert.lisp,v 1.2 2003/08/04 12:16:13 kevin Exp $ +;;;; ID: $Id: assert.lisp,v 1.3 2003/08/04 12:28:46 kevin Exp $ ;;;; Purpose: Assert functions for XLUnit ;;;; ;;;; ************************************************************************* @@ -17,25 +17,29 @@ (:documentation "Base class for all test failures.")) -(defun failure (format-str &rest args) +(defun failure-msg (msg &optional format-str &rest args) "Signal a test failure and exit the test." (signal 'test-failure-condition + :msg msg :format-control format-str :format-arguments args)) +(defun failure (format-str &rest args) + "Signal a test failure and exit the test." + (apply #'failure-msg nil format-str args)) + (defmacro test-assert (test &optional msg) `(unless ,test - (failure "Test assertion: ~s" ',test))) + (failure-msg ,msg "Test assertion: ~s" ',test))) (defun assert-equal (v1 v2 &optional msg) (unless (equal v1 v2) - (failure "Test equal: ~s ~s" v1 v2))) - -(defun assert-true (v &optional msg) - (unless v - (failure "Test true: ~s [~A]" v (if msg msg "")))) + (failure-msg msg "Test equal: ~S ~S" v1 v2))) -(defun assert-false (v &optional msg) - (when v - (failure "Test false ~A" (if msg msg "")))) +(defmacro assert-true (v &optional msg) + `(unless ,v + (failure-msg msg "Not true: ~S" ',v))) +(defmacro assert-false (v &optional msg) + `(when ,v + (failure-msg msg "Not false: ~S" ',v))) diff --git a/result.lisp b/result.lisp index 57ceba3..e601ec6 100644 --- a/result.lisp +++ b/result.lisp @@ -2,7 +2,7 @@ ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; -;;;; ID: $Id: result.lisp,v 1.2 2003/08/04 12:16:13 kevin Exp $ +;;;; ID: $Id: result.lisp,v 1.3 2003/08/04 12:28:46 kevin Exp $ ;;;; Purpose: Result functions for XLUnit ;;;; ;;;; ************************************************************************* @@ -24,7 +24,7 @@ ((failed-test :initarg :failed-test :reader failed-test) (thrown-condition :initarg :thrown-condition :reader thrown-condition)) - (:documention "Stored failures/errors in test-result slots")) + (:documentation "Stored failures/errors in test-result slots")) (defun make-test-failure (test condition) (make-instance 'test-failure :failed-test test diff --git a/tests.lisp b/tests.lisp index 555b6ac..892a033 100644 --- a/tests.lisp +++ b/tests.lisp @@ -2,18 +2,20 @@ ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; -;;;; Id: $Id: tests.lisp,v 1.5 2003/08/04 12:16:13 kevin Exp $ +;;;; Id: $Id: tests.lisp,v 1.6 2003/08/04 12:28:46 kevin Exp $ ;;;; Purpose: Test suite for XLUnit ;;;; ;;;; ************************************************************************* +(in-package #:cl-user) (defpackage #:xlunit-tests - (:use #:cl #:xlunit)) - + (:use #:cl #:xlunit) + (:export #:do-tests)) (in-package #:xlunit-tests) ;; Helper test fixture + (defclass was-run (test-fixture) ((log :accessor ws-log))) @@ -32,6 +34,7 @@ (defmethod test-error-method ((self was-run)) (error "Err")) + ;;; Main test fixture (defclass test-case-test (test-fixture) @@ -79,6 +82,7 @@ (text-testrunner (make-test-suite 'test-case-test) :handle-errors nil) + (defun do-tests () (or (was-successful (run-test (make-test-suite 'test-case-test))) -- 2.34.1