Update Math functions to handle distinct -0 and +0

This commit is contained in:
Leonardo Balter 2016-06-22 12:40:52 -04:00 committed by Mike Pennisi
parent 13e01e4340
commit 0f29f57fdc
35 changed files with 47 additions and 204 deletions

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.1_A2
description: Checking if Math.abs(-0) equals to +0
---*/
// CHECK#1
var x = -0;
if (Math.abs(x) !== +0)
{
$ERROR("#1: 'var x=-0; Math.abs(x) !== +0'");
}
assert.sameValue(Math.abs(-0), 0);

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.2_A4
description: Checking if Math.acos(1) equals to +0
---*/
// CHECK#1
var x = 1;
if (Math.acos(x) !== +0)
{
$ERROR("#1: 'var x = 1; Math.acos(x) !== +0'");
}
assert.sameValue(Math.acos(1), 0);

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.3_A4
description: Checking if Math.asin(+0) equals +0
---*/
// CHECK#1
var x = +0;
if (Math.asin(x) !== +0)
{
$ERROR("#1: 'var x = +0; Math.asin(x) !== +0'");
}
assert.sameValue(Math.asin(0), 0);

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.3_A5
description: Checking if Math.asin(-0) equals to -0
---*/
// CHECK#1
var x = -0;
if (Math.asin(x) !== -0)
{
$ERROR("#1: 'var x = -0; Math.asin(x) !== -0'");
}
assert.sameValue(Math.asin(-0), -0);

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.4_A2
description: Checking if Math.atan(+0) equals to +0
---*/
// CHECK#1
var x = +0;
if (Math.atan(x) !== +0)
{
$ERROR("#1: 'var x = +0; Math.atan(x) !== +0'");
}
assert.sameValue(Math.atan(0), 0);

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.4_A3
description: Checking if Math.atan(-0) equals to -0
---*/
// CHECK#1
var x = -0;
if (Math.atan(x) !== -0)
{
$ERROR("#1: 'var x = -0; Math.atan(x) !== -0'");
}
assert.sameValue(Math.atan(-0), -0);

View File

@ -19,6 +19,5 @@ var ynum = 3;
for (var i = 0; i < ynum; i++)
{
if (Math.atan2(y[i],x) !== +0)
$ERROR("#1: Math.atan2(" + y[i] + ", " + x + ") !== +0");
assert.sameValue(Math.atan2(y[i], x), 0, y[i]);
}

View File

@ -19,6 +19,9 @@ var ynum = 3;
for (var i = 0; i < ynum; i++)
{
if (Math.atan2(y[i],x) !== -0)
$ERROR("#1: Math.atan2(" + y[i] + ", " + x + ") !== -0");
assert.sameValue(
Math.atan2(y[i], x),
-0,
"(" + y[i] + ", Infinity)"
);
}

View File

@ -17,6 +17,5 @@ var xnum = 3;
for (var i = 0; i < xnum; i++)
{
if (Math.atan2(y,x[i]) !== +0)
$ERROR("#1: Math.atan2(" + y + ", " + x[i] + ") !== +0");
assert.sameValue(Math.atan2(y, x[i]), 0, x[i]);
}

View File

@ -7,8 +7,4 @@ es5id: 15.8.2.5_A5
description: Checking if Math.atan2(y,x) is +0, where y is +0 and x is +0
---*/
// CHECK#1
var y = +0;
var x = +0;
if (Math.atan2(y,x) !== +0)
$ERROR("#1: Math.atan2(" + y + ", " + x + ") !== +0");
assert.sameValue(Math.atan2(0, 0), 0);

View File

@ -17,6 +17,9 @@ var xnum = 3;
for (var i = 0; i < xnum; i++)
{
if (Math.atan2(y,x[i]) !== -0)
$ERROR("#1: Math.atan2(" + y + ", " + x[i] + ") !== -0");
assert.sameValue(
Math.atan2(y, x[i]),
-0,
"(-0, " + x[i] + ")"
);
}

View File

@ -7,8 +7,4 @@ es5id: 15.8.2.5_A9
description: Checking if Math.atan2(y,x) is -0, where y is -0 and x is +0
---*/
// CHECK#1
var y = -0;
var x = +0;
if (Math.atan2(y,x) !== -0)
$ERROR("#1: Math.atan2(" + y + ", " + x + ") !== -0");
assert.sameValue(Math.atan2(-0, 0), -0);

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.6_A2
description: Checking if Math.ceil(x) is +0, where x is +0
---*/
// CHECK#1
var x = +0;
if (Math.ceil(x) !== +0)
{
$ERROR("#1: 'var x = +0; Math.ceil(x) !== +0'");
}
assert.sameValue(Math.ceil(0), 0);

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.6_A3
description: Checking if Math.ceil(x) is -0, where x is -0
---*/
// CHECK#1
var x = -0;
if (Math.ceil(x) !== -0)
{
$ERROR("#1: 'var x = -0; Math.ceil(x) !== -0'");
}
assert.sameValue(Math.ceil(-0), -0);

View File

