forked from zloirock/core-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathes.number.is-integer.js
43 lines (43 loc) · 1000 Bytes
/
es.number.is-integer.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
31
32
33
34
35
36
37
38
39
40
41
42
43
QUnit.test('Number.isInteger', assert => {
const { isInteger } = Number;
const { create } = Object;
assert.isFunction(isInteger);
assert.name(isInteger, 'isInteger');
assert.arity(isInteger, 1);
assert.looksNative(isInteger);
assert.nonEnumerable(Number, 'isInteger');
const integers = [
1,
-1,
2 ** 16,
2 ** 16 - 1,
2 ** 31,
2 ** 31 - 1,
2 ** 32,
2 ** 32 - 1,
-0,
];
for (const value of integers) {
assert.true(isInteger(value), `isInteger ${ typeof value } ${ value }`);
}
const notIntegers = [
NaN,
0.1,
Infinity,
'NaN',
'5',
false,
new Number(NaN),
new Number(Infinity),
new Number(5),
new Number(0.1),
undefined,
null,
{},
function () { /* empty */ },
];
for (const value of notIntegers) {
assert.false(isInteger(value), `not isInteger ${ typeof value } ${ value }`);
}
assert.false(isInteger(create(null)), 'Number.isInteger(Object.create(null)) -> false');
});