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

Set union tests #3816

Merged
merged 22 commits into from
Nov 15, 2023
Merged

Set union tests #3816

merged 22 commits into from
Nov 15, 2023

Conversation

frehner
Copy link
Contributor

@frehner frehner commented Apr 12, 2023

Hello! First time code contributor here, so please feel free to correct anything and everything that I'm doing. I appreciate your time. ❤️


This is the very beginnings of helping with #3738 . I'm hoping that I can be helpful here, but there are still quite a bit that I'm missing and unsure on how to do.

If it helps, there's also an associated engine262 PR here engine262/engine262#212 where I've done a basic implementation of the spec and have been using it to validate these tests so far.

In any case, I figured this was a good place to stop and get feedback before moving on further. I want to make sure that I'm not doing something wrong or using patterns that are incorrect.

Thanks again!

Copy link
Member

@ljharb ljharb 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 to me so far! Feel free to look at https://github.com/es-shims/Set.prototype.union in case there's any tests there you haven't covered.

@frehner
Copy link
Contributor Author

frehner commented Apr 17, 2023

I noticed that the Set.prototype.add test suite has tests on the this value and RequireInternalSlot steps. Should I do the same for union?

e.g.

1. Let O be the this value.
2. Perform ? RequireInternalSlot(O, [[SetData]]).

@ptomato
Copy link
Contributor

ptomato commented Apr 19, 2023

That's correct, pretty much every public API has a set of boilerplate tests that include tests for those steps. Here's a list that I keep in my notes of boilerplate tests, with links to examples:

@frehner frehner mentioned this pull request Apr 24, 2023
18 tasks
@frehner
Copy link
Contributor Author

frehner commented May 8, 2023

Would these tests need to have a features flag in the frontmatter?

@ptomato
Copy link
Contributor

ptomato commented May 9, 2023

That's right. It looks like there isn't a feature defined in features.txt yet, so that would also need to be added.

@frehner
Copy link
Contributor Author

frehner commented May 9, 2023

I'll add it here, then! Should I go for something generic set-methods (so it can be used for the other methods as well) or more specific Set.prototype.union?

@ptomato
Copy link
Contributor

ptomato commented May 9, 2023

Feature flags are generally per-proposal.

@frehner
Copy link
Contributor Author

frehner commented May 12, 2023

Ok, I think these tests for Set.prototype.union are ready. How would you like me to proceed? Should I mark this as ready for review, or would you like me to implement tests for the other new methods as part of this PR?

@ptomato
Copy link
Contributor

ptomato commented May 18, 2023

I think that's mainly a question of what you prefer, as the test writer. Certainly it's OK to merge a PR that provides some but not all of the tests listed in #3738, as long as we keep track in that issue what's been done and what's left to do.

@frehner
Copy link
Contributor Author

frehner commented May 22, 2023

Left a comment here on what I've implemented and not yet implemented (only 3 bullet points not implemented by this PR). 

I think I'll mark this as ready for review and can follow up on those 3 bullet points when I'm a little more clear on what I need to do on them. 👍

@frehner frehner marked this pull request as ready for review May 22, 2023 20:03
@frehner frehner requested a review from a team as a code owner May 22, 2023 20:03
@jugglinmike
Copy link
Contributor

Hi there, @frehner! I see that you received some direction from Kevin over in gh-3738; did you want to incorporate that here in this patch? There's no rush--I just don't want to merge this prematurely.

@frehner
Copy link
Contributor Author

frehner commented May 31, 2023

Hi there, @frehner! I see that you received some direction from Kevin over in gh-3738; did you want to incorporate that here in this patch? There's no rush--I just don't want to merge this prematurely.

Yeah! I'll try to get to it hopefully this weekend, if that's ok.

@frehner
Copy link
Contributor Author

frehner commented Jun 4, 2023

Ok I think I got it all now. 😅

Copy link
Contributor

@bakkot bakkot left a comment

Choose a reason for hiding this comment

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

LGTM other than nit. Thanks!

test/built-ins/Set/GetSetRecord/keys-is-callable.js Outdated Show resolved Hide resolved
test/built-ins/Set/prototype/union/add-not-called.js Outdated Show resolved Hide resolved
@frehner
Copy link
Contributor Author

frehner commented Jun 20, 2023

Not sure what's with the failing CI check graaljs, any pointers there would be helpful.

GraalJS ❯ Downloading https://github.com/oracle/graaljs/releases/download/vm-23.0.0/graaljs-23.0.0-linux-amd64.tar.gz
esvu ✖ Error: Got 404
    at /home/circleci/test262/node_modules/esvu/src/installer.js:69:17
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Function.install (/home/circleci/test262/node_modules/esvu/src/installer.js:66:30)
    at async installEngine (/home/circleci/test262/node_modules/esvu/src/bin.js:121:3)
    at async main (/home/circleci/test262/node_modules/esvu/src/bin.js:168:7)
esvu ✖ Some engines were not installed.

