Use lowercase-only characters for package names to fix compilation on Allegro
[fiveam.git] / src / classes.lisp
1 ;; -*- lisp -*-
2
3 (in-package :it.bese.fiveam)
4
5 (defclass testable-object ()
6   ((name :initarg :name :accessor name
7          :documentation "A symbol naming this test object.")
8    (description :initarg :description :accessor description :initform nil
9                 :documentation "The textual description of this test object.")
10    (depends-on :initarg :depends-on :accessor depends-on :initform nil
11                :documentation "The list of AND, OR, NOT forms specifying when to run this test.")
12    (status :initarg :status :accessor status :initform :unknown
13            :documentation "A symbol specifying the current status
14            of this test. Either: T - this test (and all its
15            dependencies, have passed. NIL - this test
16            failed (either it failed or its dependecies weren't
17            met. :circular this test has a circular dependency
18            and was skipped. Or :depends-not-satisfied or :resolving")
19    (profiling-info :accessor profiling-info
20                    :initform nil
21                    :documentation "An object representing how
22                    much time and memory where used by the
23                    test.")
24    (collect-profiling-info :accessor collect-profiling-info
25                            :initarg :collect-profiling-info
26                            :initform nil
27                            :documentation "When T profiling
28                            information will be collected when the
29                            test is run.")))
30
31 (defmethod print-object ((test testable-object) stream)
32   (print-unreadable-object (test stream :type t :identity t)
33     (format stream "~S" (name test))))
34
35 (defclass test-suite (testable-object)
36   ((tests :accessor tests :initform (make-hash-table :test 'eql)
37           :documentation "The hash table mapping names to test
38           objects in this suite. The values in this hash table
39           can be either test-cases or other test-suites."))
40   (:documentation "A test suite is a collection of tests or test suites.
41
42 Test suites serve to organize tests into groups so that the
43 developer can chose to run some tests and not just one or
44 all. Like tests test suites have a name and a description.
45
46 Test suites, like tests, can be part of other test suites, this
47 allows the developer to create a hierarchy of tests where sub
48 trees can be singularly run.
49
50 Running a test suite has the effect of running every test (or
51 suite) in the suite."))
52
53 (defclass test-case (testable-object)
54   ((test-lambda :initarg :test-lambda :accessor test-lambda
55                 :documentation "The function to run.")
56    (runtime-package :initarg :runtime-package :accessor runtime-package
57                     :documentation "By default it stores *package* from the time this test was defined (macroexpanded)."))
58   (:documentation "A test case is a single, named, collection of
59 checks.
60
61 A test case is the smallest organizational element which can be
62 run individually. Every test case has a name, which is a symbol,
63 a description and a test lambda. The test lambda is a regular
64 funcall'able function which should use the various checking
65 macros to collect results.
66
67 Every test case is part of a suite, when a suite is not
68 explicitly specified (either via the :SUITE parameter to the TEST
69 macro or the global variable *SUITE*) the test is inserted into
70 the global suite named NIL.
71
72 Sometimes we want to run a certain test only if another test has
73 passed. FiveAM allows us to specify the ways in which one test is
74 dependent on another.
75
76 - AND Run this test only if all the named tests passed.
77
78 - OR Run this test if at least one of the named tests passed.
79
80 - NOT Run this test only if another test has failed.
81
82 FiveAM considers a test to have passed if all the checks executed
83 were successful, otherwise we consider the test a failure.
84
85 When a test is not run due to it's dependencies having failed a
86 test-skipped result is added to the results."))
87
88 (defclass explainer ()
89   ())
90
91 (defclass text-explainer (explainer)
92   ())
93
94 (defclass simple-text-explainer (text-explainer)
95   ())
96
97 (defclass detailed-text-explainer (text-explainer)
98   ())
99
100 ;; Copyright (c) 2002-2003, Edward Marco Baringer
101 ;; All rights reserved.
102 ;;
103 ;; Redistribution and use in source and binary forms, with or without
104 ;; modification, are permitted provided that the following conditions are
105 ;; met:
106 ;;
107 ;;  - Redistributions of source code must retain the above copyright
108 ;;    notice, this list of conditions and the following disclaimer.
109 ;;
110 ;;  - Redistributions in binary form must reproduce the above copyright
111 ;;    notice, this list of conditions and the following disclaimer in the
112 ;;    documentation and/or other materials provided with the distribution.
113 ;;
114 ;;  - Neither the name of Edward Marco Baringer, nor BESE, nor the names
115 ;;    of its contributors may be used to endorse or promote products
116 ;;    derived from this software without specific prior written permission.
117 ;;
118 ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
119 ;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
120 ;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
121 ;; A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
122 ;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
123 ;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
124 ;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
125 ;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
126 ;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
127 ;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
128 ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE