source: trunk/source/tests/ansi-tests/syntax-tokens.lsp @ 8991

Last change on this file since 8991 was 8991, checked in by gz, 12 years ago

Check in the gcl ansi test suite (original, in preparation for making local changes)

File size: 3.2 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Fri Jan 14 07:43:24 2005
4;;;; Contains: Tests of reading of tokens
5
6(in-package :cl-test)
7
8(compile-and-load "reader-aux.lsp")
9
10;; Erroneous numbers
11
12(def-syntax-test syntax.number-token.error.1
13  (signals-error (read-from-string "1/0") reader-error)
14  t)
15
16#|
17(def-syntax-test syntax.number-token.error.2
18  (loop for f in (list most-positive-short-float
19                       most-positive-single-float
20                       most-positive-double-float
21                       most-positive-long-float)
22        for c across "sfdl"
23        for r = (float-radix f)
24        for x = (nth-value 1 (decode-float f))
25        for n = (1+ (ceiling (* (log r 10) x)))
26        for s = (format nil "1.0~C~D" c n)
27        for vals = (multiple-value-list
28                    (eval `(signals-error (read-from-string ,s)
29                                          reader-error)))
30        unless (equal vals '(t))
31        collect (list f c r x n s vals))
32  nil)
33|#
34
35(def-syntax-test syntax.number-token.3
36  (loop for tp in '(short-float single-float double-float long-float)
37        for c across "sfdl"
38        for s = (concatenate 'string "1.0"
39                             (make-string 1000 :initial-element #\0)
40                             "1" (string c) "0")
41        for n = (read-from-string s)
42        unless (and (typep n tp)
43                    (<= 1 n)
44                    (< n 2))
45        collect (list c tp s n))
46  nil)
47
48(def-syntax-test syntax.number-token.4
49  (loop for type in '(short-float single-float double-float long-float)
50        nconc
51        (let* ((*read-default-float-format* type)
52               (s (concatenate 'string
53                               "1." (make-string 1000 :initial-element #\0)
54                               "1"))
55               (n (read-from-string s)))
56          (unless (and (typep n type)
57                       (<= 1 n)
58                       (< n 2))
59            (list (list type s n)))))
60  nil)
61
62           
63;;; Dot tokens
64
65(def-syntax-test syntax.dot-token.1
66  (read-from-string "\\.")
67  |.| 2)
68
69(def-syntax-test syntax.dot-token.2
70  (read-from-string ".\\.")
71  |..| 3)
72
73(def-syntax-test syntax.dot-token.3
74  (read-from-string "\\..")
75  |..| 3)
76
77(def-syntax-test syntax.dot-token.4
78  (read-from-string "..\\.")
79  |...| 4)
80
81(def-syntax-test syntax.dot-token.5
82  (read-from-string ".\\..")
83  |...| 4)
84
85(def-syntax-test syntax.dot-token.6
86  (read-from-string "\\...")
87  |...| 4)
88
89(def-syntax-test syntax.dot-token.7
90  (read-from-string ".||")
91  |.| 3)
92
93(def-syntax-test syntax.dot-token.8
94  (read-from-string "..||")
95  |..| 4)
96
97(def-syntax-test syntax.dot-error.1
98  (signals-error (read-from-string ".") reader-error)
99  t)
100
101(def-syntax-test syntax.dot-error.2
102  (signals-error (read-from-string "..") reader-error)
103  t)
104
105(def-syntax-test syntax.dot-error.3
106  (signals-error (read-from-string "...") reader-error)
107  t)
108
109(def-syntax-test syntax.dot-error.4
110  (signals-error (read-from-string "( . 1)") reader-error)
111  t)
112
113(def-syntax-test syntax.dot-error.5
114  (signals-error (read-from-string "(1 ..)") reader-error)
115  t)
116
117(def-syntax-test syntax.dot-error.6
118  (signals-error (read-from-string "(1 .. 2)") reader-error)
119  t)
120
121(def-syntax-test syntax.dot-error.7
122  (signals-error (read-from-string "#(1 . 2)") reader-error)
123  t)
124
125;;; right paren
126
127(def-syntax-test syntax.right-paren-error.1
128  (signals-error (read-from-string ")") reader-error)
129  t)
130
131(def-syntax-test syntax.comma-error.1
132  (signals-error (read-from-string ",") reader-error)
133  t)
134
135(def-syntax-test syntax.comma-error.2
136  (signals-error (read-from-string ",1") reader-error)
137  t)
138
Note: See TracBrowser for help on using the repository browser.