1 ;;;; streams.test --- test Guile ice-9 streams module -*- scheme -*-
3 ;;;; Copyright (C) 2004, 2006 Free Software Foundation, Inc.
5 ;;;; This library is free software; you can redistribute it and/or
6 ;;;; modify it under the terms of the GNU Lesser General Public
7 ;;;; License as published by the Free Software Foundation; either
8 ;;;; version 3 of the License, or (at your option) any later version.
10 ;;;; This library 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 GNU
13 ;;;; Lesser General Public License for more details.
15 ;;;; You should have received a copy of the GNU Lesser General Public
16 ;;;; License along with this library; if not, write to the Free Software
17 ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 (define-module (test-suite test-streams)
20 :use-module (test-suite lib)
21 :use-module (ice-9 streams))
28 (with-test-prefix "stream-for-each"
30 (with-test-prefix "1 streams"
34 (stream-for-each (lambda (x)
35 (set! lst (cons x lst)))
41 (stream-for-each (lambda (x)
42 (set! lst (cons x lst)))
43 (list->stream '(1 2 3)))
44 (equal? '(3 2 1) lst))))
46 (with-test-prefix "2 streams"
48 (pass-if "empty empty"
50 (stream-for-each (lambda (x y)
51 (set! lst (cons* x y lst)))
58 (stream-for-each (lambda (x y)
59 (set! lst (cons* x y lst)))
60 (list->stream '(1 2 3))
61 (list->stream '(4 5 6)))
62 (equal? '(3 6 2 5 1 4) lst)))
66 (stream-for-each (lambda (x y)
67 (set! lst (cons* x y lst)))
69 (list->stream '(4 5 6)))
70 (equal? '(2 5 1 4) lst)))
74 (stream-for-each (lambda (x y)
75 (set! lst (cons* x y lst)))
76 (list->stream '(1 2 3))
77 (list->stream '(4 5)))
78 (equal? '(2 5 1 4) lst)))))