Commit 383251b0 authored by pfdietz's avatar pfdietz

Add minimal tests for stream-external-form, with-open-file.

parent 59469e1e
......@@ -28,4 +28,4 @@
(load "file-position.lsp")
(load "file-string-length.lsp")
(load "open.lsp")
(load "stream-external-format.lsp")
......@@ -303,7 +303,46 @@
(notnot (every #'eql seq vals))))))
t)
;;; Add -- tests for when the filespec is a stream
;;; FIXME: Add -- tests for when the filespec is a stream
(deftest open.66
(let ((pn #p"tmp.dat"))
(delete-all-versions pn)
(with-open-file
(s pn :direction :io :if-exists :rename-and-delete
:if-does-not-exist :create)
(format s "some stuff~%")
(finish-output s)
(let ((is (open s :direction :input)))
(unwind-protect
(values
(read-char is)
(notnot (file-position s :start))
(read-line is)
(read-line s))
(close is)))))
#\s
t
"ome stuff"
"some stuff")
(deftest open.67
(let ((pn #p"tmp.dat"))
(delete-all-versions pn)
(let ((s (open pn :direction :output)))
(unwind-protect
(progn
(format s "some stuff~%")
(finish-output s)
(close s)
(let ((is (open s :direction :input)))
(unwind-protect
(values (read-line is))
(close is))))
(when (open-stream-p s) (close s)))))
"some stuff")
;;; FIXME: Add -- tests for when element-type is :default
;;; Tests of file creation
......
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Tue Jan 27 20:53:21 2004
;;;; Contains: Tests of STREAM-EXTERNAL-FORMAT
(in-package :cl-test)
;;; This is tested in open.lsp
;;; Error tests
(deftest stream-external-format.error.1
(signals-error (stream-external-format) program-error)
t)
(deftest stream-external-format.error.2
(signals-error
(let ((pn #p"tmp.dat"))
(delete-all-versions pn)
(with-open-file
(s pn :direction :output :if-exists :supersede)
(stream-external-format s nil)))
program-error)
t)
;-*- Mode: Lisp -*-
;;;; Author: Paul Dietz
;;;; Created: Tue Jan 27 20:57:05 2004
;;;; Contains: Tests of WITH-OPEN-FILE
(in-package :cl-test)
;;; For now, omit most of the options combinations, assuming they will
;;; be tested in OPEN. The tests of OPEN should be ported to here at some
;;; point.
(deftest with-open-file.1
(let ((pn #p"tmp.dat"))
(delete-all-versions pn)
(with-open-file (s pn :direction :output)))
nil)
(deftest with-open-file.2
(let ((pn #p"tmp.dat"))
(delete-all-versions pn)
(with-open-file
(s pn :direction :output)
(notnot-mv (output-stream-p s))))
t)
(deftest with-open-file.3
(let ((pn #p"tmp.dat"))
(delete-all-versions pn)
(with-open-file
(s pn :direction :output)
(values))))
(deftest with-open-file.4
(let ((pn #p"tmp.dat"))
(delete-all-versions pn)
(with-open-file
(s pn :direction :output)
(values 1 2 3 4 5 6 7 8)))
1 2 3 4 5 6 7 8)
(deftest with-open-file.5
(let ((pn #p"tmp.dat"))
(delete-all-versions pn)
(with-open-file
(s pn :direction :output)
(declare (ignore s))))
nil)
(deftest with-open-file.6
(let ((pn #p"tmp.dat"))
(delete-all-versions pn)
(with-open-file
(s pn (cdr '(nil . :direction)) (car '(:output)))
(format s "foo!~%"))
(with-open-file (s pn) (read-line s)))
"foo!" nil)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment