source: trunk/source/tests/ansi-tests/write-line.lsp @ 8991

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

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

File size: 3.8 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Mon Jan 19 06:49:26 2004
4;;;; Contains: Tests of WRITE-LINE
5
6(in-package :cl-test)
7
8(deftest write-line.1
9  (let (result)
10    (values
11     (with-output-to-string
12       (*standard-output*)
13       (setq result (multiple-value-list (write-line ""))))
14     result))
15  #.(string #\Newline)
16  (""))
17
18(deftest write-line.2
19  :notes (:nil-vectors-are-strings)
20  (let (result)
21    (values
22     (with-output-to-string
23       (*standard-output*)
24       (setq result
25             (multiple-value-list
26              (write-line (make-array '(0) :element-type nil)))))
27     result))
28  #.(string #\Newline)
29  (""))
30
31(deftest write-line.3
32  (let (result)
33    (values
34     (with-output-to-string
35       (*standard-output*)
36       (setq result (multiple-value-list (write-line "abcde"))))
37     result))
38  #.(concatenate 'string "abcde" (string #\Newline))
39  ("abcde"))
40
41(deftest write-line.4
42  (let (result)
43    (values
44     (with-output-to-string
45       (s)
46       (setq result (multiple-value-list (write-line "abcde" s :start 1))))
47     result))
48  #.(concatenate 'string "bcde" (string #\Newline))
49  ("abcde"))
50
51(deftest write-line.5
52  (let (result)
53    (values
54     (with-output-to-string
55       (s)
56       (setq result (multiple-value-list
57                     (write-line "abcde" s :start 1 :end 3))))
58     result))
59  #.(concatenate 'string "bc" (string #\Newline))
60  ("abcde"))
61
62(deftest write-line.6
63  (let (result)
64    (values
65     (with-output-to-string
66       (s)
67       (setq result (multiple-value-list
68                     (write-line "abcde" s :start 1 :end nil))))
69     result))
70  #.(concatenate 'string "bcde" (string #\Newline))
71  ("abcde"))
72
73(deftest write-line.7
74  (let (result)
75    (values
76     (with-output-to-string
77       (s)
78       (setq result (multiple-value-list (write-line "abcde" s :end 3))))
79     result))
80  #.(concatenate 'string "abc" (string #\Newline))
81  ("abcde"))
82
83(deftest write-line.8
84  (let (result)
85    (values
86     (with-output-to-string
87       (s)
88       (setq result (multiple-value-list
89                     (write-line "abcde" s :end 3 :allow-other-keys nil))))
90     result))
91  #.(concatenate 'string "abc" (string #\Newline))
92  ("abcde"))
93
94(deftest write-line.9
95  (let (result)
96    (values
97     (with-output-to-string
98       (s)
99       (setq result
100             (multiple-value-list
101              (write-line "abcde" s :end 3 :allow-other-keys t :foo 'bar))))
102     result))
103  #.(concatenate 'string "abc" (string #\Newline))
104  ("abcde"))
105
106(deftest write-line.10
107  (let (result)
108    (values
109     (with-output-to-string
110       (s)
111       (setq result (multiple-value-list
112                     (write-line "abcde" s :end 3 :end 2))))
113     result))
114  #.(concatenate 'string "abc" (string #\Newline))
115  ("abcde"))
116
117(deftest write-line.11
118  (with-input-from-string
119   (is "abcd")
120   (with-output-to-string
121     (os)
122     (let ((*terminal-io* (make-two-way-stream is os)))
123       (write-line "951" t)
124       (close *terminal-io*))))
125  #.(concatenate 'string "951" (string #\Newline)))
126
127(deftest write-line.12
128  (with-output-to-string
129    (*standard-output*)
130    (write-line "-=|!" nil))
131  #.(concatenate 'string "-=|!" (string #\Newline)))
132
133;;; Specialized string tests
134
135(deftest write-line.13
136  (do-special-strings
137   (s "abcde" nil)
138   (assert (equal
139            (with-output-to-string
140              (*standard-output*)
141              (multiple-value-list (write-line "abcde")))
142            #.(concatenate 'string "abcde" (string #\Newline)))))
143  nil)
144
145;;; Error tests
146
147(deftest write-line.error.1
148  (signals-error (write-line) program-error)
149  t)
150
151(deftest write-line.error.2
152  (signals-error (write-line "" *standard-output* :start) program-error)
153  t)
154
155(deftest write-line.error.3
156  (signals-error (write-line "" *standard-output* :foo nil) program-error)
157  t)
158
159(deftest write-line.error.4
160  (signals-error (write-line "" *standard-output*
161                               :allow-other-keys nil
162                               :foo nil)
163                 program-error)
164  t)
165
Note: See TracBrowser for help on using the repository browser.