1 ;;;; tests related to the Lisp reader
3 ;;;; This file is impure because we want to modify the readtable and stuff.
5 ;;;; This software is part of the SBCL system. See the README file for
8 ;;;; While most of SBCL is derived from the CMU CL system, the test
9 ;;;; files (like this one) were written from scratch after the fork
12 ;;;; This software is in the public domain and is provided with
13 ;;;; absolutely no warranty. See the COPYING and CREDITS files for
14 ;;;; more information.
18 ;;; Bug 30, involving mistakes in binding the read table, made this
20 (defun read-vector (stream char)
21 (coerce (read-delimited-list #\] stream t) 'vector))
22 (set-syntax-from-char #\[ #\() ; do I really need this? -- MNA 2001-01-05
23 (set-syntax-from-char #\] #\)) ; do I really need this? -- MNA 2001-01-05
24 (set-macro-character #\[ #'read-vector nil)
25 (set-macro-character #\] (get-macro-character #\)) nil)
26 (multiple-value-bind (res pos)
27 (read-from-string "[1 2 3]") ; ==> #(1 2 3), 7
28 (assert (equalp res #(1 2 3)))
30 (multiple-value-bind (res pos)
31 (read-from-string "#\\x") ; ==> #\x, 3
32 (assert (equalp res #\x))
34 (multiple-value-bind (res pos)
35 (read-from-string "[#\\x]")
36 (assert (equalp res #(#\x)))
40 (quit :unix-status 104)