fresh-line.lsp 1.9 KB
Newer Older
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 37 38 39 40 41 42
;-*- Mode:     Lisp -*-
;;;; Author:   Paul Dietz
;;;; Created:  Sun Jan 18 20:41:18 2004
;;;; Contains: Tests of FRESH-LINE

(in-package :cl-test)

(deftest fresh-line.1
  (let (result)
    (values
     (with-output-to-string
       (*standard-output*)
       (write-char #\a)
       (setq result (notnot (fresh-line))))
     result))
  #.(concatenate 'string "a" (string #\Newline))
  t)

(deftest fresh-line.2
  (let (result)
    (values
     (with-output-to-string
       (s)
       (write-char #\a s)
       (setq result (notnot (fresh-line s))))
     result))
  #.(concatenate 'string "a" (string #\Newline))
  t)

(deftest fresh-line.3
  (with-output-to-string
    (s)
    (write-char #\x s)
    (fresh-line s)
    (fresh-line s)
    (write-char #\y s))
  #.(concatenate 'string "x" (string #\Newline) "y"))

(deftest fresh-line.4
  (let (result)
    (values
     (with-output-to-string
pfdietz's avatar
pfdietz committed
43
       (*standard-output*)
44 45 46 47 48 49 50 51 52 53 54
       (setq result (multiple-value-list (fresh-line))))
     result))
  "" (nil))

(deftest fresh-line.5
  (let (result)
    (values
     (with-output-to-string
       (s)
       (write-char #\Space s)
       (setq result
sds's avatar
sds committed
55 56 57 58
             (list
              (multiple-value-list (notnot-mv (fresh-line s)))
              (multiple-value-list (fresh-line s))
              (multiple-value-list (fresh-line s)))))
59
     result))
60
  " 
61 62
" ((t) (nil) (nil)))

63 64 65 66 67 68 69 70
(deftest fresh-line.6
  (with-output-to-string
    (os)
    (let ((*terminal-io* (make-two-way-stream *standard-input* os)))
      (write-char #\a t)
      (fresh-line t)
      (finish-output t)))
  #.(concatenate 'string (string #\a) (string #\Newline)))
71

72 73 74 75 76 77
(deftest fresh-line.7
  (with-output-to-string
    (*standard-output*)
    (write-char #\a nil)
    (terpri nil))
  #.(concatenate 'string (string #\a) (string #\Newline)))
78 79 80 81 82 83 84 85 86 87

;;; Error tests

(deftest fresh-line.error.1
  (signals-error
   (with-output-to-string
     (s)
     (fresh-line s nil))
   program-error)
  t)