1 ;;;; poe.test --- exercise ice-9/poe.scm -*- scheme -*-
3 ;;;; Copyright 2003, 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 2.1 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-poe)
20 #:use-module (test-suite lib)
21 #:use-module (ice-9 poe))
28 (with-test-prefix "pure-funcq"
30 (with-test-prefix "no args"
31 (define obj (vector 123)) ;; not gc'ed
37 (let ((func (pure-funcq foo)))
39 (pass-if "called first"
44 (pass-if "not called second"
49 (with-test-prefix "1 arg"
50 (define obj1 (vector 123)) ;; not gc'ed
51 (define obj2 (vector 456)) ;; not gc'ed
58 (else (error "oops"))))
60 (let ((func (pure-funcq foo)))
62 (pass-if "called first x"
64 (and (eq? obj1 (func 'x))
67 (pass-if "not called second x"
69 (and (eq? obj1 (func 'x))
72 (pass-if "called first y"
74 (and (eq? obj2 (func 'y))
77 (pass-if "not called second y"
79 (and (eq? obj2 (func 'y))
82 (pass-if "not called third x"
84 (and (eq? obj1 (func 'x))
91 (with-test-prefix "perfect-funcq"
93 (with-test-prefix "no args"
99 (let ((func (perfect-funcq 31 foo)))
101 (pass-if "called first"
103 (and (eq? 'foo (func))
106 (pass-if "not called second"
108 (and (eq? 'foo (func))
111 (with-test-prefix "1 arg"
115 (string->number str))
117 (let ((func (perfect-funcq 31 foo)))
121 (pass-if "called first s1"
123 (and (= 123 (func s1))
126 (pass-if "not called second s1"
128 (and (= 123 (func s1))
131 (pass-if "called first s2"
133 (and (= 123 (func s2))
136 (pass-if "not called second s2"
138 (and (= 123 (func s2))