source: trunk/tests/ansi-tests/file-length.lsp @ 9045

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

Assorted cleanup:

In infrastructure:

  • add *test-verbose* and :verbose argument to do-test and do-tests. Avoid random output if false, only show failures
  • muffle-wawrnings and/or bind *suppress-compiler-warnings* in some tests that unavoidably generate them (mainly with duplicate typecase/case clauses)
  • Add record-source-file for tests so meta-. can find them
  • If *catch-errors* (or the :catch-errors arg) is :break, enter a breakloop when catch an error
  • Make test fns created by *compile-tests* have names, so can find them in backtraces
  • fix misc compiler warnings
  • Fixed cases of duplicate test numbers
  • Disable note :make-condition-with-compound-name for openmcl.

In tests themselves:

I commented out the following tests with #+bogus-test, because they just seemed wrong to me:

lambda.47
lambda.50
upgraded-array-element-type.8
upgraded-array-element-type.nil.1
pathname-match-p.5
load.17
load.18
macrolet.47
ctypecase.15

In addition, I commented out the following tests with #+bogus-test because I was too lazy to make a note
for "doesn't signal underflow":

exp.error.8 exp.error.9 exp.error.10 exp.error.11 expt.error.8 expt.error.9 expt.error.10 expt.error.11

Finally, I entered bug reports in trac, and then commented out the tests
below with #+known-bug-NNN, where nnn is the ticket number in trac:

ticket#268: encode-universal-time.3 encode-universal-time.3.1
ticket#269: macrolet.36
ticket#270: values.20 values.21
ticket#271: defclass.error.13 defclass.error.22
ticket#272: phase.10 phase.12 asin.5 asin.6 asin.8
ticket#273: phase.18 phase.19 acos.8
ticket#274: exp.error.4 exp.error.5 exp.error.6 exp.error.7
ticket#275: car.error.2 cdr.error.2
ticket#276: map.error.11
ticket#277: subtypep.cons.43
ticket#278: subtypep-function.3
ticket#279: subtypep-complex.8
ticket#280: open.output.19 open.io.19 file-position.8 file-length.4 file-length.5 read-byte.4 stream-element-type.2 stream-element-type.3
ticket#281: open.65
ticket#288: set-syntax-from-char.sharp.1

