Commit 2184e87b authored by pfdietz's avatar pfdietz

Free declaration scope tests, and a test for updating :index in...

Free declaration scope tests, and a test for updating :index in with-input-from-string when the form exits abnormally
parent bed17857
......@@ -94,8 +94,19 @@
(when (< x y) (return :good))))
:good)
;;; Default return is NIL
(deftest do-all-symbols.10
(do-all-symbols (s) (declare (ignore s)))
nil)
;;; Free declaration scope tests
(deftest do-all-symbols.11
(let ((x :good))
(declare (special x))
(let ((x :bad))
(do-all-symbols (s x)
(declare (special x)))))
:good)
......@@ -111,6 +111,25 @@
(make-array 3 :element-type etype
:displaced-to name0 :displaced-index-offset 1)))
;;; Free declaration scope tests
(deftest do-external-symbols.16
(block done
(let ((x :bad))
(declare (special x))
(let ((x :good))
(do-external-symbols (s (return-from done x))
(declare (special x))))))
:good)
(deftest do-external-symbols.17
(let ((x :good))
(declare (special x))
(let ((x :bad))
(do-external-symbols (s "CL-TEST" x)
(declare (special x)))))
:good)
;;; Error tests
(def-macro-test do-external-symbols.error.1
......
......@@ -132,8 +132,24 @@
(make-array 1 :element-type etype
:displaced-to name0 :displaced-index-offset 1)))
;;; Free declaration scope tests
(deftest do-symbols.16
(block done
(let ((x :bad))
(declare (special x))
(let ((x :good))
(do-symbols (s (return-from done x))
(declare (special x))))))
:good)
(deftest do-symbols.17
(let ((x :good))
(declare (special x))
(let ((x :bad))
(do-symbols (s "CL-TEST" x)
(declare (special x)))))
:good)
(def-macro-test do-symbols.error.1
(do-symbols (x "CL")))
......@@ -199,3 +199,15 @@
(deftest handler-case.28
(handler-case (error "foo") (error () (declare (optimize speed))))
nil)
;;; Free declaration scope
(deftest handler-case.29
(let ((x :bad))
(declare (special x))
(let ((x :good))
(handler-case nil
(:no-error (z &aux (y x))
(declare (special x) (ignore z))
y))))
:good)
......@@ -298,10 +298,13 @@
(nil () :report (lambda (s) (format s "Anonymous restart")) 10))
(foo bar foo nil))
(deftest restart-case.36
(let ((x :bad))
(declare (special x))
(let ((x :good))
(restart-case
(invoke-restart 'foo)
(foo (&aux (y x))
(declare (special x))
y))))
:good)
\ No newline at end of file
......@@ -112,3 +112,15 @@
(values (setf a 'x) (setf b 'y) (setf c 'z)
(wa-2-a obj) (wa-2-b obj) (wa-2-c obj))))
x y z x y z)
;;; Free declaration scope test
(deftest with-accessors.14
(block done
(let ((x :bad))
(declare (special x))
(let ((x :good))
(with-accessors nil (return-from done x)
(declare (special x))))))
:good)
......@@ -146,8 +146,13 @@
)))))
100 t)
\ No newline at end of file
;;; Free declaration scope
(deftest with-hash-table-iterator.12
(block done
(let ((x :bad))
(declare (special x))
(let ((x :good))
(with-hash-table-iterator (m (return-from done x))
(declare (special x))))))
:good)
......@@ -176,5 +176,44 @@
(return-from done :good)))
:good)
;;; Free declaration scope
(deftest with-input-from-string.19
(block done
(let ((x :bad))
(declare (special x))
(let ((x :good))
(with-input-from-string (s (return-from done x))
(declare (special x))))))
:good)
(deftest with-input-from-string.20
(block done
(let ((x :bad))
(declare (special x))
(let ((x :good))
(with-input-from-string (s "abc" :start (return-from done x))
(declare (special x))))))
:good)
(deftest with-input-from-string.21
(block done
(let ((x :bad))
(declare (special x))
(let ((x :good))
(with-input-from-string (s "abc" :end (return-from done x))
(declare (special x))))))
:good)
;;; index is not updated if the form exits abnormally
(deftest with-input-from-string.22
(let ((i nil))
(values
(block done
(with-input-from-string (s "abcde" :index i) (return-from done (read-char s))))
i))
#\a nil)
;;; FIXME: Add more tests on specialized strings.
......@@ -55,3 +55,32 @@
(format s "foo!~%"))
(with-open-file (s pn) (read-line s)))
"foo!" nil)
;;; Free declaration scope tests
(deftest with-open-file.7
(block done
(let ((x :bad))
(declare (special x))
(let ((x :good))
(with-open-file (s (return-from done x))
(declare (special x))))))
:good)
(deftest with-open-file.8
(block done
(let ((x :bad))
(declare (special x))
(let ((x :good))
(with-open-file (s "with-open-file.lsp" (return-from done x) :input)
(declare (special x))))))
:good)
(deftest with-open-file.9
(block done
(let ((x :bad))
(declare (special x))
(let ((x :good))
(with-open-file (s "with-open-file.lsp" :direction (return-from done x))
(declare (special x))))))
:good)
......@@ -65,4 +65,13 @@
(open-stream-p s)))
nil t nil)
;;; Free declaration scope
(deftest with-open-stream.10
(block done
(let ((x :bad))
(declare (special x))
(let ((x :good))
(with-open-stream (s (return-from done x))
(declare (special x))))))
:good)
......@@ -161,3 +161,14 @@
(make-array 5 :element-type etype
:displaced-to name0
:displaced-index-offset 1)))
;;; Free declaration scope
(deftest with-package-iterator.22
(block done
(let ((x :bad))
(declare (special x))
(let ((x :good))
(with-package-iterator (s (return-from done x) :internal)
(declare (special x))))))
:good)
......@@ -167,3 +167,14 @@
(declare (special *x*))
(values a b c)))
x y z)
;;; Free declaration scope test
(deftest with-slots.21
(block done
(let ((x :bad))
(declare (special x))
(let ((x :good))
(with-slots nil (return-from done x)
(declare (special x))))))
:good)
\ No newline at end of file
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