| 1 |
;;;; streams.test --- test Guile ice-9 streams module -*- scheme -*- |
| 2 |
;;;; |
| 3 |
;;;; Copyright (C) 2004, 2006 Free Software Foundation, Inc. |
| 4 |
;;;; |
| 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. |
| 9 |
;;;; |
| 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. |
| 14 |
;;;; |
| 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 |
| 18 |
|
| 19 |
(define-module (test-suite test-streams) |
| 20 |
:use-module (test-suite lib) |
| 21 |
:use-module (ice-9 streams)) |
| 22 |
|
| 23 |
|
| 24 |
;;; |
| 25 |
;;; stream-for-each |
| 26 |
;;; |
| 27 |
|
| 28 |
(with-test-prefix "stream-for-each" |
| 29 |
|
| 30 |
(with-test-prefix "1 streams" |
| 31 |
|
| 32 |
(pass-if "empty" |
| 33 |
(let ((lst '())) |
| 34 |
(stream-for-each (lambda (x) |
| 35 |
(set! lst (cons x lst))) |
| 36 |
(list->stream '())) |
| 37 |
(equal? '() lst))) |
| 38 |
|
| 39 |
(pass-if "123" |
| 40 |
(let ((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)))) |
| 45 |
|
| 46 |
(with-test-prefix "2 streams" |
| 47 |
|
| 48 |
(pass-if "empty empty" |
| 49 |
(let ((lst '())) |
| 50 |
(stream-for-each (lambda (x y) |
| 51 |
(set! lst (cons* x y lst))) |
| 52 |
(list->stream '()) |
| 53 |
(list->stream '())) |
| 54 |
(equal? '() lst))) |
| 55 |
|
| 56 |
(pass-if "123 456" |
| 57 |
(let ((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))) |
| 63 |
|
| 64 |
(pass-if "12 456" |
| 65 |
(let ((lst '())) |
| 66 |
(stream-for-each (lambda (x y) |
| 67 |
(set! lst (cons* x y lst))) |
| 68 |
(list->stream '(1 2)) |
| 69 |
(list->stream '(4 5 6))) |
| 70 |
(equal? '(2 5 1 4) lst))) |
| 71 |
|
| 72 |
(pass-if "123 45" |
| 73 |
(let ((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))))) |