Improve assertions comparing values to NaN (#690)

The global isNaN is not precise at all, and Number.isNaN is an ES6 feature that makes it preferrable to use assert's sameValue for NaN values, as it handles it internally using the comparison.
This commit is contained in:
Leo Balter 2016-07-01 15:22:55 -03:00 committed by Tom Care
parent a3fffa754b
commit e49d2661a8
113 changed files with 397 additions and 1064 deletions

View File

@ -19,9 +19,7 @@ if (obj.join() !== "") {
}
//CHECK#2
if (isNaN(obj.length) !== true) {
$ERROR('#2: var obj = {}; obj.length = NaN; obj.join = Array.prototype.join; obj.join(); obj.length === Not-a-Number. Actual: ' + (obj.length));
}
assert.sameValue(obj.length, NaN, "obj.length is NaN");
//CHECK#5
obj.length = Number.NEGATIVE_INFINITY;

View File

@ -13,50 +13,39 @@ function DateValue(year, month, date, hours, minutes, seconds, ms){
return new Date(year, month, date, hours, minutes, seconds, ms).valueOf();
}
if (!isNaN(DateValue(1899, 11))) {
$ERROR("#1: The value should be NaN");
}
var x;
x = DateValue(1899, 11);
assert.sameValue(x, NaN, "(1899, 11)");
if (!isNaN(DateValue(1899, 12))) {
$ERROR("#2: The value should be NaN");
}
x = DateValue(1899, 12);
assert.sameValue(x, NaN, "(1899, 12)");
if (!isNaN(DateValue(1900, 0))) {
$ERROR("#3: The value should be NaN");
}
x = DateValue(1900, 0);
assert.sameValue(x, NaN, "(1900, 0)");
if (!isNaN(DateValue(1969, 11))) {
$ERROR("#4: The value should be NaN");
}
x = DateValue(1969, 11);
assert.sameValue(x, NaN, "(1969, 11)");
if (!isNaN(DateValue(1969, 12))) {
$ERROR("#5: The value should be NaN");
}
x = DateValue(1969, 12);
assert.sameValue(x, NaN, "(1969, 12)");
if (!isNaN(DateValue(1970, 0))) {
$ERROR("#6: The value should be NaN");
}
x = DateValue(1970, 0);
assert.sameValue(x, NaN, "(1970, 0)");
if (!isNaN(DateValue(1999, 11))) {
$ERROR("#7: The value should be NaN");
}
x = DateValue(1999, 11);
assert.sameValue(x, NaN, "(1999, 11)");
if (!isNaN(DateValue(1999, 12))) {
$ERROR("#8: The value should be NaN");
}
x = DateValue(1999, 12);
assert.sameValue(x, NaN, "(1999, 12)");
if (!isNaN(DateValue(2000, 0))) {
$ERROR("#9: The value should be NaN");
}
x = DateValue(2000, 0);
assert.sameValue(x, NaN, "(2000, 0)");
if (!isNaN(DateValue(2099, 11))) {
$ERROR("#10: The value should be NaN");
}
x = DateValue(2099, 11);
assert.sameValue(x, NaN, "(2099, 11)");
if (!isNaN(DateValue(2099, 12))) {
$ERROR("#11: The value should be NaN");
}
x = DateValue(2099, 12);
assert.sameValue(x, NaN, "(2099, 12)");
if (!isNaN(DateValue(2100, 0))) {
$ERROR("#12: The value should be NaN");
}
x = DateValue(2100, 0);
assert.sameValue(x, NaN, "(2100, 0)");

View File

@ -13,50 +13,39 @@ function DateValue(year, month, date, hours, minutes, seconds, ms){
return new Date(year, month, date, hours, minutes, seconds, ms).valueOf();
}
if (!isNaN(DateValue(1899, 11, 31))) {
$ERROR("#1: The value should be NaN");
}
var x;
x = DateValue(1899, 11, 31);
assert.sameValue(x, NaN, "(1899, 11, 31)");
if (!isNaN(DateValue(1899, 12, 1))) {
$ERROR("#2: The value should be NaN");
}
x = DateValue(1899, 12, 1);
assert.sameValue(x, NaN, "(1899, 12, 1)");
if (!isNaN(DateValue(1900, 0, 1))) {
$ERROR("#3: The value should be NaN");
}
x = DateValue(1900, 0, 1);
assert.sameValue(x, NaN, "(1900, 0, 1)");
if (!isNaN(DateValue(1969, 11, 31))) {
$ERROR("#4: The value should be NaN");
}
x = DateValue(1969, 11, 31);
assert.sameValue(x, NaN, "(1969, 11, 31)");
if (!isNaN(DateValue(1969, 12, 1))) {
$ERROR("#5: The value should be NaN");
}
x = DateValue(1969, 12, 1);
assert.sameValue(x, NaN, "(1969, 12, 1)");
if (!isNaN(DateValue(1970, 0, 1))) {
$ERROR("#6: The value should be NaN");
}
x = DateValue(1970, 0, 1);
assert.sameValue(x, NaN, "(1970, 0, 1)");
if (!isNaN(DateValue(1999, 11, 31))) {
$ERROR("#7: The value should be NaN");
}
x = DateValue(1999, 11, 31);
assert.sameValue(x, NaN, "(1999, 11, 31)");
if (!isNaN(DateValue(1999, 12, 1))) {
$ERROR("#8: The value should be NaN");
}
x = DateValue(1999, 12, 1);
assert.sameValue(x, NaN, "(1999, 12, 1)");
if (!isNaN(DateValue(2000, 0, 1))) {
$ERROR("#9: The value should be NaN");
}
x = DateValue(2000, 0, 1);
assert.sameValue(x, NaN, "(2000, 0, 1)");
if (!isNaN(DateValue(2099, 11, 31))) {
$ERROR("#10: The value should be NaN");
}
x = DateValue(2099, 11, 31);
assert.sameValue(x, NaN, "(2099, 11, 31)");
if (!isNaN(DateValue(2099, 12, 1))) {
$ERROR("#11: The value should be NaN");
}
x = DateValue(2099, 12, 1);
assert.sameValue(x, NaN, "(2099, 12, 1)");
if (!isNaN(DateValue(2100, 0, 1))) {
$ERROR("#12: The value should be NaN");
}
x = DateValue(2100, 0, 1);
assert.sameValue(x, NaN, "(2100, 0, 1)");

View File

@ -13,50 +13,39 @@ function DateValue(year, month, date, hours, minutes, seconds, ms){
return new Date(year, month, date, hours, minutes, seconds, ms).valueOf();
}
if (!isNaN(DateValue(1899, 11, 31, 23))) {
$ERROR("#1: The value should be NaN");
}
var x;
x = DateValue(1899, 11, 31, 23);
assert.sameValue(x, NaN, "(1899, 11, 31, 23)");
if (!isNaN(DateValue(1899, 12, 1, 0))) {
$ERROR("#2: The value should be NaN");
}
x = DateValue(1899, 12, 1, 0);
assert.sameValue(x, NaN, "(1899, 12, 1, 0)");
if (!isNaN(DateValue(1900, 0, 1, 0))) {
$ERROR("#3: The value should be NaN");
}
x = DateValue(1900, 0, 1, 0);
assert.sameValue(x, NaN, "(1900, 0, 1, 0)");
if (!isNaN(DateValue(1969, 11, 31, 23))) {
$ERROR("#4: The value should be NaN");
}
x = DateValue(1969, 11, 31, 23);
assert.sameValue(x, NaN, "(1969, 11, 31, 23)");
if (!isNaN(DateValue(1969, 12, 1, 0))) {
$ERROR("#5: The value should be NaN");
}
x = DateValue(1969, 12, 1, 0);
assert.sameValue(x, NaN, "(1969, 12, 1, 0)");
if (!isNaN(DateValue(1970, 0, 1, 0))) {
$ERROR("#6: The value should be NaN");
}
x = DateValue(1970, 0, 1, 0);
assert.sameValue(x, NaN, "(1970, 0, 1, 0)");
if (!isNaN(DateValue(1999, 11, 31, 23))) {
$ERROR("#7: The value should be NaN");
}
x = DateValue(1999, 11, 31, 23);
assert.sameValue(x, NaN, "(1999, 11, 31, 23)");
if (!isNaN(DateValue(1999, 12, 1, 0))) {
$ERROR("#8: The value should be NaN");
}
x = DateValue(1999, 12, 1, 0);
assert.sameValue(x, NaN, "(1999, 12, 1, 0)");
if (!isNaN(DateValue(2000, 0, 1, 0))) {
$ERROR("#9: The value should be NaN");
}
x = DateValue(2000, 0, 1, 0);
assert.sameValue(x, NaN, "(2000, 0, 1, 0)");
if (!isNaN(DateValue(2099, 11, 31, 23))) {
$ERROR("#10: The value should be NaN");
}
x = DateValue(2099, 11, 31, 23);
assert.sameValue(x, NaN, "(2099, 11, 31, 23)");
if (!isNaN(DateValue(2099, 12, 1, 0))) {
$ERROR("#11: The value should be NaN");
}
x = DateValue(2099, 12, 1, 0);
assert.sameValue(x, NaN, "(2099, 12, 1, 0)");
if (!isNaN(DateValue(2100, 0, 1, 0))) {
$ERROR("#12: The value should be NaN");
}
x = DateValue(2100, 0, 1, 0);
assert.sameValue(x, NaN, "(2100, 0, 1, 0)");

View File

@ -13,50 +13,39 @@ function DateValue(year, month, date, hours, minutes, seconds, ms){
return new Date(year, month, date, hours, minutes, seconds, ms).valueOf();
}
if (!isNaN(DateValue(1899, 11, 31, 23, 59))) {
$ERROR("#1: The value should be NaN");
}
var x;
x = DateValue(1899, 11, 31, 23, 59);
assert.sameValue(x, NaN, "(1899, 11, 31, 23, 59)");
if (!isNaN(DateValue(1899, 12, 1, 0, 0))) {
$ERROR("#2: The value should be NaN");
}
x = DateValue(1899, 12, 1, 0, 0);
assert.sameValue(x, NaN, "(1899, 12, 1, 0, 0)");
if (!isNaN(DateValue(1900, 0, 1, 0, 0))) {
$ERROR("#3: The value should be NaN");
}
x = DateValue(1900, 0, 1, 0, 0);
assert.sameValue(x, NaN, "(1900, 0, 1, 0, 0)");
if (!isNaN(DateValue(1969, 11, 31, 23, 59))) {
$ERROR("#4: The value should be NaN");
}
x = DateValue(1969, 11, 31, 23, 59);
assert.sameValue(x, NaN, "(1969, 11, 31, 23, 59)");
if (!isNaN(DateValue(1969, 12, 1, 0, 0))) {
$ERROR("#5: The value should be NaN");
}
x = DateValue(1969, 12, 1, 0, 0);
assert.sameValue(x, NaN, "(1969, 12, 1, 0, 0)");
if (!isNaN(DateValue(1970, 0, 1, 0, 0))) {
$ERROR("#6: The value should be NaN");
}
x = DateValue(1970, 0, 1, 0, 0);
assert.sameValue(x, NaN, "(1970, 0, 1, 0, 0)");
if (!isNaN(DateValue(1999, 11, 31, 23, 59))) {
$ERROR("#7: The value should be NaN");
}
x = DateValue(1999, 11, 31, 23, 59);
assert.sameValue(x, NaN, "(1999, 11, 31, 23, 59)");
if (!isNaN(DateValue(1999, 12, 1, 0, 0))) {
$ERROR("#8: The value should be NaN");
}
x = DateValue(1999, 12, 1, 0, 0);
assert.sameValue(x, NaN, "(1999, 12, 1, 0, 0)");
if (!isNaN(DateValue(2000, 0, 1, 0, 0))) {
$ERROR("#9: The value should be NaN");
}
x = DateValue(2000, 0, 1, 0, 0);
assert.sameValue(x, NaN, "(2000, 0, 1, 0, 0)");
if (!isNaN(DateValue(2099, 11, 31, 23, 59))) {
$ERROR("#10: The value should be NaN");
}
x = DateValue(2099, 11, 31, 23, 59);
assert.sameValue(x, NaN, "(2099, 11, 31, 23, 59)");
if (!isNaN(DateValue(2099, 12, 1, 0, 0))) {
$ERROR("#11: The value should be NaN");
}
x = DateValue(2099, 12, 1, 0, 0);
assert.sameValue(x, NaN, "(2099, 12, 1, 0, 0)");
if (!isNaN(DateValue(2100, 0, 1, 0, 0))) {
$ERROR("#12: The value should be NaN");
}
x = DateValue(2100, 0, 1, 0, 0);
assert.sameValue(x, NaN, "(2100, 0, 1, 0, 0)");

View File

@ -13,50 +13,39 @@ function DateValue(year, month, date, hours, minutes, seconds, ms){
return new Date(year, month, date, hours, minutes, seconds, ms).valueOf();
}
if (!isNaN(DateValue(1899, 11, 31, 23, 59, 59))) {
$ERROR("#1: The value should be NaN");
}
var x;
x = DateValue(1899, 11, 31, 23, 59, 59);
assert.sameValue(x, NaN, "(1899, 11, 31, 23, 59, 59)");
if (!isNaN(DateValue(1899, 12, 1, 0, 0, 0))) {
$ERROR("#2: The value should be NaN");
}
x = DateValue(1899, 12, 1, 0, 0, 0);
assert.sameValue(x, NaN, "(1899, 12, 1, 0, 0, 0)");
if (!isNaN(DateValue(1900, 0, 1, 0, 0, 0))) {
$ERROR("#3: The value should be NaN");
}
x = DateValue(1900, 0, 1, 0, 0, 0);
assert.sameValue(x, NaN, "(1900, 0, 1, 0, 0, 0)");
if (!isNaN(DateValue(1969, 11, 31, 23, 59, 59))) {
$ERROR("#4: The value should be NaN");
}
x = DateValue(1969, 11, 31, 23, 59, 59);
assert.sameValue(x, NaN, "(1969, 11, 31, 23, 59, 59)");
if (!isNaN(DateValue(1969, 12, 1, 0, 0, 0))) {
$ERROR("#5: The value should be NaN");
}
x = DateValue(1969, 12, 1, 0, 0, 0);
assert.sameValue(x, NaN, "(1969, 12, 1, 0, 0, 0)");
if (!isNaN(DateValue(1970, 0, 1, 0, 0, 0))) {
$ERROR("#6: The value should be NaN");
}
x = DateValue(1970, 0, 1, 0, 0, 0);
assert.sameValue(x, NaN, "(1970, 0, 1, 0, 0, 0)");
if (!isNaN(DateValue(1999, 11, 31, 23, 59, 59))) {
$ERROR("#7: The value should be NaN");
}
x = DateValue(1999, 11, 31, 23, 59, 59);
assert.sameValue(x, NaN, "(1999, 11, 31, 23, 59, 59)");
if (!isNaN(DateValue(1999, 12, 1, 0, 0, 0))) {
$ERROR("#8: The value should be NaN");
}
x = DateValue(1999, 12, 1, 0, 0, 0);
assert.sameValue(x, NaN, "(1999, 12, 1, 0, 0, 0)");
if (!isNaN(DateValue(2000, 0, 1, 0, 0, 0))) {
$ERROR("#9: The value should be NaN");
}
x = DateValue(2000, 0, 1, 0, 0, 0);
assert.sameValue(x, NaN, "(2000, 0, 1, 0, 0, 0)");
if (!isNaN(DateValue(2099, 11, 31, 23, 59, 59))) {
$ERROR("#10: The value should be NaN");
}
x = DateValue(2099, 11, 31, 23, 59, 59);
assert.sameValue(x, NaN, "(2099, 11, 31, 23, 59, 59)");
if (!isNaN(DateValue(2099, 12, 1, 0, 0, 0))) {
$ERROR("#11: The value should be NaN");
}
x = DateValue(2099, 12, 1, 0, 0, 0);
assert.sameValue(x, NaN, "(2099, 12, 1, 0, 0, 0)");
if (!isNaN(DateValue(2100, 0, 1, 0, 0, 0))) {
$ERROR("#12: The value should be NaN");
}
x = DateValue(2100, 0, 1, 0, 0, 0);
assert.sameValue(x, NaN, "(2100, 0, 1, 0, 0, 0)");

View File

@ -13,21 +13,15 @@ description: >
// CHECK#1
var d1 = new Date(Number.NaN);
if (!isNaN(d1.valueOf())) {
$ERROR('#1: var d1 = new Date(Number.NaN); d1.valueOf() === Number.NaN;');
}
assert.sameValue(d1.valueOf(), NaN, "NaN");
// CHECK#2
var d2 = new Date(Infinity);
if (!isNaN(d2.valueOf())) {
$ERROR('#2: var d2 = new Date(Infinity); d2.valueOf() === Number.NaN;');
}
assert.sameValue(d2.valueOf(), NaN, "Infinity");
// CHECK#3
var d3 = new Date(-Infinity);
if (!isNaN(d3.valueOf())) {
$ERROR('#3: var d3 = new Date(-Infinity); d3.valueOf() === Number.NaN;');
}
assert.sameValue(d3.valueOf(), NaN, "-Infinity");
// CHECK#4
var d4 = new Date(0);

View File

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

View File

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

View File

@ -7,23 +7,6 @@ es5id: 15.8.2.2_A2
description: Checking if Math.acos(x) is NaN, where x is greater than 1
---*/
// CHECK#1
var x = 1.000000000000001;
if (!isNaN(Math.acos(x)))
{
$ERROR("#1: 'var x = 1.000000000000001; isNaN(Math.acos(x)) === false'");
}
// CHECK#2
x = 2;
if (!isNaN(Math.acos(x)))
{
$ERROR("#2: 'x = 2; isNaN(Math.acos(x)) === false'");
}
// CHECK#3
x = +Infinity;
if (!isNaN(Math.acos(x)))
{
$ERROR("#3: 'x = +Infinity; isNaN(Math.acos(x)) === false'");
}
assert.sameValue(Math.acos(1.000000000000001), NaN, "1.000000000000001");
assert.sameValue(Math.acos(2), NaN, "2");
assert.sameValue(Math.acos(Infinity), NaN, "Infinity");

View File

@ -7,23 +7,6 @@ es5id: 15.8.2.2_A3
description: Checking if Math.acos(x) is NaN, where x is less than -1
---*/
// CHECK#1
var x = -1.000000000000001;
if (!isNaN(Math.acos(x)))
{
$ERROR("#1: 'var x = -1.000000000000001; isNaN(Math.acos(x)) === false'");
}
// CHECK#2
x = -2;
if (!isNaN(Math.acos(x)))
{
$ERROR("#2: 'x = -2; isNaN(Math.acos(x)) === false'");
}
// CHECK#3
x = -Infinity;
if (!isNaN(Math.acos(x)))
{
$ERROR("#3: 'x = -Infinity; isNaN(Math.acos(x)) === false'");
}
assert.sameValue(Math.acos(-1.000000000000001), NaN, "-1.000000000000001");
assert.sameValue(Math.acos(-2), NaN, "-2");
assert.sameValue(Math.acos(-Infinity), NaN, "-Infinity");

View File

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

View File

@ -7,23 +7,6 @@ es5id: 15.8.2.3_A2
description: Checking if Math.asin(x) is NaN, where x is greater than 1
---*/
// CHECK#1
var x = 1.000000000000001;
if (!isNaN(Math.asin(x)))
{
$ERROR("#1: 'var x = 1.000000000000001; isNaN(Math.asin(x)) === false'");
}
// CHECK#2
x = 2;
if (!isNaN(Math.asin(x)))
{
$ERROR("#2: 'x = 2; isNaN(Math.asin(x)) === false'");
}
// CHECK#3
x = +Infinity;
if (!isNaN(Math.asin(x)))
{
$ERROR("#3: 'x = +Infinity; isNaN(Math.asin(x)) === false'");
}
assert.sameValue(Math.asin(1.000000000000001), NaN, "1.000000000000001");
assert.sameValue(Math.asin(2), NaN, "2");
assert.sameValue(Math.asin(Infinity), NaN, "Infinity");

View File

@ -7,23 +7,6 @@ es5id: 15.8.2.3_A3
description: Checking if Math.asin(x) is NaN, where x is less than -1
---*/
// CHECK#1
var x = -1.000000000000001;
if (!isNaN(Math.asin(x)))
{
$ERROR("#1: 'var x = -1.000000000000001; isNaN(Math.asin(x)) === false'");
}
// CHECK#2
x = -2;
if (!isNaN(Math.asin(x)))
{
$ERROR("#2: 'x = -2; isNaN(Math.asin(x)) === false'");
}
// CHECK#3
x = -Infinity;
if (!isNaN(Math.asin(x)))
{
$ERROR("#3: 'x = -Infinity; isNaN(Math.asin(x)) === false'");
}
assert.sameValue(Math.asin(-1.000000000000001), NaN, "-1.000000000000001");
assert.sameValue(Math.asin(-2), NaN, "-2");
assert.sameValue(Math.asin(-Infinity), NaN, "-Infinity");

View File

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

View File

@ -28,9 +28,10 @@ for (var i = 0; i < 2; i++)
for (var j = 0; j < valnum; j++)
{
args[1-i] = vals[j];
if (!isNaN(Math.atan2(args[0], args[1])))
{
$ERROR("#1: isNaN(Math.atan2(" + args[0] + ", " + args[1] + ")) === false'");
}
assert.sameValue(
Math.atan2(args[0], args[1]),
NaN,
"(" + args[0] + ", " + args[1] + ")"
);
}
}

