1 ;;;; srfi-1.test --- Test suite for Guile's SRFI-1 functions. -*- scheme -*-
3 ;;;; Copyright 2003 Free Software Foundation, Inc.
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.
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.
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
17 ;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 ;;;; Boston, MA 02111-1307 USA
20 (use-modules (srfi srfi-1)
28 (with-test-prefix "drop"
63 (pass-if "circular '(a) 0"
64 (let ((lst (circular-list 'a)))
68 (pass-if "circular '(a) 1"
69 (let ((lst (circular-list 'a)))
73 (pass-if "circular '(a) 2"
74 (let ((lst (circular-list 'a)))
78 (pass-if "circular '(a b) 1"
79 (let ((lst (circular-list 'a)))
83 (pass-if "circular '(a b) 2"
84 (let ((lst (circular-list 'a)))
88 (pass-if "circular '(a b) 5"
89 (let ((lst (circular-list 'a)))
97 (pass-if "'(a b . c) 1"
99 (drop '(a b . c) 2))))
105 (with-test-prefix "take"
108 (null? (take '() 0)))
111 (null? (take '(a) 0)))
114 (null? (take '() 0)))
116 (pass-if "'(a b c) 0"
117 (null? (take '() 0)))
122 (and (equal? '(a) got)
123 (not (eq? lst got)))))
129 (pass-if "'(a b c) 1"
136 (and (equal? '(a b) got)
137 (not (eq? lst got)))))
139 (pass-if "'(a b c) 2"
143 (pass-if "circular '(a) 0"
145 (take (circular-list 'a) 0)))
147 (pass-if "circular '(a) 1"
149 (take (circular-list 'a) 1)))
151 (pass-if "circular '(a) 2"
153 (take (circular-list 'a) 2)))
155 (pass-if "circular '(a b) 5"
157 (take (circular-list 'a 'b) 5)))
159 (pass-if "'(a . b) 1"
163 (pass-if "'(a b . c) 1"
165 (take '(a b . c) 1)))
167 (pass-if "'(a b . c) 2"
169 (take '(a b . c) 2))))