forked from ramda/ramda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmathMod.js
29 lines (23 loc) · 911 Bytes
/
mathMod.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
var assert = require('assert');
var R = require('../source/index.js');
var eq = require('./shared/eq.js');
describe('mathMod', function() {
it('requires integer arguments', function() {
assert(Number.isNaN(R.mathMod('s', 3)));
assert(Number.isNaN(R.mathMod(3, 's')));
assert(Number.isNaN(R.mathMod(12.2, 3)));
assert(Number.isNaN(R.mathMod(3, 12.2)));
});
it('behaves differently than JS modulo', function() {
assert.notStrictEqual(R.mathMod(-17, 5), -17 % 5);
assert.notStrictEqual(R.mathMod(17.2, 5), 17.2 % 5);
assert.notStrictEqual(R.mathMod(17, -5), 17 % -5);
});
it('computes the true modulo function', function() {
eq(R.mathMod(-17, 5), 3);
eq(R.identical(NaN, R.mathMod(17, -5)), true);
eq(R.identical(NaN, R.mathMod(17, 0)), true);
eq(R.identical(NaN, R.mathMod(17.2, 5)), true);
eq(R.identical(NaN, R.mathMod(17, 5.5)), true);
});
});