View File

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

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.7_A1
description: Checking if Math.cos(NaN) is NaN
---*/
// CHECK#1
var x = NaN;
if (!isNaN(Math.cos(x)))
{
$ERROR("#1: 'var x=NaN; isNaN(Math.cos(x)) === false'");
}
assert.sameValue(Math.cos(NaN), NaN);

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.7_A4
description: Checking if Math.cos(+Infinity) is NaN
---*/
// CHECK#1
var x = +Infinity;
if (!isNaN(Math.cos(x)))
{
$ERROR("#1: 'var x = +Infinity; isNaN(Math.cos(x)) === false'");
}
assert.sameValue(Math.cos(Infinity), NaN);

View File

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

View File

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

View File

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

View File

@ -7,4 +7,4 @@ author: Ryan Lewis
description: Math.fround should return NaN if called with NaN.
---*/
assert(Number.isNaN(Math.fround(NaN)), 'Number.isNaN(Math.fround(NaN)) !== true');
assert.sameValue(Math.fround(NaN), NaN);

View File

@ -9,4 +9,4 @@ description: >
NaN.
---*/
assert(Number.isNaN(Math.hypot(NaN, 3)), 'Number.isNaN(Math.hypot(NaN, 3)) !== true');
assert.sameValue(Math.hypot(NaN, 3), NaN);

