built-ins/Math/*: make all indentation consistent (depth & character) (#1435)

This commit is contained in:
Rick Waldron 2018-02-15 17:35:45 -05:00 committed by Leo Balter
parent b59d956b3c
commit 0bf08dff3d
71 changed files with 558 additions and 522 deletions

View File

@ -18,7 +18,10 @@ includes: [compareArray.js]
var mapSet = Map.prototype.set; var mapSet = Map.prototype.set;
var counter = 0; var counter = 0;
var iterable = [["foo", 1], ["bar", 2]]; var iterable = [
["foo", 1],
["bar", 2]
];
var results = []; var results = [];
var _this = []; var _this = [];

View File

@ -20,14 +20,19 @@ var iterable = {};
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return { return {
next: function() { next: function() {
return { value: [], done: false }; return {
value: [],
done: false
};
}, },
return: function() { return: function() {
count += 1; count += 1;
} }
}; };
}; };
Map.prototype.set = function() { throw new Test262Error(); } Map.prototype.set = function() {
throw new Test262Error();
}
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
new Map(iterable); new Map(iterable);

View File

@ -27,7 +27,10 @@ var iterable = {};
iterable[Symbol.iterator] = function() { iterable[Symbol.iterator] = function() {
return { return {
next: function() { next: function() {
return { value: nextItem, done: false }; return {
value: nextItem,
done: false
};
}, },
return: function() { return: function() {
count += 1; count += 1;

View File

@ -44,5 +44,7 @@ assert.throws(TypeError, function() {
}); });
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
new Map([['a', 1], 2]); new Map([
['a', 1], 2
]);
}); });

View File

@ -23,5 +23,8 @@ info: |
Map.prototype.set = null; Map.prototype.set = null;
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
new Map([[1,1], [2,2]]); new Map([
[1, 1],
[2, 2]
]);
}); });

View File

@ -17,8 +17,8 @@ info: |
---*/ ---*/
var m = new Map([ var m = new Map([
[ "attr", 1 ], ["attr", 1],
[ "foo", 2 ] ["foo", 2]
]); ]);
assert.sameValue(m.size, 2, 'The value of `m.size` is `2`'); assert.sameValue(m.size, 2, 'The value of `m.size` is `2`');

View File

