Fix comment
[jscl.git] / tests / read.lisp
1 ;; TODO: Uncomment when either read-from-string supports all these parameters
2 ;; or when test macro supports error handling, whichever comes first
3 ;; (test (equal (read-from-string " 1 3 5" t nil :start 2) (values 3 5)))
4 (expected-failure
5  (equal (multiple-value-list (read-from-string "(a b c)"))
6         '((A B C) 7)))
7
8 (test (equal (symbol-name (read-from-string "cl:cond")) "COND"))
9 (test (equal (symbol-name (read-from-string "co|N|d")) "COND"))
10 (test (equal (symbol-name (read-from-string "abc\\def")) "ABCdEF"))
11 (test (equal (symbol-name (read-from-string "|.|")) "."))
12 (test (equal (read-from-string "(1 .25)") '(1 0.25)))
13 (test (equal (read-from-string ".25") 0.25))
14 (test (equal (read-from-string "(1 . 25)") '(1 . 25)))
15
16 (test (equal (read-from-string "(#1=99 2 3 #1#)") '(99 2 3 99)))
17 (let ((v (read-from-string "#(#1=99 2 3 #1#)")))
18   (test (and (eql (aref v 0) 99)
19              (eql (aref v 1) 2)
20              (eql (aref v 2) 3)
21              (eql (aref v 3) 99))))
22
23 (test (let ((x (read-from-string "#1=(42 . #1#)")))
24         (and (eql (nth 99 x) 42)
25              (progn
26                (rplaca x 13)
27                (eql (nth 99 x) 13))
28              (eq x (cdr x)))))
29
30 (test (let ((x (read-from-string "#1=#(1 #2=99 #1# #2#)")))
31         (and (eql (aref x 0) 1)
32              (eql (aref x 1) 99)
33              (eq (aref x 2) x)
34              (eql (aref x 3) 99))))
35
36 (test (let ((x (read-from-string "#1=(1 2 #2=#(3 4 #1#) 5 #2#)")))
37         (and (eql (nth 0 x) 1)
38              (eql (nth 1 x) 2)
39              (eql (aref (nth 2 x) 0) 3)
40              (eql (aref (nth 2 x) 1) 4)
41              (eq (aref (nth 2 x) 2) x)
42              (eql (nth 3 x) 5)
43              (eq (nth 4 x) (nth 2 x)))))
44