r5449: *** empty log message ***
[xlunit.git] / result.lisp
diff --git a/result.lisp b/result.lisp
new file mode 100644 (file)
index 0000000..ba95e4a
--- /dev/null
@@ -0,0 +1,42 @@
+;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+;;;; *************************************************************************
+;;;; FILE IDENTIFICATION
+;;;;
+;;;; Name:        result.lisp
+;;;; Purpose:     Result functions for XLUnit
+;;;; Authors:     Kevin Rosenberg
+;;;;
+;;;; $Id: result.lisp,v 1.1 2003/08/04 12:01:54 kevin Exp $
+;;;; *************************************************************************
+
+(in-package #:xlunit)
+
+
+(defclass test-result ()
+  ((test :initarg :test :reader result-test)
+   (count :initform 0 :accessor test-count)
+   (failures :initarg :failures :reader test-failures :initform nil)
+   (errors :initarg :errors :reader test-errors :initform nil))
+  (:documentation "The result of applying a test"))
+
+
+(defun make-test-result ()
+  (make-instance 'test-result))
+
+(defclass test-failure ()
+  ((failed-test :initarg :failed-test :reader failed-test)
+   (thrown-condition :initarg :thrown-condition :reader thrown-condition)))
+
+(defmethod is-failure ((failure test-failure))
+  (typep (thrown-condition failure) 'test-failure-condition))
+
+(defmethod print-object ((obj test-failure) stream)
+  (print-unreadable-object (obj stream :type t :identity nil)
+    (format stream "~A: " (failed-test obj))
+    (apply #'format stream 
+          (simple-condition-format-control (thrown-condition obj))
+          (simple-condition-format-arguments (thrown-condition obj)))))
+
+(defmethod was-successful ((result test-result))
+  (and (null (test-failures result))
+       (null (test-errors result))))