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

LibJS: Implement the "Change Array by copy" stage 3 proposal #14270

Merged
merged 8 commits into from
Jun 13, 2022

Conversation

linusg
Copy link
Member

@linusg linusg commented Jun 13, 2022

Part 1: Array.prototype functions

@linusg linusg requested review from davidot, IdanHo and Lubrsi June 13, 2022 16:28
Copy link
Member

@davidot davidot left a comment

Choose a reason for hiding this comment

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

Nice work, couldn't really find anything but tiny nitpicks. And one commit order problem

Also while you're at it you could rename groupBy to group which was another new thing in the last meeting

Copy link
Member

@Lubrsi Lubrsi left a comment

Choose a reason for hiding this comment

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

Looks good from having a quick glance over. I noticed that the tests don't check the contents of the original array are unmodified.

@Lubrsi
Copy link
Member

Lubrsi commented Jun 13, 2022

I just noticed while watching the video that this is missing tests for unscopable for all of the functions except with. Here's an example one:

test("is unscopable", () => {
expect(Array.prototype[Symbol.unscopables].groupBy).toBeTrue();
const array = [];
with (array) {
expect(() => {
groupBy;
}).toThrowWithMessage(ReferenceError, "'groupBy' is not defined");
}
});

@Lubrsi
Copy link
Member

Lubrsi commented Jun 13, 2022

Same for null and undefined this values, which ToObject throws on:

test("null or undefined this value", () => {
expect(() => {
Array.prototype.groupBy.call();
}).toThrowWithMessage(TypeError, "ToObject on null or undefined");
expect(() => {
Array.prototype.groupBy.call(undefined);
}).toThrowWithMessage(TypeError, "ToObject on null or undefined");
expect(() => {
Array.prototype.groupBy.call(null);
}).toThrowWithMessage(TypeError, "ToObject on null or undefined");
});

@linusg linusg force-pushed the libjs-change-array-by-copy branch from d2b316e to aedf8cd Compare June 13, 2022 18:39
@linusg
Copy link
Member Author

linusg commented Jun 13, 2022

Thanks for the review both! I think I have all suggestions implemented 👍

@linusg linusg force-pushed the libjs-change-array-by-copy branch from aedf8cd to 7b5f94a Compare June 13, 2022 19:06
@linusg linusg merged commit 698062b into SerenityOS:master Jun 13, 2022
@linusg linusg deleted the libjs-change-array-by-copy branch June 13, 2022 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants