-
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
Add Array.findLast
and findLastIndex
from ES2023
#1557
Conversation
cea8320
to
891f01f
Compare
Maybe rebase and then merge after #1540 is merged then |
Yes indeed -- there are now test262 tests that will run these methods and it looks like many of them will pass. Can you please rebase to the latest to pick up the new test262 updates (don't forget to "git submodule update") and update the properties file? Thanks! |
891f01f
to
cd22eaa
Compare
Rebased on top of master - now passes some of the new test262 cases (it seems the same set of tests passed by |
Thanks -- this is great progress. Now, I see that we can mark a lot of the test262 tests as passing now, but looking in test262.properties under prototype/findLastIndex and prototype/findLast, there are still lots of tests that fail. Have you been able to go through those and see if we can make more of them pass? Now that we added a new feature, it'd be important to either make all of them pass or understand why some of them still fail (usually because of unimplemented stuff elsewhere in Rhino). |
@andreabergia just FYI: saw you recently submitted several PRs related to (Typed)Arrays. I've scourged the backlog and tagged all cases related to arrays with the |
To what extent are the testcases for which tests are included in this PR not already covered by test262? iMHO we do not need to duplicate testcases already covered by test262 with own tests |
At least i find id simpler to debug this extra cases instead of the 262 ones |
I too have found it useful to have a set of simple test cases to get a few feature up and running, and then use test262 to get all the details right later. I don't mind if those kinds of test cases get checked in. |
BTW this one needs one more rebase... Sorry but things are moving relatively fast! |
It's not obvious from the PR, but if you look at the file you can see that the test cases that don't pass for the new methods
I haven't really investigated them, honestly.
I literally copied those for |
cd22eaa
to
1c9be7f
Compare
The quoted failures boils down to:
For all these we have cases But there also seen to be changes to the test results of Array.prototype.flat/flatMap, which doesn't look correct I'd say |
Also implement these methods for the typed arrays variants.
1c9be7f
to
7e652a0
Compare
That was just an issue with the last rebase 🙂 Hopefully the CI build will be clean now |
Indeed looks good now Only question I have left is: why are there more test failing for the same method on TypedArray vs. regular Array? For example:
If there's a valid reason for those to fail currently, are there already cases to address them? If not, I think we should create those |
The common problem that many tests on TypedArray have is that we lack one level of prototype - this returns Object.getPrototypeOf(Int8Array).prototype The reason is that all the typed array classes should have the same prototype, i.e. the following should evaluate to true, but it does not in Rhino: Object.getPrototypeOf(Int8Array).prototype !== undefined &&
Object.getPrototypeOf(Int8Array).prototype == Object.getPrototypeOf(Uint8Array).prototype I've looked a bit into this and it does not look trivial to fix. |
Whether it's trivial or not idk, but pretty sure we don't have a case for that yet. Looks like the TypedArray intrinsic/prototype ought to provide stuff like for example the from and of methods. I assume we're lacking those as well? |
Exactly - all the methods, in rhino, are defined on I've created #1565 |
It looks to me like this is a good PR and that it goes as far as we can without a more thorough rewrite of the native array stuff. Unless there are some objections I'd like to merge it. Thanks for all the work on this! |
Also implement it for the typed arrays variants.
There are no test262 changes because our version of test262 is old and does not contain them yet. 🙂
The tests I've added are basically adaptation of the existing tests for
find
andfindIndex
.Should fix #1241.