Commit | Line | Data |
---|---|---|
f33f103c KR |
1 | ;;;; poe.test --- exercise ice-9/poe.scm -*- scheme -*- |
2 | ;;;; | |
3 | ;;;; Copyright 2003 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 2.1 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 | |
92205699 | 17 | ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
f33f103c KR |
18 | |
19 | (define-module (test-suite test-ice-9-poe) | |
20 | #:use-module (test-suite lib) | |
21 | #:use-module (ice-9 poe)) | |
22 | ||
23 | ||
24 | ;; | |
25 | ;; pure-funcq | |
26 | ;; | |
27 | ||
28 | ||
29 | ;; | |
30 | ;; perfect-funcq | |
31 | ;; | |
32 | ||
33 | (with-test-prefix "perfect-funcq" | |
34 | ||
35 | (with-test-prefix "no args" | |
36 | (define called #f) | |
37 | (define (foo) | |
38 | (set! called #t) | |
39 | 'foo) | |
40 | ||
41 | (let ((func (perfect-funcq 31 foo))) | |
42 | ||
43 | (pass-if "called first" | |
44 | (set! called #f) | |
45 | (and (eq? 'foo (func)) | |
46 | called)) | |
47 | ||
48 | (pass-if "not called second" | |
49 | (set! called #f) | |
50 | (and (eq? 'foo (func)) | |
51 | (not called))))) | |
52 | ||
53 | (with-test-prefix "1 arg" | |
54 | (define called #f) | |
55 | (define (foo str) | |
56 | (set! called #t) | |
57 | (string->number str)) | |
58 | ||
59 | (let ((func (perfect-funcq 31 foo))) | |
60 | (define s1 "123") | |
61 | (define s2 "123") | |
62 | ||
63 | (pass-if "called first s1" | |
64 | (set! called #f) | |
65 | (and (= 123 (func s1)) | |
66 | called)) | |
67 | ||
68 | (pass-if "not called second s1" | |
69 | (set! called #f) | |
70 | (and (= 123 (func s1)) | |
71 | (not called))) | |
72 | ||
73 | (pass-if "called first s2" | |
74 | (set! called #f) | |
75 | (and (= 123 (func s2)) | |
76 | called)) | |
77 | ||
78 | (pass-if "not called second s2" | |
79 | (set! called #f) | |
80 | (and (= 123 (func s2)) | |
81 | (not called)))))) |