defparameter.lsp 2.26 KB
Newer Older
1 2 3 4 5
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Thu Oct 10 23:13:22 2002
;;;; Contains: Tests of DEFPARAMETER

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

(defparameter *defparameter-test-var-1* 100)

(deftest defparameter.1
  *defparameter-test-var-1*
  100)

(deftest defparameter.2
  (documentation '*defparameter-test-var-1* 'variable)
  nil)

;;; Show that it's declared special.
(deftest defparameter.3
  (flet ((%f () *defparameter-test-var-1*))
    (let ((*defparameter-test-var-1* 29))
      (%f)))
  29)

(deftest defparameter.4
  (values
   (makunbound '*defparameter-test-var-2*)
   (defparameter *defparameter-test-var-2* 200 "Whatever.")
   (documentation '*defparameter-test-var-2* 'variable)
   *defparameter-test-var-2*)
  *defparameter-test-var-2*
  *defparameter-test-var-2*
  "Whatever."
  200)

(deftest defparameter.5
  (values
   (makunbound '*defparameter-test-var-2*)
   (defparameter *defparameter-test-var-2* 200 "Whatever.")
   (documentation '*defparameter-test-var-2* 'variable)
   *defparameter-test-var-2*
   (defparameter *defparameter-test-var-2* 300 "And ever.")
   (documentation '*defparameter-test-var-2* 'variable)
   *defparameter-test-var-2*
   )
  *defparameter-test-var-2*
  *defparameter-test-var-2*
  "Whatever."
  200
  *defparameter-test-var-2*
  "And ever."
  300)

54
;;; (deftest defparameter.error.1
55 56
;;;   (signals-error (defparameter)  program-error)
;;;   t)
sds's avatar
sds committed
57
;;;
58
;;; (deftest defparameter.error.2
59 60 61
;;;   (signals-error (defparameter *ignored-defparameter-name*)
;;;                  program-error)
;;;   t)
sds's avatar
sds committed
62
;;;
63
;;; (deftest defparameter.error.3
64
;;;   (signals-error (defparameter *ignored-defparameter-name* nil
sds's avatar
sds committed
65 66
;;;                 "documentation"
;;;                 "illegal extra argument")
67 68
;;;                  program-error)
;;;   t)
69 70

(deftest defparameter.error.1
71
  (signals-error (funcall (macro-function 'defparameter))
sds's avatar
sds committed
72
                 program-error)
73
  t)
74 75

(deftest defparameter.error.2
76
  (signals-error (funcall (macro-function 'defparameter)
sds's avatar
sds committed
77 78
                           '(defparameter *nonexistent-variable* nil))
                 program-error)
79
  t)
80 81

(deftest defparameter.error.3
82
  (signals-error (funcall (macro-function 'defparameter)
sds's avatar
sds committed
83 84 85
                           '(defparameter *nonexistent-variable* nil)
                           nil nil)
                 program-error)
86
  t)