@bakkot
Copy link
Contributor

bakkot commented Jun 20, 2023

The graal failures are unrelated to this PR - at a glance, it looks like it's caused by that project switching from having their releases tagged like vm-X.X.X to having them tagged like graal-X.X.X in their most recent release (last week).

(Edit: opened esvu issue.)

@ljharb
Copy link
Member

ljharb commented Jun 21, 2023

I rebased the PR, and ran it against my set method polyfills, and everything's passing, as expected.

@frehner
Copy link
Contributor Author

frehner commented Jul 12, 2023

Just a followup here: anything I need to do?

@ptomato
Copy link
Contributor

ptomato commented Jul 13, 2023

Just a followup here: anything I need to do?

Afraid not; the bottleneck at this point is maintainer availability for a review. Thanks @bakkot for also reviewing it, though; that's helpful!

Copy link
Contributor

@Ms2ger Ms2ger left a comment

Choose a reason for hiding this comment

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

All requests for more test coverage can be deferred, but if you do, please add a checklist to the tracking issue.

test/built-ins/Set/GetSetRecord/called-with-object.js Outdated Show resolved Hide resolved
test/built-ins/Set/GetSetRecord/called-with-object.js Outdated Show resolved Hide resolved
test/built-ins/Set/GetSetRecord/has-is-callable.js Outdated Show resolved Hide resolved
test/built-ins/Set/GetSetRecord/has-is-callable.js Outdated Show resolved Hide resolved
test/built-ins/Set/GetSetRecord/has-is-callable.js Outdated Show resolved Hide resolved
test/built-ins/Set/prototype/union/set-like-class-order.js Outdated Show resolved Hide resolved
test/built-ins/Set/prototype/union/set-like-class-order.js Outdated Show resolved Hide resolved
@bakkot
Copy link
Contributor

bakkot commented Nov 8, 2023

I can take this over so we can get this landed and engines can start shipping.

@frehner
Copy link
Contributor Author

frehner commented Nov 8, 2023

I can take this over so we can get this landed and engines can start shipping.

Thanks - I currently don't have capacity to work on this at the moment, but would have time in perhaps a couple of months.

@bakkot
Copy link
Contributor

bakkot commented Nov 12, 2023

Thanks for your thorough review @Ms2ger. I believe I've addressed all your comments.

If this is approved I'll follow up with tests for the other methods.

// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-getsetrecord
description: GetSetRecord if the Set-like object has a size of 'undefined' an error is thrown
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
description: GetSetRecord if the Set-like object has a size of 'undefined' an error is thrown
description: GetSetRecord throws an exception if the Set-like object has a size that is coerced to NaN

// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-getsetrecord
description: GetSetRecord if the Set-like object's 'has' property is not callable an error is thrown
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
description: GetSetRecord if the Set-like object's 'has' property is not callable an error is thrown
description: GetSetRecord throws an exception if the Set-like object's 'has' property is not callable

// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-getsetrecord
description: GetSetRecord if the Set-like object's 'keys' property is not callable an error is thrown
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
description: GetSetRecord if the Set-like object's 'keys' property is not callable an error is thrown
description: GetSetRecord throws an exception if the Set-like object's 'keys' property is not callable

function () {
s1.union(s2);
},
"GetSetRecord throws an error when has is not callable"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"GetSetRecord throws an error when has is not callable"
"GetSetRecord throws an error when has is undefined"

function () {
s1.union(s2);
},
"GetSetRecord throws an error when keys is not callable"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"GetSetRecord throws an error when keys is not callable"
"GetSetRecord throws an error when keys is undefined"

Comment on lines 18 to 27
const s2 = {
size: 2,
has: function () {
throw new Test262Error("Set.prototype.union should not invoke .has on its argument");
},
keys: function* keys() {
yield 2;
yield 3;
},
};
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm afraid you went a bit too far here - this is now basically a duplicate of test/built-ins/Set/prototype/union/allows-set-like-object.js, while the file name suggests that it should cover a class

const evilSetLike = {
size: 2,
get has() {
baseSet.add("q");
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be

Suggested change
baseSet.add("q");
baseSet.delete("q");

?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, actually I meant to use add but change the expectations for the resulting sets. Not sure how I made that mistake...

// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-set.prototype.union
description: Set.prototype.union function properties
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
description: Set.prototype.union function properties
description: Set.prototype.union length property

// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-set.prototype.union
description: Set.prototype.union name properties
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
description: Set.prototype.union name properties
description: Set.prototype.union name property

@bakkot
Copy link
Contributor

bakkot commented Nov 15, 2023

@Ms2ger Done.

@Ms2ger Ms2ger enabled auto-merge (squash) November 15, 2023 16:53
@Ms2ger Ms2ger merged commit 60310b7 into tc39:main Nov 15, 2023
8 of 9 checks passed
@bakkot bakkot mentioned this pull request Nov 26, 2023
7 tasks
@frehner frehner deleted the set-union-tests branch July 17, 2024 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants