defconstant.lsp 1.61 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Thu Oct 10 23:05:39 2002
;;;; Contains: Tests of DEFCONSTANT

(in-package :cl-test)

(defconstant test-constant-1  17)

(deftest defconstant.1
  (symbol-value 'test-constant-1)
  17)

(deftest defconstant.2
15 16
  (notnot-mv (constantp 'test-constant-1))
  t)
17 18 19 20 21

(deftest defconstant.3
  (documentation 'test-constant-1 'variable)
  nil)

pfdietz's avatar
pfdietz committed
22 23
(defconstant test-constant-2 'a
  "This is the documentation.")
24 25 26 27 28 29 30 31 32

(deftest defconstant.4
  (documentation 'test-constant-2 'variable)
  "This is the documentation.")

(deftest defconstant.5
  (defconstant test-constant-3 0)
  test-constant-3)

33
;;; (deftest defconstant.error.1
34 35
;;;   (signals-error (defconstant)  program-error)
;;;   t)
sds's avatar
sds committed
36
;;;
37
;;; (deftest defconstant.error.2
38 39
;;;   (signals-error (defconstant +ignorable-constant-name+) program-error)
;;;   t)
sds's avatar
sds committed
40
;;;
41
;;; (deftest defconstant.error.3
42
;;;   (signals-error (defconstant +ignorable-constant-name2+ nil
sds's avatar
sds committed
43 44
;;;                 "This is a docstring"
;;;                 "This is an unnecessary extra argument.")
45 46
;;;                  program-error)
;;;  t)
47 48

(deftest defconstant.error.1
49
  (signals-error (funcall (macro-function 'defconstant))
sds's avatar
sds committed
50
                 program-error)
51
  t)
52 53

(deftest defconstant.error.2
54
  (signals-error (funcall (macro-function 'defconstant)
sds's avatar
sds committed
55 56
                           '(defconstant +nonexistent-constant+ 0))
                 program-error)
57
  t)
58 59

(deftest defconstant.error.3
60
  (signals-error (funcall (macro-function 'defconstant)
sds's avatar
sds committed
61 62 63
                           '(defconstant +nonexistent-constant+ 0)
                           nil nil)
                 program-error)
64
  t)