Skip to content
Snippets Groups Projects
Unverified Commit 813bb516 authored by Leonardo Balter's avatar Leonardo Balter
Browse files

Remove precision-equivalency tests

Due to specs approximation values, some tests are invalid as the harness
helpers rely on another approximated values as Math.LN2.
parent 91d06f50
No related branches found
No related tags found
No related merge requests found
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
var prec;
function isEqual(num1, num2)
{
if ((num1 === Infinity)&&(num2 === Infinity))
{
return(true);
}
if ((num1 === -Infinity)&&(num2 === -Infinity))
{
return(true);
}
prec = getPrecision(Math.min(Math.abs(num1), Math.abs(num2)));
return(Math.abs(num1 - num2) <= prec);
//return(num1 === num2);
}
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
function getPrecision(num) {
//TODO: Create a table of prec's,
// because using Math for testing Math isn't that correct.
var log2num = Math.log(Math.abs(num)) / Math.LN2;
var pernum = Math.ceil(log2num);
return 2 * Math.pow(2, -52 + pernum);
}
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
If x is +Infinity, Math.atan(x) is an implementation-dependent
approximation to +PI/2
es5id: 15.8.2.4_A4
description: Checking if Math.atan(+Infinity) is an approximation to +PI/2
includes:
- math_precision.js
- math_isequal.js
---*/
// CHECK#1
var x = +Infinity;
if (!isEqual(Math.atan(x),Math.PI/2))
{
$ERROR("#1: '!isEqual(Math.atan(+Infinity), Math.PI/2)'");
}
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: >
If x is -Infinity, Math.atan(x) is an implementation-dependent
approximation to -PI/2
es5id: 15.8.2.4_A5
description: Checking if Math.atan(-Infinity) is an approximation to -PI/2
includes:
- math_precision.js
- math_isequal.js
---*/
// CHECK#1
var x = -Infinity;
if (!isEqual(Math.atan(x), -Math.PI/2))
{
$ERROR("#1: '!isEqual(Math.atan(-Infinity), -Math.PI/2)'");
}
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: Number.MIN_VALUE is approximately 5e-324
es5id: 15.7.3.3_A1
description: Checking Number.MIN_VALUE value
includes:
- math_precision.js
- math_isequal.js
---*/
// CHECK#1
if (!isEqual(Number.MIN_VALUE, 5e-324)) {
$ERROR('#1: Number.MIN_VALUE approximately equal to 5e-324');
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment