forked from zloirock/core-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathes.math.hypot.js
41 lines (40 loc) · 1.8 KB
/
es.math.hypot.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
import hypot from 'core-js-pure/features/math/hypot';
QUnit.test('Math.hypot', assert => {
const { sqrt } = Math;
assert.isFunction(hypot);
assert.strictEqual(hypot(), 0);
assert.strictEqual(hypot(1), 1);
assert.same(hypot('', 0), 0);
assert.same(hypot(0, ''), 0);
assert.strictEqual(hypot(Infinity, 0), Infinity, 'Infinity, 0');
assert.strictEqual(hypot(-Infinity, 0), Infinity, '-Infinity, 0');
assert.strictEqual(hypot(0, Infinity), Infinity, '0, Infinity');
assert.strictEqual(hypot(0, -Infinity), Infinity, '0, -Infinity');
assert.strictEqual(hypot(Infinity, NaN), Infinity, 'Infinity, NaN');
assert.strictEqual(hypot(NaN, -Infinity), Infinity, 'NaN, -Infinity');
assert.same(hypot(NaN, 0), NaN, 'NaN, 0');
assert.same(hypot(0, NaN), NaN, '0, NaN');
assert.same(hypot(0, -0), 0);
assert.same(hypot(0, 0), 0);
assert.same(hypot(-0, -0), 0);
assert.same(hypot(-0, 0), 0);
assert.strictEqual(hypot(0, 1), 1);
assert.strictEqual(hypot(0, -1), 1);
assert.strictEqual(hypot(-0, 1), 1);
assert.strictEqual(hypot(-0, -1), 1);
assert.same(hypot(0), 0);
assert.strictEqual(hypot(1), 1);
assert.strictEqual(hypot(2), 2);
assert.strictEqual(hypot(0, 0, 1), 1);
assert.strictEqual(hypot(0, 1, 0), 1);
assert.strictEqual(hypot(1, 0, 0), 1);
assert.strictEqual(hypot(2, 3, 4), sqrt(2 * 2 + 3 * 3 + 4 * 4));
assert.strictEqual(hypot(2, 3, 4, 5), sqrt(2 * 2 + 3 * 3 + 4 * 4 + 5 * 5));
assert.epsilon(hypot(66, 66), 93.33809511662427);
assert.epsilon(hypot(0.1, 100), 100.0000499999875);
assert.strictEqual(hypot(1e+300, 1e+300), 1.4142135623730952e+300);
assert.strictEqual(Math.floor(hypot(1e-300, 1e-300) * 1e308), 141421356);
assert.strictEqual(hypot(1e+300, 1e+300, 2, 3), 1.4142135623730952e+300);
assert.strictEqual(hypot(-3, 4), 5);
assert.strictEqual(hypot(3, -4), 5);
});