mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-20 10:40:19 +02:00
(truncate-file): New tests.
This commit is contained in:
parent
c783f5891a
commit
da58419409
1 changed files with 36 additions and 0 deletions
|
@ -538,6 +538,42 @@
|
||||||
(while (not (eof-object? (read-char port))))
|
(while (not (eof-object? (read-char port))))
|
||||||
(= 8 (port-column port))))))
|
(= 8 (port-column port))))))
|
||||||
|
|
||||||
|
;;;
|
||||||
|
;;; truncate-file
|
||||||
|
;;;
|
||||||
|
|
||||||
|
(with-test-prefix "truncate-file"
|
||||||
|
|
||||||
|
(with-test-prefix "filename"
|
||||||
|
|
||||||
|
(pass-if "shorten"
|
||||||
|
(call-with-output-file (test-file)
|
||||||
|
(lambda (port)
|
||||||
|
(display "hello" port)))
|
||||||
|
(truncate-file (test-file) 1)
|
||||||
|
(eqv? 1 (stat:size (stat (test-file))))))
|
||||||
|
|
||||||
|
(with-test-prefix "file descriptor"
|
||||||
|
|
||||||
|
(pass-if "shorten"
|
||||||
|
(call-with-output-file (test-file)
|
||||||
|
(lambda (port)
|
||||||
|
(display "hello" port)))
|
||||||
|
(let ((fd (open-fdes (test-file) O_RDWR)))
|
||||||
|
(truncate-file fd 1)
|
||||||
|
(close-fdes fd))
|
||||||
|
(eqv? 1 (stat:size (stat (test-file))))))
|
||||||
|
|
||||||
|
(with-test-prefix "file port"
|
||||||
|
|
||||||
|
(pass-if "shorten"
|
||||||
|
(call-with-output-file (test-file)
|
||||||
|
(lambda (port)
|
||||||
|
(display "hello" port)))
|
||||||
|
(let ((port (open-file (test-file) "r+")))
|
||||||
|
(truncate-file port 1))
|
||||||
|
(eqv? 1 (stat:size (stat (test-file)))))))
|
||||||
|
|
||||||
|
|
||||||
;;;; testing read-delimited and friends
|
;;;; testing read-delimited and friends
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue