Skip to content

Commit

Permalink
Test that "INFINITY" is not recognized as numeric
Browse files Browse the repository at this point in the history
Fixes tc39#3442
  • Loading branch information
gibson042 authored and jessealama committed Apr 13, 2022
1 parent 895f2be commit 4bd3d6d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions implementation-contributed/v8/mjsunit/harmony/to-number.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions test/built-ins/Number/S15.7.1.1_A1.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ assert.sameValue(
);

assert.sameValue(Number("abc"), NaN, 'Number("abc") returns NaN');
assert.sameValue(Number("INFINITY"), NaN, 'Number("INFINITY") returns NaN');
13 changes: 9 additions & 4 deletions test/language/expressions/unary-plus/S11.4.6_A3_T3.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}

0 comments on commit 4bd3d6d

Please sign in to comment.