source: trunk/source/tests/ansi-tests/with-open-file.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: 2.3 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Tue Jan 27 20:57:05 2004
4;;;; Contains: Tests of WITH-OPEN-FILE
5
6(in-package :cl-test)
7
8;;; For now, omit most of the options combinations, assuming they will
9;;; be tested in OPEN.  The tests of OPEN should be ported to here at some
10;;; point.
11
12(deftest with-open-file.1
13  (let ((pn #p"tmp.dat"))
14    (delete-all-versions pn)
15    (with-open-file (s pn :direction :output)))
16  nil)
17
18(deftest with-open-file.2
19  (let ((pn #p"tmp.dat"))
20    (delete-all-versions pn)
21    (with-open-file
22     (s pn :direction :output)
23     (notnot-mv (output-stream-p s))))
24  t)
25
26(deftest with-open-file.3
27  (let ((pn #p"tmp.dat"))
28    (delete-all-versions pn)
29    (with-open-file
30     (s pn :direction :output)
31     (values))))
32
33(deftest with-open-file.4
34  (let ((pn #p"tmp.dat"))
35    (delete-all-versions pn)
36    (with-open-file
37     (s pn :direction :output)
38     (values 1 2 3 4 5 6 7 8)))
39  1 2 3 4 5 6 7 8)
40
41(deftest with-open-file.5
42  (let ((pn #p"tmp.dat"))
43    (delete-all-versions pn)
44    (with-open-file
45     (s pn :direction :output)
46     (declare (ignore s))
47     (declare (optimize))))
48  nil)
49
50(deftest with-open-file.6
51  (let ((pn #p"tmp.dat"))
52    (delete-all-versions pn)
53    (with-open-file
54     (s pn (cdr '(nil . :direction)) (car '(:output)))
55     (format s "foo!~%"))
56    (with-open-file (s pn) (read-line s)))
57  "foo!" nil)
58
59;;; Free declaration scope tests
60
61(deftest with-open-file.7
62  (block done
63    (let ((x :bad))
64      (declare (special x))
65      (let ((x :good))
66        (with-open-file (s (return-from done x))
67                        (declare (special x))))))
68  :good)
69
70(deftest with-open-file.8
71  (block done
72    (let ((x :bad))
73      (declare (special x))
74      (let ((x :good))
75        (with-open-file (s "with-open-file.lsp" (return-from done x) :input)
76                        (declare (special x))))))
77  :good)
78
79(deftest with-open-file.9
80  (block done
81    (let ((x :bad))
82      (declare (special x))
83      (let ((x :good))
84        (with-open-file (s "with-open-file.lsp" :direction (return-from done x))
85                        (declare (special x))))))
86  :good)
87
88;;; Test that explicit calls to macroexpand in subforms
89;;; are done in the correct environment
90
91(deftest with-open-file.10
92  (macrolet
93   ((%m (z) z))
94   (let ((pn #p"tmp.dat"))
95    (delete-all-versions pn)
96    (with-open-file (s (expand-in-current-env (%m pn))
97                       :direction :output))))
98  nil)
Note: See TracBrowser for help on using the repository browser.