-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement parseInt() #167
Implement parseInt() #167
Conversation
int32_t first_nonws = -1; | ||
for (int i = 0; i < string_len; i++) | ||
{ | ||
if (!(zt_string_buff[i] == ' ' || zt_string_buff[i] == '\n')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that these two are enough, the standard says StrWhiteSpaceChar which also contains things like '\t', '\r' etc..
I've updated the PR. |
assert(parseInt("12A3") === 12); | ||
assert(parseInt("12.34") === 12); | ||
assert(isNaN(parseInt("AB"))); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should have test cases where we pass other things like: boolean values, numbers, arrays, empty objects, undefined values for both first and second argument.
LGTM |
I've added more test cases. |
|
||
/* 6. */ | ||
ECMA_OP_TO_NUMBER_TRY_CATCH (radix_num, radix, ret_value); | ||
int32_t r = ecma_number_to_int32 (radix_num); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rad
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai [email protected]
@egavrin, I fixed the style issues. |
Good to me. |
lgtm |
merged: 35840a4 |
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai [email protected]