/usr/share/common-lisp/source/xlunit/tests.lisp is in cl-xlunit 0.6.3-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
;;;; *************************************************************************
;;;; FILE IDENTIFICATION
;;;;
;;;; Id: $Id$
;;;; Purpose: Self Test suite for XLUnit
;;;;
;;;; *************************************************************************
(in-package #:cl-user)
(defpackage #:xlunit-tests
(:use #:cl #:xlunit)
(:export #:do-tests))
(in-package #:xlunit-tests)
(define-condition test-condition (error)
())
;; Helper test fixture
(defclass was-run (test-case)
((log :accessor ws-log)))
(defmethod set-up ((self was-run))
(setf (ws-log self) "setup "))
(defmethod tear-down ((self was-run))
(setf (ws-log self)
(concatenate 'string (ws-log self) "teardown ")))
(def-test-method test-method ((self was-run) :run nil)
(setf (ws-log self)
(concatenate 'string (ws-log self) "test-method ")))
(def-test-method test-broken-method ((self was-run) :run nil)
(assert-equal pi (/ 22 7)))
(def-test-method test-not-eql ((self was-run) :run nil)
(assert-not-eql (cons t t) (cons t t)))
(def-test-method test-eql ((self was-run) :run nil)
(let ((obj (cons t t)))
(assert-eql obj obj)))
(def-test-method test-error-method ((self was-run) :run nil)
(error "Err"))
(def-test-method test-condition-without-cond ((self was-run) :run nil)
(assert-condition 'error (list 'no-error)))
#+ignore
(def-test-method test-not-condition-with-cond ((self was-run) :run nil)
(assert-not-condition 'test-condition
(signal 'test-condition)))
;;; Second helper test case
(defclass test-two-cases (test-case)
())
(def-test-method test-1 ((self test-two-cases) :run nil)
(assert-true t))
(def-test-method test-2 ((self test-two-cases) :run nil)
(assert-false nil))
;;; Main test fixture
(defclass test-case-test (test-case)
())
(def-test-method test-template-method ((self test-case-test) :run nil)
(let ((test (named-test 'test-method (get-suite was-run))))
(run test)
(assert-equal (ws-log test) "setup test-method teardown ")))
(def-test-method test-results ((self test-case-test) :run nil)
(assert-equal "1 run, 0 erred, 0 failed"
(summary (run (named-test 'test-method
(get-suite was-run))))))
(def-test-method test-eql ((self test-case-test) :run nil)
(assert-equal "1 run, 0 erred, 0 failed"
(summary (run (named-test 'test-eql (get-suite was-run))))))
(def-test-method test-not-eql ((self test-case-test) :run nil)
(assert-equal "1 run, 0 erred, 0 failed"
(summary (run (named-test 'test-not-eql
(get-suite was-run))))))
(def-test-method test-fn ((self test-case-test) :run nil)
(let ((test (make-instance 'test-case :name 'test-fn
:method-body
(lambda ()
(declare (ignore test))
(assert-equal 10 10)))))
(assert-equal "1 run, 0 erred, 0 failed"
(summary (run test)))))
(def-test-method test-failed-result ((self test-case-test) :run nil)
(assert-equal "1 run, 0 erred, 1 failed"
(summary (run
(named-test 'test-broken-method
(get-suite was-run))))))
(def-test-method test-error-result ((self test-case-test) :run nil)
(assert-equal "1 run, 1 erred, 0 failed"
(summary (run
(named-test 'test-error-method
(get-suite was-run))))))
(def-test-method test-suite ((self test-case-test) :run nil)
(let ((suite (make-instance 'test-suite))
(result (make-test-results)))
(add-test suite (named-test 'test-method (get-suite was-run)))
(add-test suite (named-test 'test-broken-method (get-suite was-run)))
(run-on-test-results suite result)
(assert-equal "2 run, 0 erred, 1 failed" (summary result))))
(def-test-method test-dynamic-suite ((self test-case-test) :run nil)
(assert-equal "2 run, 0 erred, 0 failed"
(summary (run (get-suite test-two-cases)))))
(def-test-method test-condition ((self test-case-test) :run nil)
(assert-condition
'test-condition
(error 'test-condition)))
(def-test-method test-condition-without-cond ((self test-case-test)
:run nil)
(assert-equal "1 run, 0 erred, 1 failed"
(summary (run
(named-test 'test-condition-without-cond
(get-suite was-run))))))
#+ignore
(def-test-method test-not-condition ((self test-case-test) :run nil)
(assert-not-condition
'test-condition
(progn)))
#+ignore
(def-test-method test-not-condition-with-cond ((self test-case-test)
:run nil)
(assert-equal "1 run, 0 erred, 1 failed"
(summary (run
(named-test 'test-not-condition-with-cond
(get-suite was-run))))))
#+ignore
(textui-test-run (get-suite test-case-test))
(defun do-tests ()
(or (was-successful (run (get-suite test-case-test)))
(error "Failed tests")))
|