forked from ramda/ramda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheqBy.js
27 lines (21 loc) · 787 Bytes
/
eqBy.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
var R = require('..');
var eq = require('./shared/eq');
describe('eqBy', function() {
it('determines whether two values map to the same value in the codomain', function() {
eq(R.eqBy(Math.abs, 5, 5), true);
eq(R.eqBy(Math.abs, 5, -5), true);
eq(R.eqBy(Math.abs, -5, 5), true);
eq(R.eqBy(Math.abs, -5, -5), true);
eq(R.eqBy(Math.abs, 42, 99), false);
});
it('has R.equals semantics', function() {
function Just(x) { this.value = x; }
Just.prototype.equals = function(x) {
return x instanceof Just && R.equals(x.value, this.value);
};
eq(R.eqBy(R.identity, 0, -0), false);
eq(R.eqBy(R.identity, -0, 0), false);
eq(R.eqBy(R.identity, NaN, NaN), true);
eq(R.eqBy(R.identity, new Just([42]), new Just([42])), true);
});
});