projects
/
xlunit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r5464: *** empty log message ***
[xlunit.git]
/
assert.lisp
diff --git
a/assert.lisp
b/assert.lisp
index 460bb4d07a92cc1246a0a9913a2ff92ffb9f21e9..20d12765abd9740a8d79725b036b8becc9a60006 100644
(file)
--- a/
assert.lisp
+++ b/
assert.lisp
@@
-2,7
+2,7
@@
;;;; *************************************************************************
;;;; FILE IDENTIFICATION
;;;;
;;;; *************************************************************************
;;;; FILE IDENTIFICATION
;;;;
-;;;; ID: $Id: assert.lisp,v 1.
3 2003/08/04 12:28:46
kevin Exp $
+;;;; ID: $Id: assert.lisp,v 1.
7 2003/08/06 14:15:32
kevin Exp $
;;;; Purpose: Assert functions for XLUnit
;;;;
;;;; *************************************************************************
;;;; Purpose: Assert functions for XLUnit
;;;;
;;;; *************************************************************************
@@
-10,36
+10,46
@@
(in-package #:xlunit)
(in-package #:xlunit)
-;;; Assertions
-
-(define-condition test-failure-condition (simple-condition)
- ((msg :initform nil :initarg :msg :accessor msg))
+(define-condition assertion-failed (simple-condition)
+ ((message :initform nil :initarg :message :accessor message))
(:documentation "Base class for all test failures."))
(:documentation "Base class for all test failures."))
+(defmethod print-object ((obj assertion-failed) stream)
+ (print-unreadable-object (obj stream :type t :identity nil)
+ (apply #'format stream (simple-condition-format-control obj)
+ (simple-condition-format-arguments obj))))
-(defun failure-m
sg (msg
&optional format-str &rest args)
+(defun failure-m
essage (message
&optional format-str &rest args)
"Signal a test failure and exit the test."
"Signal a test failure and exit the test."
- (signal 'test-failure-condition
- :msg msg
- :format-control format-str
+ (signal 'assertion-failed :message message :format-control format-str
:format-arguments args))
(defun failure (format-str &rest args)
"Signal a test failure and exit the test."
: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-msg ,msg "Test assertion: ~s" ',test)))
+ (apply #'failure-message nil format-str args))
-(defun assert-equal (v1 v2 &optional m
sg
)
+(defun assert-equal (v1 v2 &optional m
essage
)
(unless (equal v1 v2)
(unless (equal v1 v2)
- (failure-msg msg "Test equal: ~S ~S" v1 v2)))
+ (failure-message message "Assert equal: ~S ~S" v1 v2)))
+
+(defun assert-eql (v1 v2 &optional message)
+ (unless (eql v1 v2)
+ (failure-message message "Assert eql: ~S ~S" v1 v2)))
-(defmacro assert-true (v &optional msg)
+(defun assert-not-eql (v1 v2 &optional message)
+ (when (eql v1 v2)
+ (failure-message message "Assert not eql: ~S ~S" v1 v2)))
+
+(defmacro assert-true (v &optional message)
`(unless ,v
`(unless ,v
- (failure-m
sg msg "No
t true: ~S" ',v)))
+ (failure-m
essage ,message "Asser
t true: ~S" ',v)))
-(defmacro assert-false (v &optional m
sg
)
+(defmacro assert-false (v &optional m
essage
)
`(when ,v
`(when ,v
- (failure-msg msg "Not false: ~S" ',v)))
+ (failure-message ,message "Assert false: ~S" ',v)))
+
+(defmacro assert-condition (condition v &optional message)
+ )
+
+(defmacro assert-not-condition (condition v &optional message)
+ )