forked from ramda/ramda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathallPass.js
30 lines (24 loc) · 930 Bytes
/
allPass.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var R = require('../source/index.js');
var eq = require('./shared/eq.js');
describe('allPass', function() {
var odd = function(n) { return n % 2 !== 0; };
var lt20 = function(n) { return n < 20; };
var gt5 = function(n) { return n > 5; };
var plusEq = function(w, x, y, z) { return w + x === y + z; };
it('reports whether all predicates are satisfied by a given value', function() {
var ok = R.allPass([odd, lt20, gt5]);
eq(ok(7), true);
eq(ok(9), true);
eq(ok(10), false);
eq(ok(3), false);
eq(ok(21), false);
});
it('returns true on empty predicate list', function() {
eq(R.allPass([])(3), true);
});
it('returns a curried function whose arity matches that of the highest-arity predicate', function() {
eq(R.allPass([odd, gt5, plusEq]).length, 4);
eq(R.allPass([odd, gt5, plusEq])(9, 9, 9, 9), true);
eq(R.allPass([odd, gt5, plusEq])(9)(9)(9)(9), true);
});
});