View File

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

View File

@ -7,23 +7,6 @@ es5id: 15.8.2.10_A2
description: Checking if Math.log(x) is NaN, where x is less than 0
---*/
// CHECK#1
var x = -0.000000000000001;
if (!isNaN(Math.log(x)))
{
$ERROR("#1: 'var x=-0.000000000000001; isNaN(Math.log(x)) === false'");
}
// CHECK#2
x = -1;
if (!isNaN(Math.log(x)))
{
$ERROR("#1: 'var x=-1; isNaN(Math.log(x)) === false'");
}
// CHECK#3
x = -Infinity;
if (!isNaN(Math.log(x)))
{
$ERROR("#1: 'var x=-Infinity; isNaN(Math.log(x)) === false'");
}
assert.sameValue(Math.log(-0.000000000000001), NaN, "-0.000000000000001");
assert.sameValue(Math.log(-1), NaN, "-1");
assert.sameValue(Math.log(-Infinity), NaN, "-Infinity");

View File

@ -6,4 +6,4 @@ es5id: 15.8.2.11-1
description: Math.max({}) is NaN
---*/
assert(isNaN(Math.max({})), 'isNaN(Math.max({})) !== true');
assert.sameValue(Math.max({}), NaN);

View File

@ -9,11 +9,7 @@ description: >
function where at least one of the arguments is NaN
---*/
// CHECK#1
if (!isNaN(Math.max(NaN)))
{
$ERROR("#1: 'isNaN(Math.max(NaN)) === false");
}
assert.sameValue(Math.max(NaN), NaN, "NaN");
// CHECK#2
var vals = new Array();
@ -33,10 +29,11 @@ for (var i = 0; i <= 1; i++)
for (var j = 0; j < valnum; j++)
{
args[1-i] = vals[j];
if (!isNaN(Math.max(args[0], args[1])))
{
$ERROR("#2: 'isNaN(Math.max(" + args[0] + ", " + args[1] + ")) === false");
}
assert.sameValue(
Math.max(args[0], args[1]),
NaN,
"max(" + args[0] + ", " + args[1] + ")"
);
}
}
@ -59,10 +56,11 @@ for (var i = 0; i <= 2; i++)
{
args[k] = vals[j];
args[l] = vals[jj];
if (!isNaN(Math.max(args[0], args[1], args[2])))
{
$ERROR("#3: 'isNaN(Math.max(" + args[0] + ", " + args[1] + ", " + args[2] + ")) === false");
}
assert.sameValue(
Math.max(args[0], args[1], args[2]),
NaN,
"max(" + args[0] + ", " + args[1] + ", " + args[2] + ")"
);
}
}
}

View File

@ -6,4 +6,4 @@ es5id: 15.8.2.12-1
description: Math.min({}) is NaN
---*/
assert(isNaN(Math.min({})), 'isNaN(Math.min({})) !== true');
assert.sameValue(Math.min({}), NaN);

View File

@ -10,10 +10,7 @@ description: >
---*/
// CHECK#1
if (!isNaN(Math.min(NaN)))
{
$ERROR("#1: 'isNaN(Math.min(NaN)) === false");
}
assert.sameValue(Math.min(NaN), NaN, "NaN");
// CHECK#2
var vals = new Array();
@ -33,10 +30,11 @@ for (var i = 0; i <= 1; i++)
for (var j = 0; j < valnum; j++)
{
args[1-i] = vals[j];
if (!isNaN(Math.min(args[0], args[1])))
{
$ERROR("#2: 'isNaN(Math.min(" + args[0] + ", " + args[1] + ")) === false");
}
assert.sameValue(
Math.min(args[0], args[1]),
NaN,
"min(" + args[0] + ", " + args[1] + ")"
);
}
}
@ -59,10 +57,11 @@ for (var i = 0; i <= 2; i++)
{
args[k] = vals[j];
args[l] = vals[jj];
if (!isNaN(Math.min(args[0], args[1], args[2])))
{
$ERROR("#3: 'isNaN(Math.min(" + args[0] + ", " + args[1] + ", " + args[2] + ")) === false");
}
assert.sameValue(
Math.min(args[0], args[1], args[2]),
NaN,
"min(" + args[0] + ", " + args[1] + ", " + args[2] + ")"
);
}
}
}

View File

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

View File

@ -26,7 +26,12 @@ exponent[7] = Math.PI;
var exponentnum = 8;
for (var i = 0; i < basenum; i++)
for (var j = 0; j < exponentnum; j++)
if (!isNaN(Math.pow(base[i],exponent[j])))
$ERROR("#1: isNaN(Math.pow(" + base[i] + ", " + exponent[j] + ")) === false");
for (var i = 0; i < basenum; i++) {
for (var j = 0; j < exponentnum; j++) {
assert.sameValue(
Math.pow(base[i], exponent[j]),
NaN,
"(" + base[i] + ", " + exponent[j] + ")"
);
}
}

View File

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

View File

@ -15,8 +15,9 @@ var basenum = 2;
for (var i = 0; i < basenum; i++)
{
if (!isNaN(Math.pow(base[i],exponent)))
{
$ERROR("#1: isNaN(Math.pow(" + base[i] + ", " + exponent + ")) === false");
}
assert.sameValue(
Math.pow(base[i], exponent),
NaN,
"(" + base[i] + ", " + exponent + ")"
);
}

View File

@ -15,8 +15,9 @@ var basenum = 2;
for (var i = 0; i < basenum; i++)
{
if (!isNaN(Math.pow(base[i],exponent)))
{
$ERROR("#1: isNaN(Math.pow(" + base[i] + ", " + exponent + ")) === false");
}
assert.sameValue(
Math.pow(base[i], exponent),
NaN,
"(" + base[i] + ", " + exponent + ")"
);
}

View File

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

View File

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

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.16_A4
description: Checking if Math.sin(+Infinity) is NaN
---*/
// CHECK#1
var x = +Infinity;
if (!isNaN(Math.sin(x)))
{
$ERROR("#1: 'var x = +Infinity; isNaN(Math.sin(x)) === false'");
}
assert.sameValue(Math.sin(Infinity), NaN);

View File

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

View File

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

View File

