1 ;;;; q.test --- test (ice-9 q) module -*- scheme -*-
3 ;;;; Copyright 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-ice-9-q)
20 #:use-module (test-suite lib)
21 #:use-module (ice-9 q))
24 ;; Call (THUNK) and return #t if it throws 'q-empty, or #f it not.
25 (define (true-if-catch-q-empty thunk)
38 (with-test-prefix "q-pop!"
40 (with-test-prefix "no elems"
42 (pass-if "empty" (true-if-catch-q-empty
45 (pass-if "valid at end" (q? q))))
47 (with-test-prefix "one elem"
52 (pass-if "x" (eq? x (q-pop! q)))
53 (pass-if "valid after x" (q? q))
54 (pass-if "empty" (true-if-catch-q-empty
57 (pass-if "valid at end" (q? q))))
59 (with-test-prefix "two elems"
66 (pass-if "y" (eq? y (q-pop! q)))
67 (pass-if "valid after y" (q? q))
68 (pass-if "x" (eq? x (q-pop! q)))
69 (pass-if "valid after x" (q? q))
70 (pass-if "empty" (true-if-catch-q-empty
73 (pass-if "valid at end" (q? q))))
75 (with-test-prefix "three elems"
84 (pass-if "z" (eq? z (q-pop! q)))
85 (pass-if "valid after z" (q? q))
86 (pass-if "y" (eq? y (q-pop! q)))
87 (pass-if "valid after y" (q? q))
88 (pass-if "x" (eq? x (q-pop! q)))
89 (pass-if "valid after x" (q? q))
90 (pass-if "empty" (true-if-catch-q-empty
93 (pass-if "valid at end" (q? q)))))