Debian Codegraph @

test/include/srfi-232-tests.scm

raw
1 ;; From the reference implementation
2 ;; https://github.com/scheme-requests-for-implementation/srfi-232
3 (test-group "Simple currying"
4 (test-eqv 5 ((curried (x y) (+ x y)) 2 3))
5 (test-eqv 5 (((curried (x y) (+ x y)) 2) 3))
6 (test-eqv 5 ((curried (w x y z) (+ w x y z)) 1 1 1 2))
7 (test-eqv 5 ((((curried (w x y z) (+ w x y z)) 1) 1) 1 2))
8 (test-eqv 5 (((curried (w x y z) (+ w x y z)) 1) 1 1 2))
9 (test-eqv 5 (((curried (w x y z) (+ w x y z)) 1 1) 1 2))
10 (test-eqv 5 (((curried (w x y z) (+ w x y z)) 1 1 1) 2))
11 (test-eqv 5 (((((curried (w x y z) (+ w x y z)) 1) 1) 1) 2))
12 )
13
14 (test-group "Variadic"
15 (test-equal '(3 (3 4))
16 ((curried (a b . rest) (list (+ a b) rest)) 1 2 3 4))
17 (test-equal
18 '(3 (3 4))
19 (((curried (a b . rest) (list (+ a b) rest)) 1) 2 3 4))
20 (test-equal '(3 ()) ((curried (a b . rest) (list (+ a b) rest)) 1 2))
21 )
22
23 (test-group "Nullary"
24 (test-eqv 3 ((curried () (curried (x y) (+ x y))) 1 2))
25 (test-eqv 3 (((curried () (curried (x y) (+ x y))) 1) 2))
26
27 ;; "... while these behaviors are decidedly not wrong, they are
28 ;; perhaps mildly unsettling."
29 (test-eqv 2
30 ((curried (a)
31 (curried ()
32 (curried ()
33 (curried (b) b)))) 1 2))
34 (test-eqv 4 (((((((((curried (a b c) 4)))))))) 1 2 3))
35 )
36
37 (test-group "Extra arguments"
38 (test-eqv 20 ((curried (x y) (curried (z) (* z (+ x y)))) 2 3 4))
39 (test-eqv 20 (((curried (x y) (curried (z) (* z (+ x y)))) 2) 3 4))
40 )