@ -9,23 +9,6 @@ description: >
than -1
---*/
// CHECK#1
var x = -0.000000000000001;
if (Math.ceil(x) !== -0)
{
$ERROR("#1: 'var x = -0.000000000000001; Math.ceil(x) !== -0'");
}
// CHECK#2
var x = -0.999999999999999;
if (Math.ceil(x) !== -0)
{
$ERROR("#2: 'var x = -0.999999999999999; Math.ceil(x) !== -0'");
}
// CHECK#3
var x = -0.5;
if (Math.ceil(x) !== -0)
{
$ERROR("#3: 'var x = -0.5; Math.ceil(x) !== -0'");
}
assert.sameValue(Math.ceil(-0.000000000000001), -0, "-0.000000000000001");
assert.sameValue(Math.ceil(-0.999999999999999), -0, "-0.999999999999999");
assert.sameValue(Math.ceil(-0.5), -0, "-0.5");

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.8_A5
description: Checking if Math.exp(-Infinity) is +0
---*/
// CHECK#1
var x = -Infinity;
if (Math.exp(x) !== +0)
{
$ERROR("#1: 'var x = -Infinity; Math.exp(x) !== +0'");
}
assert.sameValue(Math.exp(-Infinity), 0);

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.9_A2
description: Checking if Math.floor(x) is +0, where x is +0
---*/
// CHECK#1
var x = +0;
if (Math.floor(x) !== +0)
{
$ERROR("#1: 'var x = +0; Math.floor(x) !== +0'");
}
assert.sameValue(Math.floor(0), 0);

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.9_A3
description: Checking if Math.floor(x) is -0, where x is -0
---*/
// CHECK#1
var x = -0;
if (Math.floor(x) !== -0)
{
$ERROR("#1: 'var x = -0; Math.floor(x) !== -0'");
}
assert.sameValue(Math.floor(-0), -0);

View File

@ -9,23 +9,6 @@ description: >
less than 1
---*/
// CHECK#1
var x = 0.000000000000001;
if (Math.floor(x) !== +0)
{
$ERROR("#1: 'var x = 0.000000000000001; Math.floor(x) !== +0'");
}
// CHECK#2
var x = 0.999999999999999;
if (Math.floor(x) !== +0)
{
$ERROR("#2: 'var x = 0.999999999999999; Math.ceil(x) !== +0'");
}
// CHECK#3
var x = 0.5;
if (Math.floor(x) !== +0)
{
$ERROR("#3: 'var x = 0.5; Math.ceil(x) !== +0'");
}
assert.sameValue(Math.floor(0.000000000000001), 0, "0.000000000000001");
assert.sameValue(Math.floor(0.999999999999999), 0, "0.999999999999999");
assert.sameValue(Math.floor(0.5), 0, "0.5");

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.10_A4
description: Checking if Math.log(1) equals to +0
---*/
// CHECK#1
var x = 1;
if (Math.log(x) !== +0)
{
$ERROR("#1: 'var x=1; Math.log(x) !== +0'");
}
assert.sameValue(Math.log(1), 0);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.15_A2
description: Checking if Math.round(x) equals to +0, where x is +0
---*/
// CHECK#1
var x = +0;
if (Math.round(x) !== +0)
{
$ERROR("#1: 'var x=+0; Math.round(x) !== +0'");
}
assert.sameValue(Math.round(0), 0);

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.15_A3
description: Checking if Math.round(x) equals to -0, where x is -0
---*/
// CHECK#1
var x = -0;
if (Math.round(x) !== -0)
{
$ERROR("#1: 'var x=-0; Math.round(x) !== -0'");
}
assert.sameValue(Math.round(-0), -0);

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.16_A3
description: Checking if Math.sin(-0) equals to -0
---*/
// CHECK#1
var x = -0;
if (Math.sin(x) !== -0)
{
$ERROR("#1: 'var x = -0; Math.sin(x) !== -0'");
}
assert.sameValue(Math.sin(-0), -0);

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.17_A3
description: Checking if Math.sqrt(+0) equals to +0
---*/
// CHECK#1
var x = +0;
if (Math.sqrt(x) !== +0)
{
$ERROR("#1: 'var x=+0; Math.sqrt(x) !== +0'");
}
assert.sameValue(Math.sqrt(0), 0);

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.17_A4
description: Checking if Math.sqrt(-0) equals to -0
---*/
// CHECK#1
var x = -0;
if (Math.sqrt(x) !== -0)
{
$ERROR("#1: 'var x=-0; Math.sqrt(x) !== -0'");
}
assert.sameValue(Math.sqrt(-0), -0);

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.18_A2
description: Checking if Math.tan(+0) equals to +0
---*/
// CHECK#1
var x = +0;
if (Math.tan(x) !== +0)
{
$ERROR("#1: 'var x=+0; Math.tan(x) !== +0'");
}
assert.sameValue(Math.tan(0), 0);

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.18_A3
description: Checking if Math.tan(-0) equals to -0
---*/
// CHECK#1
var x = -0;
if (Math.tan(x) !== -0)
{
$ERROR("#1: 'var x=-0; Math.tan(x) !== -0'");
}
assert.sameValue(Math.tan(-0), -0);