Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Implement parseInt() #167

wants to merge 1 commit into from

Conversation

dbatyai
Copy link
Member

@dbatyai dbatyai commented Jun 10, 2015

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai [email protected]

@dbatyai dbatyai added ecma builtins Related to ECMA built-in routines development Feature implementation labels Jun 10, 2015
@galpeter galpeter mentioned this pull request Jun 10, 2015
29 tasks
int32_t first_nonws = -1;
for (int i = 0; i < string_len; i++)
{
if (!(zt_string_buff[i] == ' ' || zt_string_buff[i] == '\n'))
Copy link
Contributor

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..

@dbatyai
Copy link
Member Author

dbatyai commented Jun 11, 2015

I've updated the PR.

assert(parseInt("12A3") === 12);
assert(parseInt("12.34") === 12);
assert(isNaN(parseInt("AB")));

Copy link
Contributor

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.

@LaszloLango
Copy link
Contributor

LGTM

@dbatyai
Copy link
Member Author

dbatyai commented Jun 15, 2015

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);
Copy link
Contributor

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]
@dbatyai
Copy link
Member Author

dbatyai commented Jun 16, 2015

@egavrin, I fixed the style issues.

@egavrin
Copy link
Contributor

egavrin commented Jun 16, 2015

Good to me.

@egavrin egavrin assigned dbatyai and unassigned ruben-ayrapetyan Jun 16, 2015
@kkristof
Copy link
Contributor

lgtm

@dbatyai
Copy link
Member Author

dbatyai commented Jun 17, 2015

merged: 35840a4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Feature implementation ecma builtins Related to ECMA built-in routines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants