-
Notifications
You must be signed in to change notification settings - Fork 858
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 various missing methods in TypedArray
#1524
Implement various missing methods in TypedArray
#1524
Conversation
Since most methods were already implemented in `NativeArray`, I followed this approach: - when reasonable, I extracted the implementation in `NativeArray` and moved it to a new class `ArrayLikeAbstractOperations`; - otherwise, I copy&pasted the code from `NativeArray` into `NativeTypedArrayView` and simplified it.
Thanks 🙂
For #1411 it implements the "old" methods, i.e. not the ones added by ES2024. Therefore it also does not implement #1307 (because I felt that it's better to do a single implementation, for both normal and typed arrays).
It does not. I have only added new methods, not fixed existing ones. |
Great!
|
Besides makes a wack of tests from test262 pass, based on the diff of the test262.priperties file it seem it also breaks a bunch of tests that previously passed. What's up with those? |
We implement almost correctly [TypedArraySpeciesCreate](https://tc39.es/ecma262/multipage/indexed-collections.html#typedarray-species-create) from the spec now, which leads to passing more test262 cases passing.
ce1f70c
to
381e94b
Compare
Thanks for pointing this out, I somehow missed it. There were three categories of failing tests:
|
For the 2nd item,: you means something additional needs to be implemented here? If so, could you create a new case about what needs to be implemented? |
The state of things in test262.properties seems ok now. But I do see a recurring theme on failing tests for methods, like:
Any chance you could make a follow-up case for fixing whichever of those failing tests could be fixed by some TLC? |
Opened #1527
Created #1528 |
I think this is a good change in general, but it still looks like we fixed many test262 tests that were previously broken, but we still broke test262 tests that previously worked. I understand the issues above about "detached" support, but I'm not excited about merging this if it breaks tests that currently work. Is there anything that we can do here, or do others want to merge this and then fix the broken tests later? |
I think the reason is clear by looking at the test case code, and not just at the The first category of tests are the ones about the detached, for example: testWithTypedArrayConstructors(function(TA) {
var ta;
function detachAndReturnIndex(){
$DETACHBUFFER(ta.buffer);
return 900;
}
var array = [];
array.length = 10000; // big arrays are more likely to cause a crash if they are accessed after they are freed
array.fill(7, 0);
ta = new TA(array);
assert.throws(TypeError, function(){
ta.copyWithin(0, 100, {valueOf : detachAndReturnIndex});
}, "should throw TypeError as array is detached");
}); Previously this test was passing because the function The other category of tests now broken are those in the directory testWithTypedArrayConstructors(function(TA) {
assert.sameValue(TA.prototype.hasOwnProperty("lastIndexOf"), false);
}); This fails because the functions are now defined. The |
Does seem like there are a bunch of odd ones that are now seemingly broken Besides the detached buffer ones for example:
The detached buffer ones are also strange: if they never passed, why weren't they recorded in test262.properties before? Does that mean something is amiss in our test262Suite? So I agree this needs to be looked at before merging |
@andreabergia so our comments overlapped a bit, time-wise What about tests like prototype/map/species/ctor-get-species-custom-ctor-length-throws.js? Why are those now reported as failing? |
Same as the others - there are three tests like these: map, filter, slice. All of these do something like the following: testWithTypedArrayConstructors(function(TA) {
var sample = new TA(2);
sample.constructor = {};
sample.constructor[Symbol.species] = function() {
return new TA();
};
assert.throws(TypeError, function() {
sample.map(function() { return 0; });
});
}); Before this PR, they are "passing" because the |
@gbrail to answer your earlier question: I think the seemingly breaking tests aren't actual breakages. Instead, due to how those test are authored, they previously returned false positives So i think this PR is good to go, from a test262 perspective |
agree with @p-bakker looks fine for me and another great step forward +1 for merge and many thanks @andreabergia |
Thanks! I resolved the conflict and merged this manually. Great progress! |
Since most methods were already implemented in
NativeArray
, I followed this approach:NativeArray
and moved it to a new classArrayLikeAbstractOperations
;NativeArray
intoNativeTypedArrayView
and simplified it.