@ -7,23 +7,6 @@ es5id: 15.8.2.17_A2
description: Checking if Math.sqrt(x) is NaN, where x is less than 0
---*/
// CHECK#1
var x = -0.000000000000001;
if (!isNaN(Math.sqrt(x)))
{
$ERROR("#1: 'var x=-0.000000000000001; isNaN(Math.sqrt(x)) === false'");
}
// CHECK#2
var x = -1;
if (!isNaN(Math.sqrt(x)))
{
$ERROR("#2: 'var x=-1; isNaN(Math.sqrt(x)) === false'");
}
// CHECK#3
var x = -Infinity;
if (!isNaN(Math.sqrt(x)))
{
$ERROR("#3: 'var x=-Infinity; isNaN(Math.sqrt(x)) === false'");
}
assert.sameValue(Math.sqrt(-0.000000000000001), NaN, "-0.000000000000001");
assert.sameValue(Math.sqrt(-1), NaN, "-1");
assert.sameValue(Math.sqrt(-Infinity), NaN, "-Infinity");

View File

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

View File

@ -7,9 +7,4 @@ es5id: 15.8.2.18_A4
description: Checking if Math.tan(+Infinity) is NaN
---*/
// CHECK#1
var x = +Infinity;
if (!isNaN(Math.tan(x)))
{
$ERROR("#1: 'var x=+Infinity; isNaN(Math.tan(x)) === false'");
}
assert.sameValue(Math.tan(Infinity), NaN);

View File

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

View File

@ -7,4 +7,4 @@ author: Ryan Lewis
description: Math.trunc should return NaN when called with NaN.
---*/
assert(Number.isNaN(Math.trunc(NaN)), 'Number.isNaN(Math.trunc(NaN)) !== true');
assert.sameValue(Math.trunc(NaN), NaN);

View File

@ -2,22 +2,8 @@
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: The initial value of NaN is NaN
es5id: 15.1.1.1_A1
description: Use typeof, isNaN, isFinite
description: The initial value of NaN is NaN
---*/
// CHECK#1
if (typeof(NaN) !== "number") {
$ERROR('#1: typeof(NaN) === "number". Actual: ' + (typeof(NaN)));
}
// CHECK#2
if (isNaN(NaN) !== true) {
$ERROR('#2: NaN === Not-a-Number. Actual: ' + (NaN));
}
// CHECK#3
if (isFinite(NaN) !== false) {
$ERROR('#3: NaN === Not-a-Finite. Actual: ' + (NaN));
}
assert(NaN !== NaN);

View File

@ -30,11 +30,4 @@ if( typeof Number(new Object(10)) !== "number" ) {
}
//CHECK #5
if( typeof Number("abc") !== "number" ) {
$ERROR('#5: typeof Number("abc") should be "number", actual is "'+typeof Number("abc")+'"');
}
//CHECK #6
if( !isNaN(Number("abc"))) {
$ERROR('#6: Number("abc")) should be NaN');
}
assert.sameValue(Number("abc"), NaN, "Number('abc')");

View File

@ -7,17 +7,4 @@ es5id: 9.3_A1_T1
description: Undefined convert to Number by explicit transformation
---*/
// CHECK#1
if (isNaN(Number(undefined)) !== true) {
$ERROR('#1: Number(undefined) === Not-a-Number. Actual: ' + (Number(undefined)));
}
// CHECK#2
if (isNaN(Number(void 0)) !== true) {
$ERROR('#2: Number(void 0) === Not-a-Number. Actual: ' + (Number(void 0)));
}
// CHECK#3
if (isNaN(Number(eval("var x"))) !== true) {
$ERROR('#3: Number(eval("var x")) === Not-a-Number. Actual: ' + (Number(eval("var x"))));
}
assert.sameValue(Number(undefined), NaN);

View File

@ -13,44 +13,42 @@ description: >
---*/
// CHECK#1
if (isNaN(Number(Number.NaN)) !== true) {
$ERROR('#1: Number(NaN) === Not-a-Number. Actual: ' + (Number(NaN)));
}
assert.sameValue(Number(NaN), NaN, "NaN");
// CHECK#2
if (Number(+0) !== +0) {
$ERROR('#2.1: Number(+0) === 0. Actual: ' + (Number(+0)));
$ERROR('#2.1: Number(+0) === 0. Actual: ' + (Number(+0)));
} else {
if (1/Number(+0) !== Number.POSITIVE_INFINITY) {
$ERROR('#2.2: Number(+0) === +0. Actual: -0');
}
}
}
// CHECK#3
if (Number(-0) !== -0) {
$ERROR('#3.1: Number(-0) === 0. Actual: ' + (Number(-0)));
$ERROR('#3.1: Number(-0) === 0. Actual: ' + (Number(-0)));
} else {
if (1/Number(-0) !== Number.NEGATIVE_INFINITY) {
$ERROR('#3.2: Number(-0) === -0. Actual: +0');
}
}
}
// CHECK#4
if (Number(Number.POSITIVE_INFINITY) !== Number.POSITIVE_INFINITY) {
$ERROR('#4: Number(+Infinity) === +Infinity. Actual: ' + (Number(+Infinity)));
$ERROR('#4: Number(+Infinity) === +Infinity. Actual: ' + (Number(+Infinity)));
}
// CHECK#5
if (Number(Number.NEGATIVE_INFINITY) !== Number.NEGATIVE_INFINITY) {
$ERROR('#5: Number(-Infinity) === -Infinity. Actual: ' + (Number(-Infinity)));
$ERROR('#5: Number(-Infinity) === -Infinity. Actual: ' + (Number(-Infinity)));
}
// CHECK#6
if (Number(Number.MAX_VALUE) !== Number.MAX_VALUE) {
$ERROR('#6: Number(Number.MAX_VALUE) === Number.MAX_VALUE. Actual: ' + (Number(Number.MAX_VALUE)));
$ERROR('#6: Number(Number.MAX_VALUE) === Number.MAX_VALUE. Actual: ' + (Number(Number.MAX_VALUE)));
}
// CHECK#7
if (Number(Number.MIN_VALUE) !== Number.MIN_VALUE) {
$ERROR('#7: Number(Number.MIN_VALUE) === Number.MIN_VALUE. Actual: ' + (Number(Number.MIN_VALUE)));
$ERROR('#7: Number(Number.MIN_VALUE) === Number.MIN_VALUE. Actual: ' + (Number(Number.MIN_VALUE)));
}

View File

