Commit ad8f9af5 authored by pfdietz's avatar pfdietz
Browse files

Added tests for DEFCONSTANT, DEFPARAMETER, DEFVAR, and DESTRUCTURING-BIND. ...

Added tests for DEFCONSTANT, DEFPARAMETER, DEFVAR, and DESTRUCTURING-BIND.  The latter is failing badly.
parent 6cdcf7f2
;-*- 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
(not (constantp 'test-constant-1))
nil)
(deftest defconstant.3
(documentation 'test-constant-1 'variable)
nil)
(defconstant test-constant-2 'a "This is the documentation.")
(deftest defconstant.4
(documentation 'test-constant-2 'variable)
"This is the documentation.")
(deftest defconstant.5
(defconstant test-constant-3 0)
test-constant-3)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Thu Oct 10 23:13:22 2002
;;;; Contains: Tests of DEFPARAMETER
(in-package :cl-test)
(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)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Thu Oct 10 23:21:50 2002
;;;; Contains: Tests for DEFVAR
(in-package :cl-test)
(defvar *defvar-test-var-1* 100)
(deftest defvar.1
*defvar-test-var-1*
100)
(deftest defvar.2
(documentation '*defvar-test-var-1* 'variable)
nil)
;;; Show that it's declared special.
(deftest defvar.3
(flet ((%f () *defvar-test-var-1*))
(let ((*defvar-test-var-1* 29))
(%f)))
29)
(deftest defvar.4
(values
(makunbound '*defvar-test-var-2*)
(defvar *defvar-test-var-2* 200 "Whatever.")
(documentation '*defvar-test-var-2* 'variable)
*defvar-test-var-2*)
*defvar-test-var-2*
*defvar-test-var-2*
"Whatever."
200)
(deftest defvar.5
(let ((x 0))
(values
(makunbound '*defvar-test-var-2*)
(defvar *defvar-test-var-2* 200 "Whatever.")
(documentation '*defvar-test-var-2* 'variable)
*defvar-test-var-2*
(defvar *defvar-test-var-2* (incf x) "And ever.")
(documentation '*defvar-test-var-2* 'variable)
*defvar-test-var-2*
x
))
*defvar-test-var-2*
*defvar-test-var-2*
"Whatever."
200
*defvar-test-var-2*
"And ever."
200
0)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Thu Oct 10 23:25:50 2002
;;;; Contains: Tests for DESTRUCTURING-BIND
(in-package :cl-test)
;;; See the page for this in section 5.3
;;; Also, see destructuring lambda lists in section 3.4.5
(deftest destructuring-bind.1
(destructuring-bind (x y z) '(a b c) (values x y z))
a b c)
(deftest destructuring-bind.2
(destructuring-bind (x y &rest z) '(a b c d) (values x y z))
a b (c d))
(deftest destructuring-bind.3
(destructuring-bind (x y &optional z) '(a b c) (values x y z))
a b c)
(deftest destructuring-bind.4
(destructuring-bind (x y &optional z) '(a b) (values x y z))
a b nil)
(deftest destructuring-bind.5
(destructuring-bind (x y &optional (z 'w)) '(a b) (values x y z))
a b w)
(deftest destructuring-bind.6
(destructuring-bind (x y &optional (z 'w z-p)) '(a b) (values x y z z-p))
a b w nil)
(deftest destructuring-bind.7
(destructuring-bind (x y &optional (z 'w z-p)) '(a b c) (values x y z z-p))
a b c t)
(deftest destructuring-bind.8
(destructuring-bind (x y &optional z w) '(a b c) (values x y z w))
a b c nil)
(deftest destructuring-bind.9
(destructuring-bind ((x y)) '((a b)) (values x y))
a b)
(deftest destructuring-bind.10
(destructuring-bind (&whole w (x y)) '((a b)) (values x y w))
a b ((a b)))
(deftest destructuring-bind.11
(destructuring-bind ((x . y) . w) '((a b) c) (values x y w))
a (b) (c))
(deftest destructuring-bind.12
(destructuring-bind (x y &body z) '(a b c d) (values x y z))
a b (c d))
(deftest destructuring-bind.13
(destructuring-bind (&whole x y z) '(a b) (values x y z))
(a b) a b)
(deftest destructuring-bind.14
(destructuring-bind (w (&whole x y z)) '(1 (a b)) (values w x y z))
1 (a b) a b)
(deftest destructuring-bind.15
(destructuring-bind (&key a b c) '(:a 1) (values a b c))
1 nil nil)
(deftest destructuring-bind.16
(destructuring-bind (&key a b c) '(:b 1) (values a b c))
nil 1 nil)
(deftest destructuring-bind.17
(destructuring-bind (&key a b c) '(:c 1) (values a b c))
nil nil 1)
(deftest destructuring-bind.18
(destructuring-bind ((&key a b c)) '((:c 1 :b 2)) (values a b c))
nil 2 1)
......@@ -12,6 +12,10 @@
(load "call-arguments-limit.lsp")
(load "constantly.lsp")
(load "complement.lsp")
(load "defconstant.lsp")
(load "defparameter.lsp")
(load "defvar.lsp")
(load "destructuring-bind.lsp")
(load "fboundp.lsp")
(load "flet.lsp")
(load "fmakunbound.lsp")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment