Commit | Line | Data |
---|---|---|
9225df3c AW |
1 | ;;;; curried-definitions.test -*- scheme -*- |
2 | ;;;; Copyright (C) 2010 Free Software Foundation, Inc. | |
3 | ;;;; | |
4 | ;;;; This library is free software; you can redistribute it and/or | |
5 | ;;;; modify it under the terms of the GNU Lesser General Public | |
6 | ;;;; License as published by the Free Software Foundation; either | |
7 | ;;;; version 3 of the License, or (at your option) any later version. | |
8 | ;;;; | |
9 | ;;;; This library is distributed in the hope that it will be useful, | |
10 | ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 | ;;;; Lesser General Public License for more details. | |
13 | ;;;; | |
14 | ;;;; You should have received a copy of the GNU Lesser General Public | |
15 | ;;;; License along with this library; if not, write to the Free Software | |
16 | ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | ||
18 | (define-module (test-suite test-curried-definitions) | |
19 | #:use-module (test-suite lib) | |
20 | #:use-module (ice-9 curried-definitions)) | |
21 | ||
22 | (with-test-prefix "define" | |
23 | (pass-if "define works as usual" | |
24 | (equal? 34 | |
25 | (primitive-eval '(let () | |
26 | (define (foo) | |
27 | 34) | |
28 | (foo))))) | |
29 | (pass-if "define works as usual (2)" | |
30 | (equal? 134 | |
31 | (primitive-eval '(let () | |
32 | (define (foo x) | |
33 | (+ x 34)) | |
34 | (foo 100))))) | |
35 | (pass-if "currying once" | |
36 | (equal? 234 | |
37 | (primitive-eval '(let () | |
38 | (define ((foo) x) | |
39 | (+ x 34)) | |
40 | ((foo) 200))))) | |
41 | (pass-if "currying twice" | |
42 | (equal? 334 | |
43 | (primitive-eval '(let () | |
44 | (define (((foo)) x) | |
45 | (+ x 34)) | |
e39d0b76 AW |
46 | (((foo)) 300))))) |
47 | ||
48 | (pass-if "just a value" | |
49 | (equal? 444 | |
50 | (primitive-eval '(let () | |
51 | (define foo 444) | |
52 | foo))))) | |
53 | ||
54 | (with-test-prefix "define*" | |
55 | (pass-if "define* works as usual" | |
56 | (equal? 34 | |
57 | (primitive-eval '(let () | |
58 | (define* (foo) | |
59 | 34) | |
60 | (foo))))) | |
61 | (pass-if "define* works as usual (2)" | |
62 | (equal? 134 | |
63 | (primitive-eval '(let () | |
64 | (define* (foo x) | |
65 | (+ x 34)) | |
66 | (foo 100))))) | |
67 | (pass-if "currying once" | |
68 | (equal? 234 | |
69 | (primitive-eval '(let () | |
70 | (define* ((foo) x) | |
71 | (+ x 34)) | |
72 | ((foo) 200))))) | |
73 | (pass-if "currying twice" | |
74 | (equal? 334 | |
75 | (primitive-eval '(let () | |
76 | (define* (((foo)) x) | |
77 | (+ x 34)) | |
78 | (((foo)) 300))))) | |
79 | ||
80 | (pass-if "just a value" | |
81 | (equal? 444 | |
82 | (primitive-eval '(let () | |
83 | (define* foo 444) | |
84 | foo))))) |