@ -23,23 +23,19 @@ if (Number(new Number(0)) !== 0) {
}
// CHECK#3
if (isNaN(Number(new Number(Number.NaN)) !== true)) {
$ERROR('#3: Number(new Number(Number.NaN)) === Not-a-Number. Actual: ' + (Number(new Number(Number.NaN))));
}
assert.sameValue(Number(new Number(NaN)), NaN, "Number(new Number(NaN)");
// CHECK#4
if (Number(new Number(null)) !== 0) {
$ERROR('#4.1: Number(new Number(null)) === 0. Actual: ' + (Number(new Number(null))));
$ERROR('#4.1: Number(new Number(null)) === 0. Actual: ' + (Number(new Number(null))));
} else {
if (1/Number(new Number(null)) !== Number.POSITIVE_INFINITY) {
$ERROR('#4.2: Number(new Number(null)) === +0. Actual: -0');
}
}
}
// CHECK#5
if (isNaN(Number(new Number(void 0)) !== true)) {
$ERROR('#5: Number(new Number(void 0)) === Not-a-Number. Actual: ' + (Number(new Number(void 0))));
}
assert.sameValue(Number(new Number(void 0)), NaN, "Number(new Number(void 0)");
// CHECK#6
if (Number(new Number(true)) !== 1) {
@ -70,26 +66,22 @@ if (Number(new Boolean(false)) !== +0) {
}
// CHECK#10
if (isNaN(Number(new Array(2,4,8,16,32))) !== true) {
$ERROR('#10: Number(new Array(2,4,8,16,32)) === Not-a-Number. Actual: ' + (Number(new Array(2,4,8,16,32))));
}
assert.sameValue(Number(new Array(2,4,8,16,32)), NaN, "Number(new Array(2,4,8,16,32))");
// CHECK#11
var myobj1 = {
ToNumber : function(){return 12345;},
ToNumber : function(){return 12345;},
toString : function(){return "67890";},
valueOf : function(){return "[object MyObj]";}
valueOf : function(){return "[object MyObj]";}
};
if (isNaN(Number(myobj1)) !== true){
$ERROR("#11: Number(myobj1) calls ToPrimitive with hint Number. Actual: " + (Number(myobj1)));
}
assert.sameValue(Number(myobj1), NaN, "Number(myobj1)");
// CHECK#12
var myobj2 = {
ToNumber : function(){return 12345;},
ToNumber : function(){return 12345;},
toString : function(){return "67890";},
valueOf : function(){return "9876543210";}
valueOf : function(){return "9876543210";}
};
if (Number(myobj2) !== 9876543210){
@ -99,18 +91,16 @@ if (Number(myobj2) !== 9876543210){
// CHECK#13
var myobj3 = {
ToNumber : function(){return 12345;},
toString : function(){return "[object MyObj]";}
ToNumber : function(){return 12345;},
toString : function(){return "[object MyObj]";}
};
if (isNaN(Number(myobj3)) !== true){
$ERROR("#13: Number(myobj3) calls ToPrimitive with hint Number. Exptected: Not-a-Number. Actual: " + (Number(myobj3)));
}
assert.sameValue(Number(myobj3), NaN, "Number(myobj3)");
// CHECK#14
var myobj4 = {
ToNumber : function(){return 12345;},
toString : function(){return "67890";}
ToNumber : function(){return 12345;},
toString : function(){return "67890";}
};
if (Number(myobj4) !== 67890){
@ -119,9 +109,7 @@ if (Number(myobj4) !== 67890){
// CHECK#15
var myobj5 = {
ToNumber : function(){return 12345;}
ToNumber : function(){return 12345;}
};
if (isNaN(Number(myobj5)) !== true){
$ERROR("#15: Number(myobj5) calls ToPrimitive with hint Number. Exptected: Not-a-Number. Actual: " + (Number(myobj5)));
}
assert.sameValue(Number(myobj5), NaN, "Number(myobj5)");

View File

@ -33,9 +33,11 @@ if((new Number(1)).valueOf() !== 1){
}
//CHECK#6
if(!isNaN((new Number(Number.NaN)).valueOf())){
$ERROR('#6: (new Number(Number.NaN)).valueOf() === NaN');
}
assert.sameValue(
new Number(NaN).valueOf(),
NaN,
"NaN"
);
//CHECK#7
if((new Number(Number.POSITIVE_INFINITY)).valueOf() !== Number.POSITIVE_INFINITY){

View File

@ -33,9 +33,11 @@ if((new Number(1)).valueOf("argument") !== 1){
}
//CHECK#6
if(!isNaN((new Number(Number.NaN)).valueOf("argument"))){
$ERROR('#6: (new Number(Number.NaN)).valueOf("argument") === NaN');
}
assert.sameValue(
new Number(NaN).valueOf("argument"),
NaN,
"NaN"
);
//CHECK#7
if((new Number(Number.POSITIVE_INFINITY)).valueOf("argument") !== Number.POSITIVE_INFINITY){

View File

@ -132,9 +132,7 @@ if (Object(Number.NEGATIVE_INFINITY).constructor.prototype !== Number.prototype)
}
// CHECK#25
if (isNaN(Object(Number.NaN).valueOf()) !== true){
$ERROR('#25: Object(Number.NaN).valueOf() === Not-a-Number. Actual: ' + (Object(Number.NaN).valueOf()));
}
assert.sameValue(Object(NaN).valueOf(), NaN, "Object(NaN).valueOf()");
// CHECK#26
if (typeof Object(Number.NaN) !== "object"){

View File

@ -15,7 +15,7 @@ Object.defineProperty(obj, "foo", { value: NaN });
Object.defineProperty(obj, "foo", { value: NaN });
assert(isNaN(obj.foo));
assert.sameValue(obj.foo, NaN);
verifyNotWritable(obj, "foo");

View File

@ -24,7 +24,7 @@ Object.defineProperty(obj, "foo", {
configurable: false
});
assert(isNaN(obj.foo));
assert.sameValue(obj.foo, NaN);
verifyNotWritable(obj, "foo");

View File

@ -15,10 +15,4 @@ __FACTORY.prototype.charCodeAt = String.prototype.charCodeAt;
var __instance = new __FACTORY;
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if (!isNaN(__instance.charCodeAt(-1))) {
$ERROR('#1: function __FACTORY(){}; __FACTORY.prototype.charCodeAt = String.prototype.charCodeAt; __instance = new __FACTORY; isNaN(__instance.charCodeAt(-1)) return true. Actual: '+isNaN(__instance.charCodeAt(-1)));
}
//
//////////////////////////////////////////////////////////////////////////////
assert.sameValue(__instance.charCodeAt(-1), NaN);

View File

@ -11,10 +11,4 @@ description: pos is bigger of string length
var __instance = new String("ABC");
//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if (!isNaN(__instance.charCodeAt(3))) {
$ERROR('#1: __instance = new String("ABC"); isNaN(__instance.charCodeAt(3)) return true. Actual: '+isNaN(__instance.charCodeAt(3)));
}
//
//////////////////////////////////////////////////////////////////////////////
assert.sameValue(__instance.charCodeAt(3), NaN);

View File

@ -23,8 +23,8 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(sample[0], 0, "#1 [0]");
assert.sameValue(sample[1], 1, "#1 [1]");
assert.sameValue(sample[2], 2, "#1 [2]");
assert(Number.isNaN(sample[3]), "#1 [3]");
assert(Number.isNaN(sample[4]), "#1 [4]");
assert.sameValue(sample[3], NaN, "#1 [3]");
assert.sameValue(sample[4], NaN, "#1 [4]");
sample = new TA([3, NaN, NaN, Infinity, 0, -Infinity, 2]).sort();
assert.sameValue(sample[0], -Infinity, "#2 [0]");
@ -32,6 +32,6 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(sample[2], 2, "#2 [2]");
assert.sameValue(sample[3], 3, "#2 [3]");
assert.sameValue(sample[4], Infinity, "#2 [4]");
assert(Number.isNaN(sample[5]), "#2 [5]");
assert(Number.isNaN(sample[6]), "#2 [6]");
assert.sameValue(sample[5], NaN, "#2 [5]");
assert.sameValue(sample[6], NaN, "#2 [6]");
}, [Float64Array, Float32Array]);

View File

@ -8,5 +8,4 @@ description: >
does not contain any such characters
---*/
assert(isNaN(parseFloat("")), 'isNaN(parseFloat("")) !== true');
assert.sameValue(parseFloat(""), NaN, 'parseFloat("")');

View File

@ -7,12 +7,5 @@ es5id: 15.1.2.3_A1_T1
description: Checking for boolean primitive
---*/
//CHECK#1
if (!(isNaN(parseFloat(true)) && isNaN(parseFloat("NaN")))) {
$ERROR('#1: parseFloat(true) === Not-a-Number; parseFloat("NaN") === Not-a-Number. Actual: ' + (parseFloat("NaN")));
}
//CHECK#2
if (String(parseFloat(false)) !== "NaN") {
$ERROR('#2: String(parseFloat(false)) === "NaN". Actual: ' + (String(parseFloat(false))));
}
assert.sameValue(parseFloat(true), NaN, "true");
assert.sameValue(parseFloat(false), NaN, "false");

View File

@ -7,23 +7,5 @@ es5id: 15.1.2.3_A1_T3
description: Checking for undefined and null
---*/
//CHECK#1
if (!(isNaN(parseFloat(undefined)) && isNaN(parseFloat("NaN")))) {
$ERROR('#1: parseFloat(undefined) === Not-a-Number; parseFloat("NaN") === Not-a-Number. Actual: ' + (parseFloat("NaN")));
}
//CHECK#2
if (!(isNaN(parseFloat(null)) && isNaN(parseFloat("NaN")))) {
$ERROR('#2: parseFloat(null) === Not-a-Number; parseFloat("NaN") === Not-a-Number. Actual: ' + (parseFloat("NaN")));
}
//CHECK#3
if (String(parseFloat(undefined)) !== "NaN") {
$ERROR('#3: String(parseFloat(undefined)) === "NaN". Actual: ' + (String(parseFloat(undefined))));
}
//CHECK#4
if (String(parseFloat(null)) !== "NaN") {
$ERROR('#4: String(parseFloat(null)) === "NaN". Actual: ' + (String(parseFloat(null))));
}
assert.sameValue(parseFloat(undefined), NaN, "undefined");
assert.sameValue(parseFloat(null), NaN, "null");

View File

@ -7,12 +7,5 @@ es5id: 15.1.2.3_A1_T4
description: Checking for Boolean object
---*/
//CHECK#1
if (!(isNaN(parseFloat(new Boolean(true))) && isNaN(parseFloat("NaN")))) {
$ERROR('#1: parseFloat(new Boolean(true)) === Not-a-Number; parseFloat("NaN") === Not-a-Number. Actual: ' + (parseFloat("NaN")));
}
//CHECK#2
if (String(parseFloat(new Boolean(false))) !== "NaN") {
$ERROR('#2: String(parseFloat(new Boolean(false))) === "NaN". Actual: ' + (String(parseFloat(new Boolean(false)))));
}
assert.sameValue(parseFloat(new Boolean(true)), NaN, "new Boolean(true)");
assert.sameValue(parseFloat(new Boolean(false)), NaN, "new Boolean(false)");

View File

@ -9,9 +9,7 @@ description: If Type(value) is Object, evaluate ToPrimitive(value, String)
//CHECK#1
var object = {valueOf: function() {return 1}};
if (isNaN(parseFloat(object)) !== true) {
$ERROR('#1: var object = {valueOf: function() {return 1}}; parseFloat(object) === Not-a-Number. Actual: ' + (parseFloat(object)));
}
assert.sameValue(parseFloat(object), NaN, "{valueOf: function() {return 1}}");
//CHECK#2
var object = {valueOf: function() {return 1}, toString: function() {return 0}};

View File

@ -33,6 +33,4 @@ if (parseFloat(" \u0009 \u0009-1.1") !== parseFloat("-1.1")) {
}
//CHECK#6
if (isNaN(parseFloat("\u0009")) !== true) {
$ERROR('#6: parseFloat("\\u0009") === Not-a-Number. Actual: ' + (parseFloat("\u0009")));
}
assert.sameValue(parseFloat("\u0009"), NaN, "'\u0009'");

View File

@ -8,12 +8,14 @@ description: "StrWhiteSpaceChar :: USP"
---*/
//CHECK#
var n;
var count = 0;
var errorCount = 0;
var uspU = ["\u1680", "\u180E", "\u2000", "\u2001", "\u2002", "\u2003", "\u2004", "\u2005", "\u2006", "\u2007", "\u2008", "\u2009", "\u200A", "\u202F", "\u205F", "\u3000"];
var uspS = ["1680", "180E", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "200A", "202F", "205F", "3000"];
for (var index = 0; index < uspU.length; index++) {
var result = true;
n = false;
if (parseFloat(uspU[index] + "1.1") !== parseFloat("1.1")) {
$ERROR('#1.' + uspS[index] + ' ');
result = false;
@ -22,7 +24,8 @@ for (var index = 0; index < uspU.length; index++) {
$ERROR('#2.' + uspS[index] + ' ');
result = false;
}
if (isNaN(parseFloat(uspU[index])) !== true) {
n = parseFloat(uspU[index]);
if (!(n !== n)) {
$ERROR('#3.' + uspS[index] + ' ');
result = false;
}

View File

@ -33,6 +33,4 @@ if (parseFloat(" \u0020 \u0020-1.1") !== parseFloat("-1.1")) {
}
//CHECK#6
if (isNaN(parseFloat("\u0020")) !== true) {
$ERROR('#6: parseFloat("\\u0020") === Not-a-Number. Actual: ' + (parseFloat("\u0020")));
}
assert.sameValue(parseFloat("\u0020"), NaN);

View File

@ -18,6 +18,4 @@ if (parseFloat("\u00A0\u00A0-1.1") !== parseFloat("-1.1")) {
}
//CHECK#3
if (isNaN(parseFloat("\u00A0")) !== true) {
$ERROR('#3: parseFloat("\\u00A0") === Not-a-Number. Actual: ' + (parseFloat("\u00A0")));
}
assert.sameValue(parseFloat("\u00A0"), NaN);

View File

@ -18,6 +18,4 @@ if (parseFloat("\u000C\u000C-1.1") !== parseFloat("-1.1")) {
}
//CHECK#3
if (isNaN(parseFloat("\u000C")) !== true) {
$ERROR('#3: parseFloat("\\u000C") === Not-a-Number. Actual: ' + (parseFloat("\u000C")));
}
assert.sameValue(parseFloat("\u000C"), NaN);

View File

@ -18,6 +18,4 @@ if (parseFloat("\u000B\u000B-1.1") !== parseFloat("-1.1")) {
}
//CHECK#3
if (isNaN(parseFloat("\u000B")) !== true) {
$ERROR('#3: parseFloat("\\u000B") === Not-a-Number. Actual: ' + (parseFloat("\u000B")));
}
assert.sameValue(parseFloat("\u000B"), NaN);

View File

@ -18,6 +18,4 @@ if (parseFloat("\u000D\u000D-1.1") !== parseFloat("-1.1")) {
}
//CHECK#3
if (isNaN(parseFloat("\u000D")) !== true) {
$ERROR('#3: parseFloat("\\u000D") === Not-a-Number. Actual: ' + (parseFloat("\u000D")));
}
assert.sameValue(parseFloat("\u000D"), NaN);

View File

@ -18,6 +18,4 @@ if (parseFloat("\u000A\u000A-1.1") !== parseFloat("-1.1")) {
}
//CHECK#3
if (isNaN(parseFloat("\u000A")) !== true) {
$ERROR('#3: parseFloat("\\u000A") === Not-a-Number. Actual: ' + (parseFloat("\u000A")));
}
assert.sameValue(parseFloat("\u000A"), NaN);

View File

@ -18,6 +18,4 @@ if (parseFloat("\u2028\u2028-1.1") !== parseFloat("-1.1")) {
}
//CHECK#3
if (isNaN(parseFloat("\u2028")) !== true) {
$ERROR('#3: parseFloat("\\u2028") === Not-a-Number. Actual: ' + (parseFloat("\u2028")));
}
assert.sameValue(parseFloat("\u2028"), NaN);

View File

@ -18,6 +18,4 @@ if (parseFloat("\u2029\u2029-1.1") !== parseFloat("-1.1")) {
}
//CHECK#3
if (isNaN(parseFloat("\u2029")) !== true) {
$ERROR('#3: parseFloat("\\u2029") === Not-a-Number. Actual: ' + (parseFloat("\u2029")));
}
assert.sameValue(parseFloat("\u2029"), NaN);

View File

@ -9,37 +9,7 @@ es5id: 15.1.2.3_A3_T1
description: parseFloat("some string") return NaN
---*/
//CHECK#1
if (isNaN(parseFloat("str")) !== true) {
$ERROR('#1: parseFloat("str") === Not-a-Number. Actual: ' + (parseFloat("str")));
}
//CHECK#2
if (isNaN(parseFloat("s1")) !== true) {
$ERROR('#2: parseFloat("s1") === Not-a-Number. Actual: ' + (parseFloat("s1")));
}
//CHECK#3
if (isNaN(parseFloat("")) !== true) {
$ERROR('#3: parseFloat("") === Not-a-Number. Actual: ' + (parseFloat("")));
}
//CHECK#4
if (String(parseFloat("str")) !== "NaN") {
$ERROR('#4: String(parseFloat("str")) === "NaN". Actual: ' + (String(parseFloat("str"))));
}
//CHECK#5
if (String(parseFloat("s1")) !== "NaN") {
$ERROR('#5: String(parseFloat("s1")) === "NaN". Actual: ' + (String(parseFloat("s1"))));
}
//CHECK#6
if (String(parseFloat("")) !== "NaN") {
$ERROR('#6: String(parseFloat("")) === "NaN". Actual: ' + (String(parseFloat(""))));
}
//CHECK#7
if (String(parseFloat("+")) !== "NaN") {
$ERROR('#7: String(parseFloat("+")) === "NaN". Actual: ' + (String(parseFloat("+"))));
}
assert.sameValue(parseFloat("str"), NaN, "str");
assert.sameValue(parseFloat("s1"), NaN, "s1");
assert.sameValue(parseFloat(""), NaN, "");
assert.sameValue(parseFloat("+"), NaN, "+");

View File

@ -9,52 +9,9 @@ es5id: 15.1.2.3_A3_T2
description: parseFloat("wrong number format with ExponentIndicator") return NaN
---*/
//CHECK#1
if (isNaN(parseFloat("e1")) !== true) {
$ERROR('#1: parseFloat("e1") === Not-a-Number. Actual: ' + (parseFloat("e1")));
}
//CHECK#2
if (isNaN(parseFloat("e-1")) !== true) {
$ERROR('#2: parseFloat("e-1") === Not-a-Number. Actual: ' + (parseFloat("e-1")));
}
//CHECK#3
if (isNaN(parseFloat("E+1")) !== true) {
$ERROR('#3: parseFloat("E+1") === Not-a-Number. Actual: ' + (parseFloat("E+1")));
}
//CHECK#4
if (isNaN(parseFloat("E0")) !== true) {
$ERROR('#4: parseFloat("E0") === Not-a-Number. Actual: ' + (parseFloat("E0")));
}
//CHECK#5
if (String(parseFloat("e1")) !== "NaN") {
$ERROR('#5: String(parseFloat("e1")) === "NaN". Actual: ' + (String(parseFloat("e1"))));
}
//CHECK#6
if (String(parseFloat("e-1")) !== "NaN") {
$ERROR('#6: String(parseFloat("e-1")) === "NaN". Actual: ' + (String(parseFloat("e-1"))));
}
//CHECK#7
if (String(parseFloat("E+1")) !== "NaN") {
$ERROR('#73: String(parseFloat("E+1")) === "NaN". Actual: ' + (String(parseFloat("E+1"))));
}
//CHECK#8
if (String(parseFloat("E0")) !== "NaN") {
$ERROR('#8: String(parseFloat("E0")) === "NaN". Actual: ' + (String(parseFloat("E0"))));
}
//CHECK#9
if (isNaN(parseFloat("-.e-1")) !== true) {
$ERROR('#9: parseFloat("-.e-1") === Not-a-Number. Actual: ' + (parseFloat("-.e-1")));
}
//CHECK#10
if (isNaN(parseFloat(".e1")) !== true) {
$ERROR('#10: parseFloat(".e1") === Not-a-Number. Actual: ' + (parseFloat(".e1")));
}
assert.sameValue(parseFloat("e1"), NaN, "e1");
assert.sameValue(parseFloat("e-1"), NaN, "e-1");
assert.sameValue(parseFloat("E+1"), NaN, "E+1");
assert.sameValue(parseFloat("E0"), NaN, "E0");
assert.sameValue(parseFloat("-.e-1"), NaN, "-.e-1");
assert.sameValue(parseFloat(".e1"), NaN, ".e1");

View File

@ -9,42 +9,7 @@ es5id: 15.1.2.3_A3_T3
description: parseFloat("wrong numbr format") return NaN
---*/
//CHECK#1
if (isNaN(parseFloat(".x")) !== true) {
$ERROR('#1: parseFloat(".x") === Not-a-Number. Actual: ' + (parseFloat(".x")));
}
//CHECK#2
if (isNaN(parseFloat("+x")) !== true) {
$ERROR('#2: parseFloat("+x") === Not-a-Number. Actual: ' + (parseFloat("+x")));
}
//CHECK#3
if (isNaN(parseFloat("infinity")) !== true) {
$ERROR('#3: parseFloat("infinity") === Not-a-Number. Actual: ' + (parseFloat("infinity")));
}
//CHECK#4
if (isNaN(parseFloat("A")) !== true) {
$ERROR('#4: parseFloat("A") === Not-a-Number. Actual: ' + (parseFloat("A")));
}
//CHECK#5
if (String(parseFloat(".s")) !== "NaN") {
$ERROR('#5: String(parseFloat(".s")) === "NaN". Actual: ' + (String(parseFloat(".s"))));
}
//CHECK#6
if (String(parseFloat("+x")) !== "NaN") {
$ERROR('#6: String(parseFloat("+x")) === "NaN". Actual: ' + (String(parseFloat("+x"))));
}
//CHECK#7
if (String(parseFloat("infinity")) !== "NaN") {
$ERROR('#73: String(parseFloat("infinity")) === "NaN". Actual: ' + (String(parseFloat("infinity"))));
}
//CHECK#8
if (String(parseFloat("A")) !== "NaN") {
$ERROR('#8: String(parseFloat("A")) === "NaN". Actual: ' + (String(parseFloat("A"))));
}
assert.sameValue(parseFloat(".x"), NaN, ".x");
assert.sameValue(parseFloat("+x"), NaN, "+x");
assert.sameValue(parseFloat("infinity"), NaN, "infinity");
assert.sameValue(parseFloat("A"), NaN, "A");

View File

@ -8,5 +8,4 @@ description: >
contain any such characters
---*/
assert(isNaN(parseInt("")), 'isNaN(parseInt("")) !== true');
assert.sameValue(parseInt(""), NaN, 'parseInt("")');

View File

@ -7,12 +7,5 @@ es5id: 15.1.2.2_A1_T1
description: Checking for boolean primitive
---*/
//CHECK#1
if (!(isNaN(parseInt(true)) && isNaN(parseInt("NaN")))) {
$ERROR('#1: parseInt(true) === Not-a-Number; parseInt("NaN") === Not-a-Number. Actual: ' + (parseInt("NaN")));
}
//CHECK#2
if (String(parseInt(false)) !== "NaN") {
$ERROR('#2: String(parseInt(false)) === "NaN". Actual: ' + (String(parseInt(false))));
}
assert.sameValue(parseInt(true), NaN, "true");
assert.sameValue(parseInt(false), NaN, "false");

View File

@ -7,22 +7,5 @@ es5id: 15.1.2.2_A1_T3
description: Checking for undefined and null
---*/
//CHECK#1
if (!(isNaN(parseInt(undefined)) && isNaN(parseInt("NaN")))) {
$ERROR('#1: parseInt(undefined) === Not-a-Number; parseInt("NaN") === Not-a-Number. Actual: ' + (parseInt("NaN")));
}
//CHECK#2
if (!(isNaN(parseInt(null)) && isNaN(parseInt("NaN")))) {
$ERROR('#2: parseInt(null) === Not-a-Number; parseInt("NaN") === Not-a-Number. Actual: ' + (parseInt("NaN")));
}
//CHECK#3
if (String(parseInt(undefined)) !== "NaN") {
$ERROR('#3: String(parseInt(undefined)) === "NaN". Actual: ' + (String(parseInt(undefined))));
}
//CHECK#4
if (String(parseInt(null)) !== "NaN") {
$ERROR('#4: String(parseInt(null)) === "NaN". Actual: ' + (String(parseInt(null))));
}
assert.sameValue(parseInt(undefined), NaN, "undefined");
assert.sameValue(parseInt(null), NaN, "null");

View File

@ -7,12 +7,5 @@ es5id: 15.1.2.2_A1_T4
description: Checking for Boolean object
---*/
//CHECK#1
if (!(isNaN(parseInt(new Boolean(true))) && isNaN(parseInt("NaN")))) {
$ERROR('#1: parseInt(new Boolean(true)) === Not-a-Number; parseInt("NaN") === Not-a-Number. Actual: ' + (parseInt("NaN")));
}
//CHECK#2
if (String(parseInt(new Boolean(false))) !== "NaN") {
$ERROR('#2: String(parseInt(new Boolean(false))) === "NaN". Actual: ' + (String(parseInt(new Boolean(false)))));
}
assert.sameValue(parseInt(new Boolean(true)), NaN, "new Boolean(true)");
assert.sameValue(parseInt(new Boolean(false)), NaN, "new Boolean(false)");

View File

@ -9,9 +9,7 @@ description: If Type(value) is Object, evaluate ToPrimitive(value, String)
//CHECK#1
var object = {valueOf: function() {return 1}};
if (isNaN(parseInt(object)) !== true) {
$ERROR('#1: var object = {valueOf: function() {return 1}}; parseInt(object) === Not-a-Number. Actual: ' + (parseInt(object)));
}
assert.sameValue(parseInt(object), NaN, "{valueOf: function() {return 1}}");
//CHECK#2
var object = {valueOf: function() {return 1}, toString: function() {return 0}};

View File

@ -33,6 +33,4 @@ if (parseInt(" \u0009 \u0009-1") !== parseInt("-1")) {
}
//CHECK#6
if (isNaN(parseInt("\u0009")) !== true) {
$ERROR('#6: parseInt("\\u0009") === Not-a-Number. Actual: ' + (parseInt("\u0009")));
}
assert.sameValue(parseInt("\u0009"), NaN);

View File

@ -8,6 +8,7 @@ description: "StrWhiteSpaceChar :: USP"
---*/
//CHECK#
var n;
var count = 0;
var errorCount = 0;
var uspU = ["\u1680", "\u180E", "\u2000", "\u2001", "\u2002", "\u2003", "\u2004", "\u2005", "\u2006", "\u2007", "\u2008", "\u2009", "\u200A", "\u202F", "\u205F", "\u3000"];
@ -15,6 +16,7 @@ var uspS = ["1680", "180E", "2000", "2001", "2002", "2003", "2004", "2005", "200
for (var index = 0; index < uspU.length; index++) {
var result = true;
n = false;
if (parseInt(uspU[index] + "1") !== parseInt("1")) {
$ERROR('#1.' + uspS[index] + ' ');
result = false;
@ -23,7 +25,8 @@ for (var index = 0; index < uspU.length; index++) {
$ERROR('#2.' + uspS[index] + ' ');
result = false;
}
if (isNaN(parseInt(uspU[index])) !== true) {
n = parseInt(uspU[index]);
if (!(n !== n)) {
$ERROR('#3.' + uspS[index] + ' ');
result = false;
}

View File

@ -33,6 +33,4 @@ if (parseInt(" \u0020 \u0020-1") !== parseInt("-1")) {
}
//CHECK#6
if (isNaN(parseInt("\u0020")) !== true) {
$ERROR('#6: parseInt("\\u0020") === Not-a-Number. Actual: ' + (parseInt("\u0020")));
}
assert.sameValue(parseInt("\u0020"), NaN);

View File

@ -18,6 +18,4 @@ if (parseInt("\u00A0\u00A0-1") !== parseInt("-1")) {
}
//CHECK#3
if (isNaN(parseInt("\u00A0")) !== true) {
$ERROR('#3: parseInt("\\u00A0") === Not-a-Number. Actual: ' + (parseInt("\u00A0")));
}
assert.sameValue(parseInt("\u00A0"), NaN);

View File

@ -18,6 +18,4 @@ if (parseInt("\u000C\u000C-1") !== parseInt("-1")) {
}
//CHECK#3
if (isNaN(parseInt("\u000C")) !== true) {
$ERROR('#3: parseInt("\\u000C") === Not-a-Number. Actual: ' + (parseInt("\u000C")));
}
assert.sameValue(parseInt("\u000C"), NaN);

View File

@ -18,6 +18,4 @@ if (parseInt("\u000B\u000B-1") !== parseInt("-1")) {
}
//CHECK#3
if (isNaN(parseInt("\u000B")) !== true) {
$ERROR('#3: parseInt("\\u000B") === Not-a-Number. Actual: ' + (parseInt("\u000B")));
}
assert.sameValue(parseInt("\u000B"), NaN);

View File

@ -18,6 +18,4 @@ if (parseInt("\u000D\u000D-1") !== parseInt("-1")) {
}
//CHECK#3
if (isNaN(parseInt("\u000D")) !== true) {
$ERROR('#3: parseInt("\\u000D") === Not-a-Number. Actual: ' + (parseInt("\u000D")));
}
assert.sameValue(parseInt("\u000D"), NaN);

View File

@ -18,6 +18,4 @@ if (parseInt("\u000A\u000A-1") !== parseInt("-1")) {
}
//CHECK#3
if (isNaN(parseInt("\u000A")) !== true) {
$ERROR('#3: parseInt("\\u000A") === Not-a-Number. Actual: ' + (parseInt("\u000A")));
}
assert.sameValue(parseInt("\u000A"), NaN);

View File

@ -18,6 +18,4 @@ if (parseInt("\u2028\u2028-1") !== parseInt("-1")) {
}
//CHECK#3
if (isNaN(parseInt("\u2028")) !== true) {
$ERROR('#3: parseInt("\\u2028") === Not-a-Number. Actual: ' + (parseInt("\u2028")));
}
assert.sameValue(parseInt("\u2028"), NaN);

View File

@ -18,6 +18,4 @@ if (parseInt("\u2029\u2029-1") !== parseInt("-1")) {
}
//CHECK#3
if (isNaN(parseInt("\u2029")) !== true) {
$ERROR('#3: parseInt("\\u2029") === Not-a-Number. Actual: ' + (parseInt("\u2029")));
}
assert.sameValue(parseInt("\u2029"), NaN);

View File

@ -13,6 +13,4 @@ if (parseInt("11", false) !== parseInt("11", 10)) {
}
//CHECK#2
if (isNaN(parseInt("11", true)) !== true) {
$ERROR('#2: parseInt("11", true) === Not-a-Number. Actual: ' + (parseInt("11", true)));
}
assert.sameValue(parseInt("11", true), NaN);

View File

@ -13,6 +13,4 @@ if (parseInt("11", new Boolean(false)) !== parseInt("11", false)) {
}
//CHECK#2
if (isNaN(parseInt("11", new Boolean(true))) !== true) {
$ERROR('#2: parseInt("11", new Boolean(true)) === Not-a-Number. Actual: ' + (parseInt("11", new Boolean(true))));
}
assert.sameValue(parseInt("11", new Boolean(true)), NaN);

View File

@ -18,9 +18,7 @@ if (parseInt("11", 4294967296) !== parseInt("11", 10)) {
}
//CHECK#3
if (isNaN(parseInt("11", -2147483650)) !== true) {
$ERROR('#3: parseInt("11", 2147483650) === Not-a-Number. Actual: ' + (parseInt("11", 2147483650)));
}
assert.sameValue(parseInt("11", -2147483650), NaN, "-2147483650");
//CHECK#4
if (parseInt("11", -4294967294) !== parseInt("11", 2)) {

View File

@ -7,62 +7,15 @@ es5id: 15.1.2.2_A4.2_T1
description: R = 1
---*/
//CHECK#0
if (isNaN(parseInt("0", 1)) !== true) {
$ERROR('#0: parseInt("0", 1) === Not-a-Number. Actual: ' + (parseInt("0", 1)));
}
//CHECK#1
if (isNaN(parseInt("1", 1)) !== true) {
$ERROR('#1: parseInt("1", 1) === Not-a-Number. Actual: ' + (parseInt("1", 1)));
}
//CHECK#2
if (isNaN(parseInt("2", 1)) !== true) {
$ERROR('#2: parseInt("2", 1) === Not-a-Number. Actual: ' + (parseInt("2", 1)));
}
//CHECK#3
if (isNaN(parseInt("3", 1)) !== true) {
$ERROR('#3: parseInt("3", 1) === Not-a-Number. Actual: ' + (parseInt("3", 1)));
}
//CHECK#4
if (isNaN(parseInt("4", 1)) !== true) {
$ERROR('#4: parseInt("4", 1) === Not-a-Number. Actual: ' + (parseInt("4", 1)));
}
//CHECK#5
if (isNaN(parseInt("5", 1)) !== true) {
$ERROR('#5: parseInt("5", 1) === Not-a-Number. Actual: ' + (parseInt("5", 1)));
}
//CHECK#6
if (isNaN(parseInt("6", 1)) !== true) {
$ERROR('#6: parseInt("6", 1) === Not-a-Number. Actual: ' + (parseInt("6", 1)));
}
//CHECK#7
if (isNaN(parseInt("7", 1)) !== true) {
$ERROR('#7: parseInt("7", 1) === Not-a-Number. Actual: ' + (parseInt("7", 1)));
}
//CHECK#8
if (isNaN(parseInt("8", 1)) !== true) {
$ERROR('#8: parseInt("8", 1) === Not-a-Number. Actual: ' + (parseInt("8", 1)));
}
//CHECK#9
if (isNaN(parseInt("9", 1)) !== true) {
$ERROR('#9: parseInt("9", 1) === Not-a-Number. Actual: ' + (parseInt("9", 1)));
}
//CHECK#10
if (isNaN(parseInt("10", 1)) !== true) {
$ERROR('#10: parseInt("10", 1) === Not-a-Number. Actual: ' + (parseInt("10", 1)));
}
//CHECK#11
if (isNaN(parseInt("11", 1)) !== true) {
$ERROR('#11: parseInt("11", 1) === Not-a-Number. Actual: ' + (parseInt("11", 1)));
}
assert.sameValue(parseInt("0", 1), NaN, "0");
assert.sameValue(parseInt("1", 1), NaN, "1");
assert.sameValue(parseInt("2", 1), NaN, "2");
assert.sameValue(parseInt("3", 1), NaN, "3");
assert.sameValue(parseInt("4", 1), NaN, "4");
assert.sameValue(parseInt("5", 1), NaN, "5");
assert.sameValue(parseInt("6", 1), NaN, "6");
assert.sameValue(parseInt("7", 1), NaN, "7");
assert.sameValue(parseInt("8", 1), NaN, "8");
assert.sameValue(parseInt("9", 1), NaN, "9");
assert.sameValue(parseInt("10", 1), NaN, "10");
assert.sameValue(parseInt("11", 1), NaN, "11");

View File

@ -7,62 +7,15 @@ es5id: 15.1.2.2_A4.2_T2
description: R = 37
---*/
//CHECK#0
if (isNaN(parseInt("0", 37)) !== true) {
$ERROR('#0: parseInt("0", 37) === Not-a-Number. Actual: ' + (parseInt("0", 37)));
}
//CHECK#1
if (isNaN(parseInt("1", 37)) !== true) {
$ERROR('#1: parseInt("1", 37) === Not-a-Number. Actual: ' + (parseInt("1", 37)));
}
//CHECK#2
if (isNaN(parseInt("2", 37)) !== true) {
$ERROR('#2: parseInt("2", 37) === Not-a-Number. Actual: ' + (parseInt("2", 37)));
}
//CHECK#3
if (isNaN(parseInt("3", 37)) !== true) {
$ERROR('#3: parseInt("3", 37) === Not-a-Number. Actual: ' + (parseInt("3", 37)));
}
//CHECK#4
if (isNaN(parseInt("4", 37)) !== true) {
$ERROR('#4: parseInt("4", 37) === Not-a-Number. Actual: ' + (parseInt("4", 37)));
}
//CHECK#5
if (isNaN(parseInt("5", 37)) !== true) {
$ERROR('#5: parseInt("5", 37) === Not-a-Number. Actual: ' + (parseInt("5", 37)));
}
//CHECK#6
if (isNaN(parseInt("6", 37)) !== true) {
$ERROR('#6: parseInt("6", 37) === Not-a-Number. Actual: ' + (parseInt("6", 37)));
}
//CHECK#7
if (isNaN(parseInt("7", 37)) !== true) {
$ERROR('#7: parseInt("7", 37) === Not-a-Number. Actual: ' + (parseInt("7", 37)));
}
//CHECK#8
if (isNaN(parseInt("8", 37)) !== true) {
$ERROR('#8: parseInt("8", 37) === Not-a-Number. Actual: ' + (parseInt("8", 37)));
}
//CHECK#9
if (isNaN(parseInt("9", 37)) !== true) {
$ERROR('#9: parseInt("9", 37) === Not-a-Number. Actual: ' + (parseInt("9", 37)));
}
//CHECK#10
if (isNaN(parseInt("10", 37)) !== true) {
$ERROR('#10: parseInt("10", 37) === Not-a-Number. Actual: ' + (parseInt("10", 37)));
}
//CHECK#11
if (isNaN(parseInt("11", 37)) !== true) {
$ERROR('#11: parseInt("11", 37) === Not-a-Number. Actual: ' + (parseInt("11", 37)));
}
assert.sameValue(parseInt("0", 37), NaN, "0");
assert.sameValue(parseInt("1", 37), NaN, "1");
assert.sameValue(parseInt("2", 37), NaN, "2");
assert.sameValue(parseInt("3", 37), NaN, "3");
assert.sameValue(parseInt("4", 37), NaN, "4");
assert.sameValue(parseInt("5", 37), NaN, "5");
assert.sameValue(parseInt("6", 37), NaN, "6");
assert.sameValue(parseInt("7", 37), NaN, "7");
assert.sameValue(parseInt("8", 37), NaN, "8");
assert.sameValue(parseInt("9", 37), NaN, "9");
assert.sameValue(parseInt("10", 37), NaN, "10");
assert.sameValue(parseInt("11", 37), NaN, "11");

View File

@ -1,23 +0,0 @@
// Copyright 2009 the Sputnik authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
info: If R < 2 or R > 36, then return NaN
es5id: 15.1.2.2_A4.2_T3
description: Complex test
---*/
//CHECK#
var pow = 2;
for (var i = 1; i < 32; i++) {
if (pow > 36) {
var res = true;
if (isNaN(parseInt(1, pow)) !== true) {
$ERROR('#1.' + i + ': If R < 2 or R > 36, then return NaN');
}
if (isNaN(parseInt(1, -pow)) !== true) {
$ERROR('#2.' + i + ': If R < 2 or R > 36, then return NaN');
}
}
pow = pow * 2;
}

View File

@ -9,7 +9,5 @@ description: Complex test. R in [2, 36]
//CHECK#
for (var i = 2; i <= 36; i++) {
if (isNaN(parseInt("$string", i)) !== true) {
$ERROR('#' + i + ': parseInt("$string", i) === Not-a-Number. Actual: ' + (parseInt("$string", i)));
}
assert.sameValue(parseInt("$string", i), NaN);
}

View File

@ -7,27 +7,8 @@ es5id: 15.1.2.2_A7.1_T2
description: x is not a radix-R digit
---*/
//CHECK#1
if (isNaN(parseInt("$0x")) !== true) {
$ERROR('#1: parseInt("$0x") === Not-a-Number. Actual: ' + (parseInt("$0x")));
}
//CHECK#2
if (isNaN(parseInt("$0X")) !== true) {
$ERROR('#2: parseInt("$0X") === Not-a-Number. Actual: ' + (parseInt("$0X")));
}
//CHECK#3
if (isNaN(parseInt("$$$")) !== true) {
$ERROR('#3: parseInt("$$$") === Not-a-Number. Actual: ' + (parseInt("$$$")));
}
//CHECK#4
if (isNaN(parseInt("")) !== true) {
$ERROR('#4: parseInt("") === Not-a-Number. Actual: ' + (parseInt("")));
}
//CHECK#5
if (isNaN(parseInt(" ")) !== true) {
$ERROR('#5: parseInt(" ") === Not-a-Number. Actual: ' + (parseInt(" ")));
}
assert.sameValue(parseInt("$0x"), NaN, "$0x");
assert.sameValue(parseInt("$0X"), NaN, "$0X");
assert.sameValue(parseInt("$$$"), NaN, "$$$");
assert.sameValue(parseInt(""), NaN, "the empty string");
assert.sameValue(parseInt(" "), NaN, "a string with a single space");

View File

@ -20,7 +20,9 @@ bases[8] = NaN;
for (var i = 0; i < bases.length; i++) {
if (!isNaN(bases[i] ** exponent)) {
$ERROR("isNaN(" + bases[i] + " ** " + exponent + ") === false");
}
assert.sameValue(
bases[i] ** exponent,
NaN,
bases[i] + " ** " + exponent
);
}

Some files were not shown because too many files have changed in this diff Show More