Fix parseFloat built-in function of the Global object.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
@@ -531,31 +531,35 @@ ecma_builtin_global_object_parse_float (ecma_value_t this_arg __attr_unused___,
|
||||
if (str_curr_p < str_end_p)
|
||||
{
|
||||
current = *str_curr_p;
|
||||
}
|
||||
|
||||
/* Check decimal point. */
|
||||
if (current == LIT_CHAR_DOT && str_curr_p < str_end_p)
|
||||
{
|
||||
current = *(++str_curr_p);
|
||||
|
||||
if (lit_char_is_decimal_digit (current))
|
||||
/* Check decimal point. */
|
||||
if (current == LIT_CHAR_DOT)
|
||||
{
|
||||
has_fraction_part = true;
|
||||
str_curr_p++;
|
||||
|
||||
/* Check digits of fractional part. */
|
||||
while (str_curr_p < str_end_p)
|
||||
if (str_curr_p < str_end_p)
|
||||
{
|
||||
current = *str_curr_p++;
|
||||
if (!lit_char_is_decimal_digit (current))
|
||||
current = *str_curr_p;
|
||||
|
||||
if (lit_char_is_decimal_digit (current))
|
||||
{
|
||||
str_curr_p--;
|
||||
break;
|
||||
has_fraction_part = true;
|
||||
|
||||
/* Check digits of fractional part. */
|
||||
while (str_curr_p < str_end_p)
|
||||
{
|
||||
current = *str_curr_p++;
|
||||
if (!lit_char_is_decimal_digit (current))
|
||||
{
|
||||
str_curr_p--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set end position to end of fraction part. */
|
||||
end_p = str_curr_p;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set end position to end of fraction part. */
|
||||
end_p = str_curr_p;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ assert(parseFloat("1.2e3") === 1200);
|
||||
assert(parseFloat("+1.2e3") === 1200);
|
||||
assert(parseFloat("-1.2e3") === -1200);
|
||||
assert(parseFloat(" \n\t 1.2e3") === 1200);
|
||||
assert(parseFloat("03.02e1") === 30.2);
|
||||
assert(parseFloat("003.") === 3);
|
||||
assert(parseFloat(".2e3") === 200);
|
||||
assert(parseFloat("1.e3") === 1000);
|
||||
assert(parseFloat("1.2e") === 1.2);
|
||||
|
||||
Reference in New Issue
Block a user