File: fd-streams.lisp

package info (click to toggle)
cmucl 21a-4
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 50,060 kB
  • sloc: lisp: 375,822; ansic: 30,304; asm: 2,977; sh: 1,372; makefile: 355; csh: 31
file content (36 lines) | stat: -rw-r--r-- 977 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
;;;; -*- Lisp -*-

(defpackage fd-streams-tests
  (:use #:common-lisp #:lisp-unit))

(in-package #:fd-streams-tests)

(defparameter *test-path*
  (merge-pathnames (make-pathname :name :unspecific :type :unspecific
                                  :version :unspecific)
                   *load-truename*)
  "Directory for temporary test files.")

(defparameter *test-file*
  (merge-pathnames #p"test-data.tmp" *test-path*))

(eval-when (:load-toplevel)
  (ensure-directories-exist *test-path* :verbose t))

(define-test clear-output-1
  (:tag :trac)
  (assert-eql
   0
   (unwind-protect
	(let ((s (open *test-file*
		       :direction :output
		       :if-exists :supersede)))
	  ;; Write a character to the (fully buffered) output
	  ;; stream. Clear the output and close the file. Nothing
	  ;; should have been written to the file.
	  (write-char #\a s)
	  (clear-output s)
	  (close s)
	  (setf s (open *test-file*))
	  (file-length s))
     (delete-file *test-file*))))