X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Freader.impure.lisp;h=46be9f93fd829eaa6df5bab00f1f7fe8f97d5d84;hb=7c7e6276719b8d40fddec2070cad81064a25c8ed;hp=a518f25e9a20a035a809a5626b471cd702c9236c;hpb=bbfeb9a341eb81fdd80146f38548437b211dc280;p=sbcl.git diff --git a/tests/reader.impure.lisp b/tests/reader.impure.lisp index a518f25..46be9f9 100644 --- a/tests/reader.impure.lisp +++ b/tests/reader.impure.lisp @@ -13,7 +13,8 @@ ;;;; absolutely no warranty. See the COPYING and CREDITS files for ;;;; more information. -(in-package :cl-user) +(load "assertoid.lisp") +(use-package "ASSERTOID") ;;; Bug 30, involving mistakes in binding the read table, made this ;;; code fail. @@ -35,5 +36,52 @@ (assert (equalp res #(#\x))) (assert (= pos 5))) +;;; Bug 51b. (try to throw READER-ERRORs when the reader encounters +;;; dubious input) +(assert (raises-error? (read-from-string "1e1000") reader-error)) +(assert (raises-error? (read-from-string "1/0") reader-error)) + +;;; Bug reported by Antonio Martinez on comp.lang.lisp 2003-02-03 in +;;; message : reading +;;; circular instances of CLOS classes didn't work: +(defclass box () + ((value :initarg :value :reader value))) +(defun read-box (stream char) + (declare (ignore char)) + (let ((objects (read-delimited-list #\] stream t))) + (unless (= 1 (length objects)) + (error "Unknown box reader syntax")) + (make-instance 'box :value (first objects)))) +(set-macro-character #\[ 'read-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 +(defstruct readable-struct a) +(macrolet + ((frob (string) + `(assert (eq (readable-struct-a (read-from-string ,string)) t)))) + (frob "#S(READABLE-STRUCT :A T)") + (frob "#S(READABLE-STRUCT A T)") + (frob "#S(READABLE-STRUCT \"A\" T)") + (frob "#S(READABLE-STRUCT #\\A T)") + (frob "#S(READABLE-STRUCT #\\A T :A NIL)")) +(macrolet + ((frob (string) + `(assert (raises-error? (read-from-string ,string) reader-error)))) + (frob "#S(READABLE-STRUCT . :A)") + (frob "#S(READABLE-STRUCT :A . T)") + (frob "#S(READABLE-STRUCT :A T . :A)") + (frob "#S(READABLE-STRUCT :A T :A . T)")) + +;;; reported by Henrik Motakef +(defpackage "") +(assert (eq (symbol-package (read-from-string "||::FOO")) + (find-package ""))) + ;;; success (quit :unix-status 104)