source: trunk/source/tests/ansi-tests/delete-file.lsp @ 8991

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

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

File size: 2.4 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Tue Jan 13 18:42:29 2004
4;;;; Contains: Tests for DELETE-FILE
5
6(in-package :cl-test)
7
8(deftest delete-file.1
9  (let ((pn "scratchfile.txt"))
10    (unless (probe-file pn)
11      (with-open-file (s pn :direction :output)
12                      (format s "Contents~%")))
13    (values
14     (notnot (probe-file pn))
15     (multiple-value-list (delete-file pn))
16     (probe-file pn)))
17  t (t) nil)
18
19(deftest delete-file.2
20  (let ((pn #p"scratchfile.txt"))
21    (unless (probe-file pn)
22      (with-open-file (s pn :direction :output)
23                      (format s "Contents~%")))
24    (values
25     (notnot (probe-file pn))
26     (multiple-value-list (delete-file pn))
27     (probe-file pn)))
28  t (t) nil)
29
30(deftest delete-file.3
31  (let ((pn "CLTEST:scratchfile.txt"))
32    (assert (typep (pathname pn) 'logical-pathname))
33    (unless (probe-file pn)
34      (with-open-file (s pn :direction :output)
35                      (format s "Contents~%")))
36    (values
37     (notnot (probe-file pn))
38     (multiple-value-list (delete-file pn))
39     (probe-file pn)))
40  t (t) nil)
41
42(deftest delete-file.4
43  (let ((pn "CLTEST:scratchfile.txt"))
44    (assert (typep (pathname pn) 'logical-pathname))
45    (unless (probe-file pn)
46      (with-open-file (s pn :direction :output)
47                      (format s "Contents~%")))
48    (let ((s (open pn :direction :input)))
49      (close s)
50      (values
51       (notnot (probe-file pn))
52       (multiple-value-list (delete-file s))
53       (probe-file pn))))
54  t (t) nil)
55
56;;; Specialized string tests
57
58(deftest delete-file.5
59  (do-special-strings
60   (pn "scratchfile.txt" nil)
61   (unless (probe-file pn)
62     (with-open-file (s pn :direction :output)
63                     (format s "Contents~%")))
64   (assert (probe-file pn))
65   (assert (equal (multiple-value-list (delete-file pn)) '(t)))
66   (assert (not (probe-file pn))))
67  nil)
68
69;;; Error tests
70
71(deftest delete-file.error.1
72  (signals-error (delete-file) program-error)
73  t)
74
75(deftest delete-file.error.2
76  (let ((pn "scratch.txt"))
77    (unless (probe-file pn)
78      (with-open-file (s pn :direction :output)
79                      (format s "Contents~%")))
80    (values
81     (notnot (probe-file pn))
82     (signals-error (delete-file "scratch.txt" nil) program-error)
83     (notnot (probe-file pn))
84     (delete-file pn)
85     (probe-file pn)))
86  t t t t nil)
87
88#|
89(deftest delete-file.error.3
90  (let ((pn "nonexistent.txt"))
91    (when (probe-file pn) (delete-file pn))
92    (signals-error (delete-file "nonexistent.txt") file-error))
93  t)
94|#
95
Note: See TracBrowser for help on using the repository browser.