source: trunk/source/tests/ansi-tests/read-line.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.3 KB
Line 
1;-*- Mode:     Lisp -*-
2;;;; Author:   Paul Dietz
3;;;; Created:  Sun Jan 18 20:53:59 2004
4;;;; Contains: Tests of READ-LINE
5
6(in-package :cl-test)
7
8(deftest read-line.1
9  (with-input-from-string
10   (*standard-input* " abcd ")
11   (let ((vals (multiple-value-list (read-line))))
12     (assert (= (length vals) 2))
13     (values (first vals) (notnot (second vals)))))
14  " abcd " t)
15
16(deftest read-line.2
17  (with-input-from-string
18   (*standard-input* (string #\Newline))
19   (read-line))
20  "" nil)
21
22(deftest read-line.3
23  (with-input-from-string
24   (s (concatenate 'string "abc" (string #\Newline)))
25   (read-line s))
26  "abc" nil)
27
28(deftest read-line.4
29  (with-input-from-string
30   (s "")
31   (let ((vals (multiple-value-list (read-line s nil))))
32     (assert (= (length vals) 2))
33     (values (first vals) (notnot (second vals)))))
34  nil t)
35
36(deftest read-line.5
37  (with-input-from-string
38   (s "")
39   (let ((vals (multiple-value-list (read-line s nil 'foo))))
40     (assert (= (length vals) 2))
41     (values (first vals) (notnot (second vals)))))
42  foo t)
43
44(deftest read-line.6
45  (with-input-from-string
46   (s " abcd ")
47   (let ((vals (multiple-value-list (read-line s t nil t))))
48     (assert (= (length vals) 2))
49     (values (first vals) (notnot (second vals)))))
50  " abcd " t)
51
52(deftest read-line.7
53  (with-input-from-string
54   (is "abc")
55   (let ((*terminal-io* (make-two-way-stream is *standard-output*)))
56     (let ((vals (multiple-value-list (read-line t))))
57       (assert (= (length vals) 2))
58       (assert (second vals))
59       (first vals))))
60  "abc")
61
62(deftest read-line.8
63  (with-input-from-string
64   (*standard-input* "abc")
65   (let ((vals (multiple-value-list (read-line nil))))
66     (assert (= (length vals) 2))
67     (assert (second vals))
68     (first vals)))
69  "abc")
70
71;;; Error tests
72
73(deftest read-line.error.1
74  (signals-error
75   (with-input-from-string
76    (s (concatenate 'string "abc" (string #\Newline)))
77    (read-line s t nil nil nil))
78   program-error)
79  t)
80
81(deftest read-line.error.2
82  (signals-error-always
83   (with-input-from-string
84    (s "")
85    (read-line s))
86   end-of-file)
87  t t)
88
89(deftest read-line.error.3
90  (signals-error-always
91   (with-input-from-string
92    (*standard-input* "")
93    (read-line))
94   end-of-file)
95  t t)
96
97(deftest read-line.error.4
98  (signals-error-always
99   (with-input-from-string
100    (s "")
101    (read-line s t))
102   end-of-file)
103  t t)
104
Note: See TracBrowser for help on using the repository browser.