X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Freader.impure.lisp;h=bb37bdf3a30d112534642a26cbc93c747b6e0284;hb=7e24349c17298e2959e853ea411b5f65d9f7f332;hp=1d90ae191b4ac84c9a58f57c4bf57fc1f761e3f6;hpb=15ecd1ada227a60bcb3a660a4924c8d9449cb997;p=sbcl.git diff --git a/tests/reader.impure.lisp b/tests/reader.impure.lisp index 1d90ae1..bb37bdf 100644 --- a/tests/reader.impure.lisp +++ b/tests/reader.impure.lisp @@ -8,7 +8,7 @@ ;;;; While most of SBCL is derived from the CMU CL system, the test ;;;; files (like this one) were written from scratch after the fork ;;;; from CMU CL. -;;;; +;;;; ;;;; This software is in the public domain and is provided with ;;;; absolutely no warranty. See the COPYING and CREDITS files for ;;;; more information. @@ -58,6 +58,22 @@ (read-from-string "#1=[#1#]") (assert (eq (value res) res)) (assert (= pos 8))) +;;; much, much, later (in Feb 2007), CSR noticed that the problem +;;; still exists for funcallable instances. +(defclass funcallable-box (box sb-mop:funcallable-standard-object) () + (:metaclass sb-mop:funcallable-standard-class)) +(defun read-funcallable-box (stream char) + (declare (ignore char)) + (let ((objects (read-delimited-list #\} stream t))) + (unless (= 1 (length objects)) + (error "Unknown box reader syntax")) + (make-instance 'funcallable-box :value (first objects)))) +(set-macro-character #\{ 'read-funcallable-box) +(set-syntax-from-char #\} #\)) +(multiple-value-bind (res pos) + (read-from-string "#1={#1#}") + (assert (eq (value res) res)) + (assert (= pos 8))) ;;; CSR managed to break the #S reader macro in the process of merging ;;; SB-PCL:CLASS and CL:CLASS -- make sure it works @@ -81,7 +97,7 @@ ;;; reported by Henrik Motakef (defpackage "") (assert (eq (symbol-package (read-from-string "||::FOO")) - (find-package ""))) + (find-package ""))) ;;; test nested reads, test case by Helmut Eller for cmucl (defclass my-in-stream (sb-gray:fundamental-character-input-stream) @@ -93,8 +109,8 @@ (with-input-from-string (s "b") (read s)) (with-slots (last-char) s (cond (last-char (prog1 last-char (setf last-char nil))) - (t (prog1 (aref string i) - (setq i (mod (1+ i) (length string))))))))) + (t (prog1 (aref string i) + (setq i (mod (1+ i) (length string))))))))) (defmethod sb-gray:stream-unread-char ((s my-in-stream) char) (setf (slot-value s 'last-char) char) @@ -102,5 +118,11 @@ (assert (eq 'a (read (make-instance 'my-in-stream :last-char nil)))) +;;; NIL as the last argument to SET-SYNTAX-FROM-CHAR in compiled code, +;;; reported by Levente Mészáros +(let ((fun (compile nil '(lambda () + (set-syntax-from-char #\{ #\( *readtable* nil))))) + (funcall fun) + (assert (equal '(:ok) (read-from-string "{:ok)")))) + ;;; success -(quit :unix-status 104)