Fix comment
[jscl.git] / tests / print.lisp
1 (test (let ((x (read-from-string (prin1-to-string 'foo))))
2         (and (symbolp x) (equal (symbol-name x) "FOO"))))
3 (test (let ((x (read-from-string (prin1-to-string 'fo\o))))
4         (and (symbolp x) (equal (symbol-name x) "FOo"))))
5 (test (let ((x (read-from-string (prin1-to-string '1..2))))
6         (and (symbolp x) (equal (symbol-name x) "1..2"))))
7 (test (let ((x (read-from-string (prin1-to-string '\1))))
8         (and (symbolp x) (equal (symbol-name x) "1"))))
9 (test (let ((x (read-from-string (prin1-to-string '\-10))))
10         (and (symbolp x) (equal (symbol-name x) "-10"))))
11 (test (let ((x (read-from-string (prin1-to-string '\.\.\.))))
12         (and (symbolp x) (equal (symbol-name x) "..."))))
13 (test (let ((x (read-from-string (prin1-to-string '1E))))
14         (and (symbolp x) (equal (symbol-name x) "1E"))))
15 (test (let ((x (read-from-string (prin1-to-string '\1E+2))))
16         (and (symbolp x) (equal (symbol-name x) "1E+2"))))
17 (test (let ((x (read-from-string (prin1-to-string '1E+))))
18         (and (symbolp x) (equal (symbol-name x) "1E+"))))
19
20
21
22 ;;; Printing strings
23 (test (string= "\"foobar\"" (write-to-string "foobar")))
24 (test (string= "\"foo\\\"bar\"" (write-to-string "foo\"bar")))
25
26 ;;; Printing vectors
27 (test (string= "#()" (write-to-string #())))
28 (test (string= "#(1)" (write-to-string #(1))))
29 (test (string= "#(1 2 3)" (write-to-string #(1 2 3))))
30
31 ;;; Lists
32 (test (string= "NIL" (write-to-string '())))
33 (test (string= "(1)" (write-to-string '(1))))
34 (test (string= "(1 2 3)" (write-to-string '(1 2 3))))
35 (test (string= "(1 2 . 3)" (write-to-string '(1 2 . 3))))
36 (test (string= "(1 2 3)" (write-to-string '(1 2 3))))
37 (test (string= "((1 . 2) 3)" (write-to-string '((1 . 2) 3))))
38 (test (string= "((1) 3)" (write-to-string '((1) 3))))
39
40 ;;; Circular printing
41 (let ((vector #(1 2 nil)))
42   (setf (aref vector 2) vector)
43   (test (string= "#1=#(1 2 #1#)"
44                  (let ((*print-circle* t))
45                    (write-to-string vector)))))
46
47 (let ((list '(1)))
48   (setf (cdr list) list)
49   (test (string= "#1=(1 . #1#)"
50                  (let ((*print-circle* t))
51                    (write-to-string list)))))
52
53