Implement numeric-separator (#4158)
JerryScript-DCO-1.0-Signed-off-by: bence gabor kis kisbg@inf.u-szeged.hu
This commit is contained in:
@@ -295,7 +295,12 @@ ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 st
|
||||
const lit_utf8_byte_t *end_p, /**< end of utf-8 string */
|
||||
uint32_t radix) /**< radix */
|
||||
{
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
bool allow_underscore = (radix & ECMA_CONVERSION_ALLOW_UNDERSCORE);
|
||||
radix &= (uint32_t) ~ECMA_CONVERSION_ALLOW_UNDERSCORE;
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
JERRY_ASSERT (radix == 2 || radix == 8 || radix == 16);
|
||||
|
||||
ecma_number_t num = ECMA_NUMBER_ZERO;
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
@@ -342,6 +347,12 @@ ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 st
|
||||
{
|
||||
digit_value = 10 + (*iter_p - LIT_CHAR_UPPERCASE_A);
|
||||
}
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else if (*iter_p == LIT_CHAR_UNDERSCORE && allow_underscore)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
else
|
||||
{
|
||||
return ecma_number_make_nan ();
|
||||
@@ -364,7 +375,8 @@ ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 st
|
||||
*/
|
||||
ecma_number_t
|
||||
ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
lit_utf8_size_t str_size) /**< string size */
|
||||
lit_utf8_size_t str_size, /**< string size */
|
||||
uint32_t options) /**< allowing underscore option bit */
|
||||
{
|
||||
/* TODO: Check license issues */
|
||||
|
||||
@@ -388,15 +400,15 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
{
|
||||
case LIT_CHAR_LOWERCASE_X :
|
||||
{
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 16);
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 16 | options);
|
||||
}
|
||||
case LIT_CHAR_LOWERCASE_O :
|
||||
{
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 8);
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 8 | options);
|
||||
}
|
||||
case LIT_CHAR_LOWERCASE_B :
|
||||
{
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 2);
|
||||
return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 2 | options);
|
||||
}
|
||||
default:
|
||||
{
|
||||
@@ -449,6 +461,13 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
digit_seen = true;
|
||||
digit_value = (*str_p - LIT_CHAR_0);
|
||||
}
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else if (*str_p == LIT_CHAR_UNDERSCORE && (options & ECMA_CONVERSION_ALLOW_UNDERSCORE))
|
||||
{
|
||||
str_p++;
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
else
|
||||
{
|
||||
break;
|
||||
@@ -491,6 +510,11 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
digit_seen = true;
|
||||
digit_value = (*str_p - LIT_CHAR_0);
|
||||
}
|
||||
else if (*str_p == LIT_CHAR_UNDERSCORE && (options & ECMA_CONVERSION_ALLOW_UNDERSCORE))
|
||||
{
|
||||
str_p++;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
@@ -550,6 +574,13 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
|
||||
{
|
||||
digit_value = (*str_p - LIT_CHAR_0);
|
||||
}
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
else if (*str_p == LIT_CHAR_UNDERSCORE && (options & ECMA_CONVERSION_ALLOW_UNDERSCORE))
|
||||
{
|
||||
str_p++;
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
else
|
||||
{
|
||||
return ecma_number_make_nan ();
|
||||
|
||||
@@ -1059,7 +1059,7 @@ ecma_number_parse_float (const lit_utf8_byte_t *string_buff, /**< routine's firs
|
||||
}
|
||||
|
||||
/* 5. */
|
||||
ecma_number_t ret_num = ecma_utf8_string_to_number (start_p, (lit_utf8_size_t) (end_p - start_p));
|
||||
ecma_number_t ret_num = ecma_utf8_string_to_number (start_p, (lit_utf8_size_t) (end_p - start_p), 0);
|
||||
|
||||
if (sign)
|
||||
{
|
||||
|
||||
@@ -985,7 +985,7 @@ ecma_string_to_number (const ecma_string_t *string_p) /**< ecma-string */
|
||||
return ECMA_NUMBER_ZERO;
|
||||
}
|
||||
|
||||
return ecma_utf8_string_to_number (chars_p, size);
|
||||
return ecma_utf8_string_to_number (chars_p, size, 0);
|
||||
} /* ecma_string_to_number */
|
||||
|
||||
/**
|
||||
|
||||
@@ -96,6 +96,11 @@ typedef enum
|
||||
ECMA_STRING_FLAG_MUST_BE_FREED = (1 << 3), /**< The returned buffer must be freed */
|
||||
} ecma_string_flag_t;
|
||||
|
||||
/**
|
||||
* Underscore is ignored when this option is passed.
|
||||
*/
|
||||
#define ECMA_CONVERSION_ALLOW_UNDERSCORE 0x1
|
||||
|
||||
/**
|
||||
* Convert ecma-string's contents to a cesu-8 string and put it into a buffer.
|
||||
*/
|
||||
@@ -525,7 +530,8 @@ ecma_native_pointer_t *ecma_get_native_pointer_value (ecma_object_t *obj_p, void
|
||||
bool ecma_delete_native_pointer_property (ecma_object_t *obj_p, void *info_p);
|
||||
|
||||
/* ecma-helpers-conversion.c */
|
||||
ecma_number_t ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, lit_utf8_size_t str_size);
|
||||
ecma_number_t ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, lit_utf8_size_t str_size,
|
||||
uint32_t option);
|
||||
lit_utf8_size_t ecma_uint32_to_utf8_string (uint32_t value, lit_utf8_byte_t *out_buffer_p, lit_utf8_size_t buffer_size);
|
||||
uint32_t ecma_number_to_uint32 (ecma_number_t num);
|
||||
int32_t ecma_number_to_int32 (ecma_number_t num);
|
||||
|
||||
@@ -68,7 +68,7 @@ ecma_date_parse_date_chars (const lit_utf8_byte_t **str_p, /**< pointer to the c
|
||||
}
|
||||
}
|
||||
|
||||
ecma_number_t parsed_number = ecma_utf8_string_to_number (str_start_p, (lit_utf8_size_t) (*str_p - str_start_p));
|
||||
ecma_number_t parsed_number = ecma_utf8_string_to_number (str_start_p, (lit_utf8_size_t) (*str_p - str_start_p), 0);
|
||||
|
||||
if (parsed_number < min || parsed_number > max)
|
||||
{
|
||||
|
||||
@@ -287,7 +287,7 @@ ecma_builtin_json_parse_number (ecma_json_token_t *token_p) /**< token argument
|
||||
}
|
||||
|
||||
token_p->type = TOKEN_NUMBER;
|
||||
token_p->u.number = ecma_utf8_string_to_number (start_p, (lit_utf8_size_t) (current_p - start_p));
|
||||
token_p->u.number = ecma_utf8_string_to_number (start_p, (lit_utf8_size_t) (current_p - start_p), 0);
|
||||
|
||||
token_p->current_p = current_p;
|
||||
} /* ecma_builtin_json_parse_number */
|
||||
|
||||
@@ -75,6 +75,7 @@ ecma_bigint_parse_string (const lit_utf8_byte_t *string_p, /**< string represena
|
||||
{
|
||||
ecma_bigint_digit_t radix = 10;
|
||||
uint32_t sign = (options & ECMA_BIGINT_PARSE_SET_NEGATIVE) ? ECMA_BIGINT_SIGN : 0;
|
||||
bool allow_underscore = options & ECMA_BIGINT_PARSE_ALLOW_UNDERSCORE;
|
||||
|
||||
const lit_utf8_byte_t *string_end_p = string_p + size;
|
||||
string_p = ecma_string_trim_front (string_p, string_p + size);
|
||||
@@ -120,7 +121,7 @@ ecma_bigint_parse_string (const lit_utf8_byte_t *string_p, /**< string represena
|
||||
return ECMA_BIGINT_ZERO;
|
||||
}
|
||||
|
||||
while (string_p < string_end_p && *string_p == LIT_CHAR_0)
|
||||
while (string_p < string_end_p && (*string_p == LIT_CHAR_0 || (*string_p == LIT_CHAR_UNDERSCORE && allow_underscore)))
|
||||
{
|
||||
string_p++;
|
||||
}
|
||||
@@ -140,6 +141,10 @@ ecma_bigint_parse_string (const lit_utf8_byte_t *string_p, /**< string represena
|
||||
{
|
||||
digit = (ecma_bigint_digit_t) (*string_p - LIT_CHAR_0);
|
||||
}
|
||||
else if (*string_p == LIT_CHAR_UNDERSCORE && allow_underscore)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
lit_utf8_byte_t character = (lit_utf8_byte_t) LEXER_TO_ASCII_LOWERCASE (*string_p);
|
||||
|
||||
@@ -36,6 +36,7 @@ typedef enum
|
||||
* return with ECMA_VALUE_FALSE */
|
||||
ECMA_BIGINT_PARSE_DISALLOW_MEMORY_ERROR = (1 << 2), /**< don't throw out-of-memory error,
|
||||
* return with ECMA_VALUE_NULL instead */
|
||||
ECMA_BIGINT_PARSE_ALLOW_UNDERSCORE = (1 << 3), /** allow parse underscore characters */
|
||||
} ecma_bigint_parse_string_options_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1305,26 +1305,43 @@ lexer_parse_string (parser_context_t *context_p, /**< context */
|
||||
} /* lexer_parse_string */
|
||||
|
||||
/**
|
||||
* Parse octal number.
|
||||
* Check number
|
||||
*/
|
||||
static inline void
|
||||
lexer_parse_octal_number (parser_context_t *context_p, /** context */
|
||||
const uint8_t **source_p) /**< current source position */
|
||||
static void
|
||||
lexer_check_numbers (parser_context_t *context_p, /**< context */
|
||||
const uint8_t **source_p, /**< source_pointer */
|
||||
const uint8_t *source_end_p, /**< end of the source */
|
||||
const ecma_char_t digit_max, /**< maximum of the number range */
|
||||
const bool is_legacy) /**< is legacy octal number */
|
||||
{
|
||||
do
|
||||
#if ENABLED (!JERRY_ESNEXT)
|
||||
JERRY_UNUSED (context_p);
|
||||
JERRY_UNUSED (is_legacy);
|
||||
#endif /* ENABLED (!JERRY_ESNEXT) */
|
||||
while (true)
|
||||
{
|
||||
(*source_p)++;
|
||||
}
|
||||
while (*source_p < context_p->source_end_p
|
||||
&& *source_p[0] >= LIT_CHAR_0
|
||||
&& *source_p[0] <= LIT_CHAR_7);
|
||||
while (*source_p < source_end_p
|
||||
&& *source_p[0] >= LIT_CHAR_0
|
||||
&& *source_p[0] <= digit_max)
|
||||
{
|
||||
*source_p += 1;
|
||||
}
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (*source_p != source_end_p && *source_p[0] == LIT_CHAR_UNDERSCORE)
|
||||
{
|
||||
*source_p += 1;
|
||||
if (is_legacy || *source_p[0] == LIT_CHAR_UNDERSCORE
|
||||
|| *source_p[0] > digit_max || *source_p[0] < LIT_CHAR_0)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_INVALID_UNDERSCORE_IN_NUMBER);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (*source_p < context_p->source_end_p
|
||||
&& (*source_p[0] == LIT_CHAR_8 || *source_p[0] == LIT_CHAR_9))
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_INVALID_OCTAL_DIGIT);
|
||||
break;
|
||||
}
|
||||
} /* lexer_parse_octal_number */
|
||||
} /* lexer_check_numbers */
|
||||
|
||||
/**
|
||||
* Parse number.
|
||||
@@ -1349,6 +1366,12 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
|
||||
if (source_p[0] == LIT_CHAR_0
|
||||
&& source_p + 1 < source_end_p)
|
||||
{
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (source_p[1] == LIT_CHAR_UNDERSCORE)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_INVALID_UNDERSCORE_IN_NUMBER);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
if (LEXER_TO_ASCII_LOWERCASE (source_p[1]) == LIT_CHAR_LOWERCASE_X)
|
||||
{
|
||||
context_p->token.extra_value = LEXER_NUMBER_HEXADECIMAL;
|
||||
@@ -1363,6 +1386,16 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
|
||||
do
|
||||
{
|
||||
source_p++;
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (source_p < source_end_p && source_p[0] == LIT_CHAR_UNDERSCORE)
|
||||
{
|
||||
source_p++;
|
||||
if (!lit_char_is_hex_digit (source_p[0]) || source_p == source_end_p)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_INVALID_UNDERSCORE_IN_NUMBER);
|
||||
}
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
while (source_p < source_end_p
|
||||
&& lit_char_is_hex_digit (source_p[0]));
|
||||
@@ -1379,7 +1412,7 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
|
||||
parser_raise_error (context_p, PARSER_ERR_INVALID_OCTAL_DIGIT);
|
||||
}
|
||||
|
||||
lexer_parse_octal_number (context_p, &source_p);
|
||||
lexer_check_numbers (context_p, &source_p, source_end_p, LIT_CHAR_7, false);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
else if (source_p[1] >= LIT_CHAR_0
|
||||
@@ -1395,7 +1428,7 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
|
||||
parser_raise_error (context_p, PARSER_ERR_OCTAL_NUMBER_NOT_ALLOWED);
|
||||
}
|
||||
|
||||
lexer_parse_octal_number (context_p, &source_p);
|
||||
lexer_check_numbers (context_p, &source_p, source_end_p, LIT_CHAR_7, true);
|
||||
}
|
||||
else if (source_p[1] >= LIT_CHAR_8
|
||||
&& source_p[1] <= LIT_CHAR_9)
|
||||
@@ -1417,6 +1450,16 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
|
||||
do
|
||||
{
|
||||
source_p++;
|
||||
if (source_p < source_end_p && source_p[0] == LIT_CHAR_UNDERSCORE)
|
||||
{
|
||||
source_p++;
|
||||
if (source_p == source_end_p
|
||||
|| source_p[0] > LIT_CHAR_9
|
||||
|| source_p[0] < LIT_CHAR_0)
|
||||
{
|
||||
parser_raise_error (context_p, PARSER_ERR_INVALID_UNDERSCORE_IN_NUMBER);
|
||||
}
|
||||
}
|
||||
}
|
||||
while (source_p < source_end_p
|
||||
&& lit_char_is_binary_digit (source_p[0]));
|
||||
@@ -1430,13 +1473,7 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
else
|
||||
{
|
||||
while (source_p < source_end_p
|
||||
&& source_p[0] >= LIT_CHAR_0
|
||||
&& source_p[0] <= LIT_CHAR_9)
|
||||
{
|
||||
source_p++;
|
||||
}
|
||||
|
||||
lexer_check_numbers (context_p, &source_p, source_end_p, LIT_CHAR_9, false);
|
||||
can_be_float = true;
|
||||
}
|
||||
|
||||
@@ -1450,12 +1487,13 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
|
||||
can_be_bigint = false;
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
|
||||
while (source_p < source_end_p
|
||||
&& source_p[0] >= LIT_CHAR_0
|
||||
&& source_p[0] <= LIT_CHAR_9)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (source_p < source_end_p && source_p[0] == LIT_CHAR_UNDERSCORE)
|
||||
{
|
||||
source_p++;
|
||||
parser_raise_error (context_p, PARSER_ERR_INVALID_UNDERSCORE_IN_NUMBER);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
lexer_check_numbers (context_p, &source_p, source_end_p, LIT_CHAR_9, false);
|
||||
}
|
||||
|
||||
if (source_p < source_end_p
|
||||
@@ -1479,13 +1517,7 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
|
||||
parser_raise_error (context_p, PARSER_ERR_MISSING_EXPONENT);
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
source_p++;
|
||||
}
|
||||
while (source_p < source_end_p
|
||||
&& source_p[0] >= LIT_CHAR_0
|
||||
&& source_p[0] <= LIT_CHAR_9);
|
||||
lexer_check_numbers (context_p, &source_p, source_end_p, LIT_CHAR_9, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2627,8 +2659,13 @@ lexer_construct_number_object (parser_context_t *context_p, /**< context */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
if (context_p->token.extra_value < LEXER_NUMBER_OCTAL)
|
||||
{
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
num = ecma_utf8_string_to_number (context_p->token.lit_location.char_p,
|
||||
length);
|
||||
length,
|
||||
ECMA_CONVERSION_ALLOW_UNDERSCORE);
|
||||
#else
|
||||
num = ecma_utf8_string_to_number (context_p->token.lit_location.char_p, length, 0);
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2653,6 +2690,10 @@ lexer_construct_number_object (parser_context_t *context_p, /**< context */
|
||||
num = 0;
|
||||
do
|
||||
{
|
||||
if (src_p[1] == LIT_CHAR_UNDERSCORE)
|
||||
{
|
||||
src_p++;
|
||||
}
|
||||
num = num * multiplier + (ecma_number_t) (*(++src_p) - LIT_CHAR_0);
|
||||
}
|
||||
while (src_p < src_end_p);
|
||||
@@ -2681,7 +2722,9 @@ lexer_construct_number_object (parser_context_t *context_p, /**< context */
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t options = ECMA_BIGINT_PARSE_DISALLOW_SYNTAX_ERROR | ECMA_BIGINT_PARSE_DISALLOW_MEMORY_ERROR;
|
||||
uint32_t options = (ECMA_BIGINT_PARSE_DISALLOW_SYNTAX_ERROR
|
||||
| ECMA_BIGINT_PARSE_DISALLOW_MEMORY_ERROR
|
||||
| ECMA_BIGINT_PARSE_ALLOW_UNDERSCORE);
|
||||
|
||||
if (is_negative_number)
|
||||
{
|
||||
|
||||
@@ -985,6 +985,10 @@ parser_error_to_string (parser_error_t error) /**< error code */
|
||||
{
|
||||
return "Missing exponent part.";
|
||||
}
|
||||
case PARSER_ERR_INVALID_UNDERSCORE_IN_NUMBER:
|
||||
{
|
||||
return "Invalid use of underscore character in number literals";
|
||||
}
|
||||
case PARSER_ERR_IDENTIFIER_AFTER_NUMBER:
|
||||
{
|
||||
return "Identifier cannot start after a number.";
|
||||
|
||||
@@ -56,6 +56,7 @@ typedef enum
|
||||
PARSER_ERR_INVALID_NUMBER, /**< invalid number literal */
|
||||
PARSER_ERR_MISSING_EXPONENT, /**< missing exponent */
|
||||
PARSER_ERR_IDENTIFIER_AFTER_NUMBER, /**< identifier start after number */
|
||||
PARSER_ERR_INVALID_UNDERSCORE_IN_NUMBER, /**< invalid use of underscore in number */
|
||||
#if ENABLED (JERRY_BUILTIN_BIGINT)
|
||||
PARSER_ERR_INVALID_BIGINT, /**< number is not a valid BigInt */
|
||||
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright JS Foundation and other contributors, http://js.foundation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
// few valid numeric separators
|
||||
assert (1_1 == 11)
|
||||
assert (0x11_11 == 4369)
|
||||
assert (0b11_11 == 15)
|
||||
assert (0o11_11 == 585)
|
||||
assert (1_1n == 11n)
|
||||
assert (100_001.11_00 == 100001.11)
|
||||
assert (0x11_11n == 4369n)
|
||||
|
||||
// checker functions
|
||||
|
||||
function invalid_numeric_separator (expression)
|
||||
{
|
||||
try {
|
||||
var a = eval (expression)
|
||||
assert (false)
|
||||
} catch (e) {
|
||||
assert (true)
|
||||
}
|
||||
}
|
||||
|
||||
// few invalid numeric separators
|
||||
invalid_numeric_separator ("_1_1")
|
||||
invalid_numeric_separator ("1__1")
|
||||
invalid_numeric_separator ("1_1_n")
|
||||
invalid_numeric_separator ("1_1n_")
|
||||
invalid_numeric_separator ("0b_11")
|
||||
invalid_numeric_separator ("0x_11")
|
||||
invalid_numeric_separator ("0o_11")
|
||||
invalid_numeric_separator ("0_0.123")
|
||||
@@ -3803,56 +3803,6 @@
|
||||
<test id="language/identifiers/start-unicode-8.0.0.js"><reason></reason></test>
|
||||
<test id="language/identifiers/start-unicode-9.0.0-escaped.js"><reason></reason></test>
|
||||
<test id="language/identifiers/start-unicode-9.0.0.js"><reason></reason></test>
|
||||
<test id="language/literals/bigint/numeric-separators/numeric-separator-literal-bil-bd-nsl-bd.js"><reason></reason></test>
|
||||
<test id="language/literals/bigint/numeric-separators/numeric-separator-literal-bil-bd-nsl-bds.js"><reason></reason></test>
|
||||
<test id="language/literals/bigint/numeric-separators/numeric-separator-literal-bil-bds-nsl-bd.js"><reason></reason></test>
|
||||
<test id="language/literals/bigint/numeric-separators/numeric-separator-literal-bil-bds-nsl-bds.js"><reason></reason></test>
|
||||
<test id="language/literals/bigint/numeric-separators/numeric-separator-literal-dd-nsl-dd-one-of.js"><reason></reason></test>
|
||||
<test id="language/literals/bigint/numeric-separators/numeric-separator-literal-dds-nsl-dd.js"><reason></reason></test>
|
||||
<test id="language/literals/bigint/numeric-separators/numeric-separator-literal-hil-hd-nsl-hd.js"><reason></reason></test>
|
||||
<test id="language/literals/bigint/numeric-separators/numeric-separator-literal-hil-hd-nsl-hds.js"><reason></reason></test>
|
||||
<test id="language/literals/bigint/numeric-separators/numeric-separator-literal-hil-hds-nsl-hd.js"><reason></reason></test>
|
||||
<test id="language/literals/bigint/numeric-separators/numeric-separator-literal-hil-hds-nsl-hds.js"><reason></reason></test>
|
||||
<test id="language/literals/bigint/numeric-separators/numeric-separator-literal-hil-od-nsl-od-one-of.js"><reason></reason></test>
|
||||
<test id="language/literals/bigint/numeric-separators/numeric-separator-literal-nzd-nsl-dd-one-of.js"><reason></reason></test>
|
||||
<test id="language/literals/bigint/numeric-separators/numeric-separator-literal-nzd-nsl-dd.js"><reason></reason></test>
|
||||
<test id="language/literals/bigint/numeric-separators/numeric-separator-literal-nzd-nsl-dds.js"><reason></reason></test>
|
||||
<test id="language/literals/bigint/numeric-separators/numeric-separator-literal-oil-od-nsl-od-one-of.js"><reason></reason></test>
|
||||
<test id="language/literals/bigint/numeric-separators/numeric-separator-literal-oil-od-nsl-od.js"><reason></reason></test>
|
||||
<test id="language/literals/bigint/numeric-separators/numeric-separator-literal-oil-od-nsl-ods.js"><reason></reason></test>
|
||||
<test id="language/literals/bigint/numeric-separators/numeric-separator-literal-oil-ods-nsl-od.js"><reason></reason></test>
|
||||
<test id="language/literals/bigint/numeric-separators/numeric-separator-literal-oil-ods-nsl-ods.js"><reason></reason></test>
|
||||
<test id="language/literals/bigint/numeric-separators/numeric-separator-literal-sign-minus-dds-nsl-dd.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-bil-bd-nsl-bd.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-bil-bd-nsl-bds.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-bil-bds-nsl-bd.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-bil-bds-nsl-bds.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-dd-dot-dd-ep-sign-minus-dd-nsl-dd.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-dd-dot-dd-ep-sign-minus-dds-nsl-dd.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-dd-dot-dd-ep-sign-plus-dd-nsl-dd.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-dd-dot-dd-ep-sign-plus-dds-nsl-dd.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-dd-nsl-dd-one-of.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-dds-dot-dd-nsl-dd-ep-dd.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-dds-nsl-dd.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-dot-dd-nsl-dd-ep.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-dot-dd-nsl-dds-ep.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-dot-dds-nsl-dd-ep.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-dot-dds-nsl-dds-ep.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-hil-hd-nsl-hd.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-hil-hd-nsl-hds.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-hil-hds-nsl-hd.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-hil-hds-nsl-hds.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-hil-od-nsl-od-one-of.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-nzd-nsl-dd-one-of.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-nzd-nsl-dd.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-nzd-nsl-dds.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-oil-od-nsl-od-one-of.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-oil-od-nsl-od.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-oil-od-nsl-ods.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-oil-ods-nsl-od.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-oil-ods-nsl-ods.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-sign-minus-dds-nsl-dd.js"><reason></reason></test>
|
||||
<test id="language/literals/numeric/numeric-separators/numeric-separator-literal-sign-plus-dds-nsl-dd.js"><reason></reason></test>
|
||||
<test id="language/literals/regexp/named-groups/forward-reference.js"><reason></reason></test>
|
||||
<test id="language/literals/regexp/unicode-escape-nls-err.js"><reason></reason></test>
|
||||
<test id="language/literals/string/legacy-octal-escape-sequence-prologue-strict.js"><reason></reason></test>
|
||||
|
||||
@@ -75,7 +75,7 @@ main (void)
|
||||
i < sizeof (nums) / sizeof (nums[0]);
|
||||
i++)
|
||||
{
|
||||
ecma_number_t num = ecma_utf8_string_to_number (strings[i], lit_zt_utf8_string_size (strings[i]));
|
||||
ecma_number_t num = ecma_utf8_string_to_number (strings[i], lit_zt_utf8_string_size (strings[i]), 0);
|
||||
|
||||
if (num != nums[i]
|
||||
&& (!ecma_number_is_nan (num)
|
||||
|
||||
Reference in New Issue
Block a user