The FSF has a new address.
[bpt/guile.git] / test-suite / tests / srfi-6.test
CommitLineData
0e87743a
KR
1;;;; srfi-6.test --- test suite for SRFI-6 -*- scheme -*-
2;;;;
3;;;; Copyright (C) 2003 Free Software Foundation, Inc.
4;;;;
5;;;; This program is free software; you can redistribute it and/or modify
6;;;; it under the terms of the GNU General Public License as published by
7;;;; the Free Software Foundation; either version 2, or (at your option)
8;;;; any later version.
9;;;;
10;;;; This program is distributed in the hope that it will be useful,
11;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13;;;; GNU General Public License for more details.
14;;;;
15;;;; You should have received a copy of the GNU General Public License
16;;;; along with this software; see the file COPYING. If not, write to
92205699
MV
17;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18;;;; Boston, MA 02110-1301 USA
0e87743a
KR
19
20(use-modules (test-suite lib))
21
22;; use #:select to see that the bindings we expect are indeed exported
23(use-modules ((srfi srfi-6)
24 #:select ((open-input-string . open-input-string)
25 (open-output-string . open-output-string)
26 (get-output-string . get-output-string))))
27
28
29(with-test-prefix "open-input-string"
30
31 (pass-if "eof on empty"
32 (let ((port (open-input-string "")))
33 (eof-object? (read-char port))))
34
35 (pass-if "read-char"
36 (let ((port (open-input-string "xyz")))
37 (and (char=? #\x (read-char port))
38 (char=? #\y (read-char port))
39 (char=? #\z (read-char port))
40 (eof-object? (read-char port)))))
41
42 (with-test-prefix "unread-char"
43
44 (pass-if "one char"
45 (let ((port (open-input-string "")))
46 (unread-char #\x port)
47 (and (char=? #\x (read-char port))
48 (eof-object? (read-char port)))))
49
50 (pass-if "after eof"
51 (let ((port (open-input-string "")))
52 (and (eof-object? (read-char port))
53 (begin
54 (unread-char #\x port)
55 (and (char=? #\x (read-char port))
56 (eof-object? (read-char port)))))))
57
58 (pass-if "order"
59 (let ((port (open-input-string "")))
60 (unread-char #\x port)
61 (unread-char #\y port)
62 (unread-char #\z port)
63 (and (char=? #\z (read-char port))
64 (char=? #\y (read-char port))
65 (char=? #\x (read-char port))
66 (eof-object? (read-char port)))))))
67
68
69(with-test-prefix "open-output-string"
70
71 (pass-if "empty"
72 (let ((port (open-output-string)))
73 (string=? "" (get-output-string port))))
74
75 (pass-if "xyz"
76 (let ((port (open-output-string)))
77 (display "xyz" port)
78 (string=? "xyz" (get-output-string port))))
79
80 (pass-if "seek"
81 (let ((port (open-output-string)))
82 (display "abcdef" port)
83 (seek port 2 SEEK_SET)
84 (display "--" port)
0e87743a 85 (string=? "ab--ef" (get-output-string port)))))