X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fprint.lisp;h=c159e568a3e08c5d8a164a09ebb3479ecbacb4a0;hb=3517907ed86d25003e1f8ae220ef354296d22416;hp=8d58c3ca95a6395572caf905a5e94f43634536e3;hpb=2ff4cf0a60d5187b27bc07c6bcfdef88cc89f22b;p=jscl.git diff --git a/tests/print.lisp b/tests/print.lisp index 8d58c3c..c159e56 100644 --- a/tests/print.lisp +++ b/tests/print.lisp @@ -16,3 +16,38 @@ (and (symbolp x) (equal (symbol-name x) "1E+2")))) (test (let ((x (read-from-string (prin1-to-string '1E+)))) (and (symbolp x) (equal (symbol-name x) "1E+")))) + + + +;;; Printing strings +(test (string= "\"foobar\"" (write-to-string "foobar"))) +(test (string= "\"foo\\\"bar\"" (write-to-string "foo\"bar"))) + +;;; Printing vectors +(test (string= "#()" (write-to-string #()))) +(test (string= "#(1)" (write-to-string #(1)))) +(test (string= "#(1 2 3)" (write-to-string #(1 2 3)))) + +;;; Lists +(test (string= "NIL" (write-to-string '()))) +(test (string= "(1)" (write-to-string '(1)))) +(test (string= "(1 2 3)" (write-to-string '(1 2 3)))) +(test (string= "(1 2 . 3)" (write-to-string '(1 2 . 3)))) +(test (string= "(1 2 3)" (write-to-string '(1 2 3)))) +(test (string= "((1 . 2) 3)" (write-to-string '((1 . 2) 3)))) +(test (string= "((1) 3)" (write-to-string '((1) 3)))) + +;;; Circular printing +(let ((vector #(1 2 nil))) + (setf (aref vector 2) vector) + (test (string= "#1=#(1 2 #1#)" + (let ((*print-circle* t)) + (write-to-string vector))))) + +(let ((list '(1))) + (setf (cdr list) list) + (test (string= "#1=(1 . #1#)" + (let ((*print-circle* t)) + (write-to-string list))))) + +