Test that "INFINITY" is not recognized as numeric

Fixes #3442
This commit is contained in:
Richard Gibson 2022-03-24 16:52:05 -04:00 committed by Rick Waldron
parent 51822ff2d8
commit c572588ea9
3 changed files with 11 additions and 4 deletions

View File

@ -19,6 +19,7 @@ assertEquals(NaN, %ToNumber(undefined));
assertEquals(-1, %ToNumber("-1"));
assertEquals(123, %ToNumber("123"));
assertEquals(NaN, %ToNumber("random text"));
assertEquals(NaN, %ToNumber("INFINITY"));
assertThrows(function() { %ToNumber(Symbol.toPrimitive) }, TypeError);

View File

@ -24,3 +24,4 @@ assert.sameValue(
);
assert.sameValue(Number("abc"), NaN, 'Number("abc") returns NaN');
assert.sameValue(Number("INFINITY"), NaN, 'Number("INFINITY") returns NaN');

View File

@ -13,11 +13,16 @@ if (+"1" !== 1) {
}
//CHECK#2
if (isNaN(+"x") !== true) {
throw new Test262Error('#2: +"x" === Not-a-Number. Actual: ' + (+"x"));
if (+new Number("-1") !== -1) {
throw new Test262Error('#2: +new String("-1") === -1. Actual: ' + (+new String("-1")));
}
//CHECK#3
if (+new Number("-1") !== -1) {
throw new Test262Error('#3: +new String("-1") === -1. Actual: ' + (+new String("-1")));
if (isNaN(+"x") !== true) {
throw new Test262Error('#3: +"x" === Not-a-Number. Actual: ' + (+"x"));
}
//CHECK#4
if (isNaN(+"INFINITY") !== true) {
throw new Test262Error('#4: +"INFINITY" === Not-a-Number. Actual: ' + (+"INFINITY"));
}