forked from zloirock/core-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathes.number.is-finite.js
43 lines (43 loc) · 978 Bytes
/
es.number.is-finite.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.isFinite', assert => {
const { isFinite } = Number;
const { create } = Object;
assert.isFunction(isFinite);
assert.name(isFinite, 'isFinite');
assert.arity(isFinite, 1);
assert.looksNative(isFinite);
assert.nonEnumerable(Number, 'isFinite');
const finite = [
1,
0.1,
-1,
2 ** 16,
2 ** 16 - 1,
2 ** 31,
2 ** 31 - 1,
2 ** 32,
2 ** 32 - 1,
-0,
];
for (const value of finite) {
assert.true(isFinite(value), `isFinite ${ typeof value } ${ value }`);
}
const notFinite = [
NaN,
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 notFinite) {
assert.false(isFinite(value), `not isFinite ${ typeof value } ${ value }`);
}
assert.false(isFinite(create(null)), 'Number.isFinite(Object.create(null)) -> false');
});