@ -25,7 +25,10 @@ assert.sameValue(
"`Object.getPrototypeOf(m1)` returns `Map.prototype`" "`Object.getPrototypeOf(m1)` returns `Map.prototype`"
); );
var m2 = new Map([[1, 1], [2, 2]]); var m2 = new Map([
[1, 1],
[2, 2]
]);
assert.sameValue( assert.sameValue(
Object.getPrototypeOf(m2), Object.getPrototypeOf(m2),

View File

@ -17,11 +17,14 @@ info: |
features: [Symbol] features: [Symbol]
---*/ ---*/
var m1 = new Map([['foo', 'bar'], [1, 1]]); var m1 = new Map([
['foo', 'bar'],
[1, 1]
]);
var m2 = new Map(); var m2 = new Map();
var m3 = new Map(); var m3 = new Map();
m2.set('foo', 'bar'); m2.set('foo', 'bar');
m2.set(1,1); m2.set(1, 1);
m2.set(Symbol('a'), Symbol('a')); m2.set(Symbol('a'), Symbol('a'));
m1.clear(); m1.clear();

View File

@ -20,7 +20,11 @@ info: |
6. Return undefined. 6. Return undefined.
---*/ ---*/
var m = new Map([[1,1], [2,2], [3,3]]); var m = new Map([
[1, 1],
[2, 2],
[3, 3]
]);
var e = m.entries(); var e = m.entries();
e.next(); e.next();

View File

@ -16,7 +16,10 @@ info: |
6. Return undefined. 6. Return undefined.
---*/ ---*/
var m1 = new Map([['foo', 'bar'], [1, 1]]); var m1 = new Map([
['foo', 'bar'],
[1, 1]
]);
assert.sameValue(m1.clear(), undefined, 'clears a map and returns undefined'); assert.sameValue(m1.clear(), undefined, 'clears a map and returns undefined');
assert.sameValue(m1.clear(), undefined, 'returns undefined on an empty map'); assert.sameValue(m1.clear(), undefined, 'returns undefined on an empty map');

View File

@ -16,7 +16,11 @@ info: |
... ...
---*/ ---*/
var m = new Map([['a',1], ['b', 2], ['c', 3]]); var m = new Map([
['a', 1],
['b', 2],
['c', 3]
]);
var e = m.entries(); var e = m.entries();
e.next(); e.next();

View File

@ -15,7 +15,10 @@ info: |
6. Return false. 6. Return false.
---*/ ---*/
var m = new Map([['a',1], ['b', 2]]); var m = new Map([
['a', 1],
['b', 2]
]);
assert.sameValue(m.delete('not-in-the-map'), false); assert.sameValue(m.delete('not-in-the-map'), false);

View File

@ -16,7 +16,10 @@ info: |
... ...
---*/ ---*/
var m = new Map([['a',1], ['b', 2]]); var m = new Map([
['a', 1],
['b', 2]
]);
var result = m.delete('a'); var result = m.delete('a');

View File

@ -27,7 +27,7 @@ for (var i = 0; i < 2; i++)
args[i] = NaN; args[i] = NaN;
for (var j = 0; j < valnum; j++) for (var j = 0; j < valnum; j++)
{ {
args[1-i] = vals[j]; args[1 - i] = vals[j];
assert.sameValue( assert.sameValue(
Math.atan2(args[0], args[1]), Math.atan2(args[0], args[1]),
NaN, NaN,

View File

@ -20,8 +20,7 @@ var ynum = 3;
for (var i = 0; i < ynum; i++) for (var i = 0; i < ynum; i++)
{ {
assert.sameValue( assert.sameValue(
Math.atan2(y[i], x), Math.atan2(y[i], x), -0,
-0,
"(" + y[i] + ", Infinity)" "(" + y[i] + ", Infinity)"
); );
} }

View File

@ -18,8 +18,7 @@ var xnum = 3;
for (var i = 0; i < xnum; i++) for (var i = 0; i < xnum; i++)
{ {
assert.sameValue( assert.sameValue(
Math.atan2(y, x[i]), Math.atan2(y, x[i]), -0,
-0,
"(-0, " + x[i] + ")" "(-0, " + x[i] + ")"
); );
} }

View File

@ -25,7 +25,7 @@ assert.sameValue(Math.atanh(-1), Number.NEGATIVE_INFINITY,
"Math.atanh should produce negative infinity for -1"); "Math.atanh should produce negative infinity for -1");
assert.sameValue(Math.atanh(+1), Number.POSITIVE_INFINITY, assert.sameValue(Math.atanh(+1), Number.POSITIVE_INFINITY,
"Math.atanh should produce positive infinity for +1"); "Math.atanh should produce positive infinity for +1");
assert.sameValue(1/Math.atanh(-0), Number.NEGATIVE_INFINITY, assert.sameValue(1 / Math.atanh(-0), Number.NEGATIVE_INFINITY,
"Math.atanh should produce -0 for -0"); "Math.atanh should produce -0 for -0");
assert.sameValue(1/Math.atanh(0), Number.POSITIVE_INFINITY, assert.sameValue(1 / Math.atanh(0), Number.POSITIVE_INFINITY,
"Math.atanh should produce +0 for +0"); "Math.atanh should produce +0 for +0");

View File

@ -12,7 +12,7 @@ assert.sameValue(Math.cbrt(Number.NEGATIVE_INFINITY), Number.NEGATIVE_INFINITY,
"Math.cbrt should produce negative infinity for Number.NEGATIVE_INFINITY"); "Math.cbrt should produce negative infinity for Number.NEGATIVE_INFINITY");
assert.sameValue(Math.cbrt(Number.POSITIVE_INFINITY), Number.POSITIVE_INFINITY, assert.sameValue(Math.cbrt(Number.POSITIVE_INFINITY), Number.POSITIVE_INFINITY,
"Math.cbrt should produce positive infinity for Number.POSITIVE_INFINITY"); "Math.cbrt should produce positive infinity for Number.POSITIVE_INFINITY");
assert.sameValue(1/Math.cbrt(-0), Number.NEGATIVE_INFINITY, assert.sameValue(1 / Math.cbrt(-0), Number.NEGATIVE_INFINITY,
"Math.cbrt should produce -0 for -0"); "Math.cbrt should produce -0 for -0");
assert.sameValue(1/Math.cbrt(0), Number.POSITIVE_INFINITY, assert.sameValue(1 / Math.cbrt(0), Number.POSITIVE_INFINITY,
"Math.cbrt should produce +0 for +0"); "Math.cbrt should produce +0 for +0");

View File

@ -10,9 +10,9 @@ description: >
---*/ ---*/
// CHECK#1 // CHECK#1
for (var i=-1000; i<1000; i++) for (var i = -1000; i < 1000; i++)
{ {
var x = i/10.0; var x = i / 10.0;
if (Math.ceil(x) !== -Math.floor(-x)) if (Math.ceil(x) !== -Math.floor(-x))
{ {
$ERROR("#1: 'x = " + x + "; Math.ceil(x) !== -Math.floor(-x)'"); $ERROR("#1: 'x = " + x + "; Math.ceil(x) !== -Math.floor(-x)'");

View File

@ -12,7 +12,7 @@ assert.sameValue(Math.expm1(Number.NEGATIVE_INFINITY), -1,
"Math.expm1 should produce -1 for Number.NEGATIVE_INFINITY"); "Math.expm1 should produce -1 for Number.NEGATIVE_INFINITY");
assert.sameValue(Math.expm1(Number.POSITIVE_INFINITY), Number.POSITIVE_INFINITY, assert.sameValue(Math.expm1(Number.POSITIVE_INFINITY), Number.POSITIVE_INFINITY,
"Math.expm1 should produce POSITIVE infinity for Number.POSITIVE_INFINITY"); "Math.expm1 should produce POSITIVE infinity for Number.POSITIVE_INFINITY");
assert.sameValue(1/Math.expm1(-0), Number.NEGATIVE_INFINITY, assert.sameValue(1 / Math.expm1(-0), Number.NEGATIVE_INFINITY,
"Math.expm1 should produce -0 for -0"); "Math.expm1 should produce -0 for -0");
assert.sameValue(1/Math.expm1(0), Number.POSITIVE_INFINITY, assert.sameValue(1 / Math.expm1(0), Number.POSITIVE_INFINITY,
"Math.expm1 should produce +0 for +0"); "Math.expm1 should produce +0 for +0");

View File

@ -10,9 +10,9 @@ description: >
---*/ ---*/
// CHECK#1 // CHECK#1
for (var i=-1000; i<1000; i++) for (var i = -1000; i < 1000; i++)
{ {
var x = i/10.0; var x = i / 10.0;
if (-Math.ceil(-x) !== Math.floor(x)) if (-Math.ceil(-x) !== Math.floor(x))
{ {
$ERROR("#1: 'x = " + x + "; Math.floor(x) !== -Math.ceil(-x)'"); $ERROR("#1: 'x = " + x + "; Math.floor(x) !== -Math.ceil(-x)'");

View File

@ -7,4 +7,4 @@ author: Ryan Lewis
description: Math.hypot should return 5 if called with 3 and 4. description: Math.hypot should return 5 if called with 3 and 4.
---*/ ---*/
assert.sameValue(Math.hypot(3,4), 5, 'Math.hypot(3,4)'); assert.sameValue(Math.hypot(3, 4), 5, 'Math.hypot(3,4)');

View File

@ -30,4 +30,3 @@ assert.sameValue(Math.log10(100.00), 2,
"Math.log10 produces incorrect output for 100.00"); "Math.log10 produces incorrect output for 100.00");
assert.sameValue(Math.log10(1000.00), 3, assert.sameValue(Math.log10(1000.00), 3,
"Math.log10 produces incorrect output for 1000.00"); "Math.log10 produces incorrect output for 1000.00");

View File

@ -28,7 +28,7 @@ for (var i = 0; i <= 1; i++)
args[i] = NaN; args[i] = NaN;
for (var j = 0; j < valnum; j++) for (var j = 0; j < valnum; j++)
{ {
args[1-i] = vals[j]; args[1 - i] = vals[j];
assert.sameValue( assert.sameValue(
Math.max(args[0], args[1]), Math.max(args[0], args[1]),
NaN, NaN,

View File

@ -29,7 +29,7 @@ for (var i = 0; i <= 1; i++)
args[i] = NaN; args[i] = NaN;
for (var j = 0; j < valnum; j++) for (var j = 0; j < valnum; j++)
{ {
args[1-i] = vals[j]; args[1 - i] = vals[j];
assert.sameValue( assert.sameValue(
Math.min(args[0], args[1]), Math.min(args[0], args[1]),
NaN, NaN,

View File

@ -19,7 +19,7 @@ var basenum = 6;
for (var i = 0; i < basenum; i++) for (var i = 0; i < basenum; i++)
{ {
if (Math.pow(base[i],exponent) !== +Infinity) if (Math.pow(base[i], exponent) !== +Infinity)
{ {
$ERROR("#1: Math.pow(" + base[i] + ", " + exponent + ") !== +Infinity"); $ERROR("#1: Math.pow(" + base[i] + ", " + exponent + ") !== +Infinity");
} }

View File

@ -17,7 +17,7 @@ var exponentnum = 4;
for (var i = 0; i < exponentnum; i++) for (var i = 0; i < exponentnum; i++)
{ {
if (Math.pow(base,exponent[i]) !== +Infinity) if (Math.pow(base, exponent[i]) !== +Infinity)
{ {
$ERROR("#1: Math.pow(" + base + ", " + exponent[i] + ") !== +Infinity"); $ERROR("#1: Math.pow(" + base + ", " + exponent[i] + ") !== +Infinity");
} }

View File

@ -16,7 +16,7 @@ var exponentnum = 3;
for (var i = 0; i < exponentnum; i++) for (var i = 0; i < exponentnum; i++)
{ {
if (Math.pow(base,exponent[i]) !== -Infinity) if (Math.pow(base, exponent[i]) !== -Infinity)
{ {
$ERROR("#1: Math.pow(" + base + ", " + exponent[i] + ") !== -Infinity"); $ERROR("#1: Math.pow(" + base + ", " + exponent[i] + ") !== -Infinity");
} }

View File

@ -18,7 +18,7 @@ var exponentnum = 5;
for (var i = 0; i < exponentnum; i++) for (var i = 0; i < exponentnum; i++)
{ {
if (Math.pow(base,exponent[i]) !== +Infinity) if (Math.pow(base, exponent[i]) !== +Infinity)
{ {
$ERROR("#1: Math.pow(" + base + ", " + exponent[i] + ") !== +Infinity"); $ERROR("#1: Math.pow(" + base + ", " + exponent[i] + ") !== +Infinity");
} }

View File

@ -17,7 +17,7 @@ var exponentnum = 4;
for (var i = 0; i < exponentnum; i++) for (var i = 0; i < exponentnum; i++)
{ {
if (Math.pow(base,exponent[i]) !== +Infinity) if (Math.pow(base, exponent[i]) !== +Infinity)
{ {
$ERROR("#1: Math.pow(" + base + ", " + exponent[i] + ") !== +Infinity"); $ERROR("#1: Math.pow(" + base + ", " + exponent[i] + ") !== +Infinity");
} }

View File

@ -22,7 +22,7 @@ var basenum = 9;
for (var i = 0; i < basenum; i++) for (var i = 0; i < basenum; i++)
{ {
if (Math.pow(base[i],exponent) !== 1) if (Math.pow(base[i], exponent) !== 1)
{ {
$ERROR("#1: Math.pow(" + base[i] + ", " + exponent + ") !== 1"); $ERROR("#1: Math.pow(" + base[i] + ", " + exponent + ") !== 1");
} }

View File

@ -16,7 +16,7 @@ var exponentnum = 3;
for (var i = 0; i < exponentnum; i++) for (var i = 0; i < exponentnum; i++)
{ {
if (Math.pow(base,exponent[i]) !== -Infinity) if (Math.pow(base, exponent[i]) !== -Infinity)
{ {
$ERROR("#1: Math.pow(" + base + ", " + exponent[i] + ") !== -Infinity"); $ERROR("#1: Math.pow(" + base + ", " + exponent[i] + ") !== -Infinity");
} }

View File

@ -22,7 +22,7 @@ var basenum = 9;
for (var i = 0; i < basenum; i++) for (var i = 0; i < basenum; i++)
{ {
if (Math.pow(base[i],exponent) !== 1) if (Math.pow(base[i], exponent) !== 1)
{ {
$ERROR("#1: Math.pow(" + base[i] + ", -0) !== 1"); $ERROR("#1: Math.pow(" + base[i] + ", -0) !== 1");
} }

View File

@ -19,7 +19,7 @@ var basenum = 6;
for (var i = 0; i < basenum; i++) for (var i = 0; i < basenum; i++)
{ {
if (Math.pow(base[i],exponent) !== +Infinity) if (Math.pow(base[i], exponent) !== +Infinity)
{ {
$ERROR("#1: Math.pow(" + base[i] + ", " + exponent + ") !== +Infinity"); $ERROR("#1: Math.pow(" + base[i] + ", " + exponent + ") !== +Infinity");
} }

View File

@ -15,7 +15,7 @@ description: >
// CHECK#1 // CHECK#1
for (var i = 0; i <= 1000; i++) for (var i = 0; i <= 1000; i++)
{ {
var x = i/10.0; var x = i / 10.0;
if (Math.round(x) !== Math.floor(x + 0.5)) if (Math.round(x) !== Math.floor(x + 0.5))
{ {
$ERROR("#1: 'x = " + x + "; Math.round(x) !== Math.floor(x + 0.5)'") $ERROR("#1: 'x = " + x + "; Math.round(x) !== Math.floor(x + 0.5)'")
@ -29,7 +29,7 @@ for (i = -5; i >= -1000; i--)
x = -0.500000000000001; x = -0.500000000000001;
} else } else
{ {
x = i/10.0; x = i / 10.0;
} }
if (Math.round(x) !== Math.floor(x + 0.5)) if (Math.round(x) !== Math.floor(x + 0.5))

View File

@ -12,7 +12,7 @@ assert.sameValue(Math.sinh(Number.NEGATIVE_INFINITY), Number.NEGATIVE_INFINITY,
"Math.sinh should produce negative infinity for Number.NEGATIVE_INFINITY"); "Math.sinh should produce negative infinity for Number.NEGATIVE_INFINITY");
assert.sameValue(Math.sinh(Number.POSITIVE_INFINITY), Number.POSITIVE_INFINITY, assert.sameValue(Math.sinh(Number.POSITIVE_INFINITY), Number.POSITIVE_INFINITY,
"Math.sinh should produce positive infinity for Number.POSITIVE_INFINITY"); "Math.sinh should produce positive infinity for Number.POSITIVE_INFINITY");
assert.sameValue(1/Math.sinh(-0), Number.NEGATIVE_INFINITY, assert.sameValue(1 / Math.sinh(-0), Number.NEGATIVE_INFINITY,
"Math.sinh should produce -0 for -0"); "Math.sinh should produce -0 for -0");
assert.sameValue(1/Math.sinh(0), Number.POSITIVE_INFINITY, assert.sameValue(1 / Math.sinh(0), Number.POSITIVE_INFINITY,
"Math.sinh should produce +0 for +0"); "Math.sinh should produce +0 for +0");

View File

@ -12,7 +12,7 @@ assert.sameValue(Math.tanh(Number.NEGATIVE_INFINITY), -1,
"Math.tanh should produce -1 for Number.NEGATIVE_INFINITY"); "Math.tanh should produce -1 for Number.NEGATIVE_INFINITY");
assert.sameValue(Math.tanh(Number.POSITIVE_INFINITY), 1, assert.sameValue(Math.tanh(Number.POSITIVE_INFINITY), 1,
"Math.tanh should produce 1 for Number.POSITIVE_INFINITY"); "Math.tanh should produce 1 for Number.POSITIVE_INFINITY");
assert.sameValue(1/Math.tanh(-0), Number.NEGATIVE_INFINITY, assert.sameValue(1 / Math.tanh(-0), Number.NEGATIVE_INFINITY,
"Math.tanh should produce -0 for -0"); "Math.tanh should produce -0 for -0");
assert.sameValue(1/Math.tanh(0), Number.POSITIVE_INFINITY, assert.sameValue(1 / Math.tanh(0), Number.POSITIVE_INFINITY,
"Math.tanh should produce +0 for +0"); "Math.tanh should produce +0 for +0");

View File

@ -10,7 +10,7 @@ assert.sameValue(Math.trunc(Number.NEGATIVE_INFINITY), Number.NEGATIVE_INFINITY,
"Math.trunc should produce negative infinity for Number.NEGATIVE_INFINITY"); "Math.trunc should produce negative infinity for Number.NEGATIVE_INFINITY");
assert.sameValue(Math.trunc(Number.POSITIVE_INFINITY), Number.POSITIVE_INFINITY, assert.sameValue(Math.trunc(Number.POSITIVE_INFINITY), Number.POSITIVE_INFINITY,
"Math.trunc should produce positive infinity for Number.POSITIVE_INFINITY"); "Math.trunc should produce positive infinity for Number.POSITIVE_INFINITY");
assert.sameValue(1/Math.trunc(-0), Number.NEGATIVE_INFINITY, assert.sameValue(1 / Math.trunc(-0), Number.NEGATIVE_INFINITY,
"Math.trunc should produce -0 for -0"); "Math.trunc should produce -0 for -0");
assert.sameValue(1/Math.trunc(0), Number.POSITIVE_INFINITY, assert.sameValue(1 / Math.trunc(0), Number.POSITIVE_INFINITY,
"Math.trunc should produce +0 for +0"); "Math.trunc should produce +0 for +0");