source: trunk/source/tests/ansi-tests/defvar.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 11 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 1.8 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Thu Oct 10 23:21:50 2002
4;;;; Contains: Tests for DEFVAR
5
6(in-package :cl-test)
7
8(defvar *defvar-test-var-1* 100)
9
10(deftest defvar.1
11  *defvar-test-var-1*
12  100)
13
14(deftest defvar.2
15  (documentation '*defvar-test-var-1* 'variable)
16  nil)
17
18;;; Show that it's declared special.
19(deftest defvar.3
20  (flet ((%f () *defvar-test-var-1*))
21    (let ((*defvar-test-var-1* 29))
22      (%f)))
23  29)
24
25(deftest defvar.4
26  (values
27   (makunbound '*defvar-test-var-2*)
28   (defvar *defvar-test-var-2* 200 "Whatever.")
29   (documentation '*defvar-test-var-2* 'variable)
30   *defvar-test-var-2*)
31  *defvar-test-var-2*
32  *defvar-test-var-2*
33  "Whatever."
34  200)
35
36(deftest defvar.5
37  (let ((x 0))
38    (values
39     (makunbound '*defvar-test-var-2*)
40     (defvar *defvar-test-var-2* 200 "Whatever.")
41     (documentation '*defvar-test-var-2* 'variable)
42     *defvar-test-var-2*
43     (defvar *defvar-test-var-2* (incf x) "And ever.")
44     (documentation '*defvar-test-var-2* 'variable)
45     *defvar-test-var-2*
46     x
47     ))
48  *defvar-test-var-2*
49  *defvar-test-var-2*
50  "Whatever."
51  200
52  *defvar-test-var-2*
53  "And ever."
54  200
55  0)
56
57;;; (deftest defvar.error.1
58;;;   (signals-error (defvar) program-error)
59;;;   t)
60;;;
61;;; (deftest defvar.error.2
62;;;   (signals-error (defvar *ignored-defvar-name* nil "documentation"
63;;;                 "illegal extra argument")
64;;;                  program-error)
65;;;   t)
66
67(deftest defvar.error.1
68  (signals-error (funcall (macro-function 'defvar))
69                 program-error)
70  t)
71
72(deftest defvar.error.2
73  (signals-error (funcall (macro-function 'defvar)
74                           '(defvar *nonexistent-variable* nil))
75                 program-error)
76  t)
77
78(deftest defvar.error.3
79  (signals-error (funcall (macro-function 'defvar)
80                           '(defvar *nonexistent-variable* nil)
81                           nil nil)
82                 program-error)
83  t)
Note: See TracBrowser for help on using the repository browser.