File size: 4.6 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Wed Jan 21 06:21:11 2004
4;;;; Contains: Tests of FILE-LENGTH
5
6(in-package :cl-test)
7
8(deftest file-length.error.1
9  (signals-error (file-length) program-error)
10  t)
11
12(deftest file-length.error.2
13  (signals-error
14   (with-open-file (is "file-length.lsp" :direction :input)
15                   (file-length is nil))
16   program-error)
17  t)
18
19(deftest file-length.error.3
20  (loop for x in *mini-universe*
21        unless (or (typep x 'file-stream)
22                   (typep x 'broadcast-stream)
23                   (handler-case (progn (file-length x) nil)
24                                 (type-error (c)
25                                             (assert (not (typep x (type-error-expected-type c))))
26                                             t)
27                                 (condition () nil)))
28        collect x)
29  nil)
30
31(deftest file-length.error.4
32  :notes (:assume-no-simple-streams :assume-no-gray-streams)
33  (signals-error (with-input-from-string (s "abc") (file-length s))
34                 type-error)
35  t)
36
37(deftest file-length.error.5
38  (signals-error
39   (with-open-file
40    (is "file-length.lsp" :direction :input)
41    (with-open-file
42     (os "tmp.txt" :direction :output :if-exists :supersede)
43     (let ((s (make-two-way-stream is os)))
44       (unwind-protect (file-length s) (close s)))))
45   type-error)
46  t)
47
48(deftest file-length.error.6
49  (signals-error
50   (with-open-file
51    (is "file-length.lsp" :direction :input)
52    (with-open-file
53     (os "tmp.txt" :direction :output :if-exists :supersede)
54     (let ((s (make-echo-stream is os)))
55       (unwind-protect (file-length s) (close s)))))
56   type-error)
57  t)
58
59(deftest file-length.error.8
60  (with-open-file
61   (os "tmp.txt" :direction :output :if-exists :supersede)
62   (let ((s (make-broadcast-stream os)))
63     (eqlt (file-length s) (file-length os))))
64  t)
65
66(deftest file-length.error.9
67  (signals-type-error s (make-concatenated-stream)
68                      (unwind-protect (file-length s) (close s)))
69  t)
70
71(deftest file-length.error.10
72  (signals-error
73   (with-open-file
74    (is "file-length.lsp" :direction :input)
75    (let ((s (make-concatenated-stream is)))
76      (unwind-protect (file-length s) (close s))))
77   type-error)
78  t)
79
80(deftest file-length.error.11
81  :notes (:assume-no-simple-streams :assume-no-gray-streams)
82  (signals-type-error s (make-string-input-stream "abcde")
83                      (unwind-protect (file-length s) (close s)))
84  t)
85
86(deftest file-length.error.12
87  :notes (:assume-no-simple-streams :assume-no-gray-streams)
88  (signals-type-error s (make-string-output-stream)
89                      (unwind-protect (file-length s) (close s)))
90  t)
91
92;;; Non-error tests
93
94(deftest file-length.1
95  (let ((results (multiple-value-list
96                  (with-open-file
97                   (is "file-length.lsp" :direction :input)
98                   (file-length is)))))
99    (and (= (length results) 1)
100         (typep (car results) '(integer 1))
101         t))
102  t)
103
104(deftest file-length.2
105  (loop for i from 1 to 32
106        for etype = `(unsigned-byte ,i)
107        for e = (max 0 (- (ash 1 i) 5))
108        for os = (open "tmp.dat" :direction :output
109                               :if-exists :supersede
110                               :element-type etype)
111        do (loop repeat 17 do (write-byte e os))
112        do (finish-output os)
113        unless (= (file-length os) 17)
114        collect (list i (file-length os))
115        do (close os))
116  nil)
117
118(deftest file-length.3
119  (loop for i from 1 to 32
120        for etype = `(unsigned-byte ,i)
121        for e = (max 0 (- (ash 1 i) 5))
122        for os = (open "tmp.dat" :direction :output
123                               :if-exists :supersede
124                               :element-type etype)
125        for len = 0
126        do (loop repeat 17 do (write-byte e os))
127        do (close os)
128        unless (let ((is (open "tmp.dat" :direction :input
129                               :element-type etype)))
130                 (prog1
131                     (= (file-length is) 17)
132                   (close is)))
133        collect i)
134  nil)
135
136#+known-bug-280
137(deftest file-length.4
138  (loop for i from 33 to 100
139        for etype = `(unsigned-byte ,i)
140        for e = (max 0 (- (ash 1 i) 5))
141        for os = (open "tmp.dat" :direction :output
142                               :if-exists :supersede
143                               :element-type etype)
144        do (loop repeat 17 do (write-byte e os))
145        do (finish-output os)
146        unless (= (file-length os) 17)
147        collect (list i (file-length os))
148        do (close os))
149  nil)
150
151#+known-bug-280
152(deftest file-length.5
153  (loop for i from 33 to 100
154        for etype = `(unsigned-byte ,i)
155        for e = (max 0 (- (ash 1 i) 5))
156        for os = (open "tmp.dat" :direction :output
157                               :if-exists :supersede
158                               :element-type etype)
159        for len = 0
160        do (loop repeat 17 do (write-byte e os))
161        do (close os)
162        unless (let ((is (open "tmp.dat" :direction :input
163                               :element-type etype)))
164                 (prog1
165                     (= (file-length is) 17)
166                   (close is)))
167        collect i)
168  nil)           
169
170(deftest file-length.6
171  (with-open-file
172   (*foo* "file-length.lsp" :direction :input)
173   (declare (special *foo*))
174   (let ((s (make-synonym-stream '*foo*)))
175     (unwind-protect
176         (typep* (file-length s) '(integer 1))
177        (close s))))
178  t)
Note: See TracBrowser for help on using the repository browser.