This file is indexed.

/usr/share/common-lisp/source/xlunit/assert.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
;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
;;;; *************************************************************************
;;;; FILE IDENTIFICATION
;;;;
;;;; ID:       $Id$
;;;; Purpose:  Assert functions for XLUnit
;;;;
;;;; *************************************************************************

(in-package #:xlunit)


(define-condition assertion-failed (simple-condition)
  ((message :initform nil :initarg :message :accessor message))
  (: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-message (message &optional format-str &rest args)
  "Signal a test failure and exit the test."
  (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."
  (apply #'failure-message nil format-str args))

(defun assert-equal (v1 v2 &optional message)
  (unless (equal 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 equal: ~S ~S" v1 v2)))

(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
    (failure-message ,message "Assert true: ~S" ',v)))

(defmacro assert-false (v &optional message)
  `(when ,v
     (failure-message ,message "Assert false: ~S" ',v)))

(defmacro assert-condition (condition form &optional message)
  (let ((cond (gensym "COND-")))
    `(handler-case
         (progn
           ,form
           (values))
       (t (,cond)
         (when (and (typep ,cond 'serious-condition)
                    (not (typep ,cond ,condition)))
           (failure-message
            ,message
            "Assert condition ~A, but signaled condition ~A"
            ,condition ,cond)))
       (:no-error ()
         (failure-message ,message
                          "Assert condition ~A, but no condition signaled"
                          ,condition)))))

(defmacro assert-not-condition (condition form &optional message)
  (let ((cond (gensym "COND-")))
    `(handler-case
         (progn
           ,form
           (values))
       (serious-condition (,cond)
         (unless (typep ,cond ,condition)
           (failure-message ,message "Assert not condition ~A"
                            ,condition))))))