From c58ac691ebb16ce23af564d64c1f8c0a63479afa Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Fri, 25 Mar 2022 08:35:50 -0400 Subject: [PATCH] Test that "infinity" is not recognized as numeric --- implementation-contributed/v8/mjsunit/harmony/to-number.js | 1 + test/built-ins/Number/S15.7.1.1_A1.js | 1 + test/language/expressions/unary-plus/S11.4.6_A3_T3.js | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/implementation-contributed/v8/mjsunit/harmony/to-number.js b/implementation-contributed/v8/mjsunit/harmony/to-number.js index c5a06cf4ff..e145782d4b 100644 --- a/implementation-contributed/v8/mjsunit/harmony/to-number.js +++ b/implementation-contributed/v8/mjsunit/harmony/to-number.js @@ -20,6 +20,7 @@ assertEquals(-1, %ToNumber("-1")); assertEquals(123, %ToNumber("123")); assertEquals(NaN, %ToNumber("random text")); assertEquals(NaN, %ToNumber("INFINITY")); +assertEquals(NaN, %ToNumber("infinity")); assertThrows(function() { %ToNumber(Symbol.toPrimitive) }, TypeError); diff --git a/test/built-ins/Number/S15.7.1.1_A1.js b/test/built-ins/Number/S15.7.1.1_A1.js index ebecc20106..adf4f19515 100644 --- a/test/built-ins/Number/S15.7.1.1_A1.js +++ b/test/built-ins/Number/S15.7.1.1_A1.js @@ -25,3 +25,4 @@ assert.sameValue( assert.sameValue(Number("abc"), NaN, 'Number("abc") returns NaN'); assert.sameValue(Number("INFINITY"), NaN, 'Number("INFINITY") returns NaN'); +assert.sameValue(Number("infinity"), NaN, 'Number("infinity") returns NaN'); diff --git a/test/language/expressions/unary-plus/S11.4.6_A3_T3.js b/test/language/expressions/unary-plus/S11.4.6_A3_T3.js index cb6c454615..9a3a2f6b49 100644 --- a/test/language/expressions/unary-plus/S11.4.6_A3_T3.js +++ b/test/language/expressions/unary-plus/S11.4.6_A3_T3.js @@ -26,3 +26,8 @@ if (isNaN(+"x") !== true) { if (isNaN(+"INFINITY") !== true) { throw new Test262Error('#4: +"INFINITY" === Not-a-Number. Actual: ' + (+"INFINITY")); } + +//CHECK#5 +if (isNaN(+"infinity") !== true) { + throw new Test262Error('#5: +"infinity" === Not-a-Number. Actual: ' + (+"infinity")); +}