Skip to content

Implement String.prototype.split function #530

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

Merged
merged 1 commit into from
Aug 7, 2015

Conversation

bzsolt
Copy link
Member

@bzsolt bzsolt commented Aug 5, 2015

JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com

@bzsolt bzsolt force-pushed the string-prototype-split branch from b27c817 to 704f1df Compare August 5, 2015 14:20
@ILyoan ILyoan mentioned this pull request Aug 6, 2015
25 tasks
@LaszloLango LaszloLango added ecma builtins Related to ECMA built-in routines development Feature implementation labels Aug 6, 2015
@LaszloLango LaszloLango added this to the ECMA builtins milestone Aug 6, 2015
ecma_string_t *magic_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_INDEX);
ecma_property_t *index_prop_p = ecma_find_named_property (obj_p, magic_str_p);

JERRY_ASSERT (index_prop_p != NULL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ecma_get_named_property could be used in the case. The version includes assertion from line 1715.

@bzsolt bzsolt force-pushed the string-prototype-split branch from 704f1df to 976500d Compare August 6, 2015 12:13
@bzsolt
Copy link
Member Author

bzsolt commented Aug 6, 2015

I've fixed the mentoined parts.

@ruben-ayrapetyan
Copy link
Contributor

@bzsolt, thank you!

I've got no other comments.

{
assert (e instanceof ReferenceError);
assert (e.message === "foo");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont see a similar test from the spec:

"A<B>bold</B>and<CODE>coded</CODE>".split(/<(\/)?([^<>]+)>/) ->
["A", undefined, "B", "bold", "/", "B", "and", undefined, "CODE", "coded", "/", "CODE", ""]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I've implemented the missing part and added a related testcase (what you wrote).
Thanks.

@sand1k
Copy link
Contributor

sand1k commented Aug 7, 2015

LGTM.

@sand1k sand1k assigned bzsolt and unassigned sand1k Aug 7, 2015
@bzsolt bzsolt force-pushed the string-prototype-split branch from 976500d to 5277461 Compare August 7, 2015 12:25
@bzsolt
Copy link
Member Author

bzsolt commented Aug 7, 2015

@ruben-ayrapetyan @sand1k
Could you please also check this PR, because I've added an additional part. 13.c.iii.7

ecma_string_t *idx_str_p = ecma_new_ecma_string_from_uint32 (i);
ecma_string_t *new_array_idx_str_p = ecma_new_ecma_string_from_uint32 (new_array_length);

ecma_completion_value_t match_comp_value = ecma_op_object_get (match_array_obj_p, idx_str_p);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this operation throw an exception?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should never throw an exception. I've added an extra assert to make sure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Thank you.

JerryScript-DCO-1.0-Signed-off-by: Zsolt Borbély zsborbely.u-szeged@partner.samsung.com
@bzsolt bzsolt force-pushed the string-prototype-split branch from 5277461 to 640370d Compare August 7, 2015 14:07
@ruben-ayrapetyan
Copy link
Contributor

I've got no other comments.

@ruben-ayrapetyan ruben-ayrapetyan assigned sand1k and unassigned bzsolt Aug 7, 2015
@galpeter
Copy link
Contributor

galpeter commented Aug 7, 2015

lgtm

@galpeter galpeter merged commit 640370d into jerryscript-project:master Aug 7, 2015
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.

7 participants