Tracking issue for new `set` methods.
The set methods proposal has landed in the specification. These methods need to be implemented for our conformance.
Fore reference, the archived proposal repository can be found here. Although, the methods are also currently in the ECMAScript spec.
Methods that need to be implemented
- [x] 24.2.4.5 Set.prototype.difference ( other )
- [x] 24.2.4.9 Set.prototype.intersection ( other )
- [x] 24.2.4.10 Set.prototype.isDisjointFrom ( other )
- [x] 24.2.4.11 Set.prototype.isSubsetOf ( other )
- [x] 24.2.4.12 Set.prototype.isSupersetOf ( other )
- [x] 24.2.4.15 Set.prototype.symmetricDifference ( other )
- [x] 24.2.4.16 Set.prototype.union ( other )
Hello, I would like to try solving this task!
Sure! Assigned it to you. Feel free to reach out if you have any questions :smile:
Hello, I have encountered an issue with two methods: Set.prototype.intersection(other) and Set.prototype.difference(other). When I ask it to check the following: ```rust fn difference_empty(){ run_test_actions([ TestAction::run(indoc! {r#" let setA = new Set([1, 3, 5, 7, 9]); let setB = new Set([]); "#}),
TestAction::assert_with_op("setA.difference(setB)", |v, _| {
v.display().to_string() == "Set { 1, 3, 5, 7, 9 }"
}),
TestAction::assert_with_op("setB.difference(setA)", |v, _| {
v.display().to_string() == "Set { }"
}),
]);
}``` And specifically, the check fails when we try to perform one of these operations on a non-empty set. Perhaps I wrote the test incorrectly, missed some logic, or didn't fully understand how to correctly return the result. If you could point out where I got stuck or what I did wrong, it would greatly help me in my further work.
I took a look at the branch that you're working on, and I think the implementations may be a bit optimistic at current for the specification, especially in these two methods.
My recommendation would be to copy and paste the specification steps and then work through them individually with a Boa like internal (if you'd like a good example of this in the engine, I'd recommend many of the Array methods).
The specification has a couple of sneaky user land calls that are worked into the specification that means following the steps, especially in certain locations may be fairly important.
For instance, test262 has a test for a set-like object and set-like class.
Also, if it wasn't for the userland calls, I'd recommend taking a look at IndexSet docs as it already has implementations of
the methods that might be implementable on OrderedSet.
Also, an early comment would be: these are methods, so they should be added to the BuiltinBuilder as .method(Self::difference, "difference", 1) over defining them as properties.
Hello, i am done this tasks and create pull requests #4145
Completed and all tests are passing on the conformance page.