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 "Change Array by Copy" tests (stage 3) #3464
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intended that [].with
always throws, no matter what arguments are passed?
test/built-ins/Array/prototype/with/index-bigger-or-eq-than-length.js
Outdated
Show resolved
Hide resolved
test/built-ins/Array/prototype/with/index-smaller-than-minus-length.js
Outdated
Show resolved
Hide resolved
test/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js
Outdated
Show resolved
Hide resolved
test/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js
Outdated
Show resolved
Hide resolved
test/built-ins/Array/prototype/with/length-exceeding-array-length-limit.js
Outdated
Show resolved
Hide resolved
@nicolo-ribaudo I'm not going to ask you to move the files out of the |
test/built-ins/Array/prototype/toReversed/get-descending-order.js
Outdated
Show resolved
Hide resolved
test/built-ins/Array/prototype/toReversed/get-descending-order.js
Outdated
Show resolved
Hide resolved
test/built-ins/Array/prototype/toReversed/holes-not-preserved.js
Outdated
Show resolved
Hide resolved
test/built-ins/Array/prototype/toReversed/holes-not-preserved.js
Outdated
Show resolved
Hide resolved
Yep that is intentional. There are no valid indexes to change for an empty array. And passing no arguments or |
Does it make sense to add tests to ensure that I don't know if this is the type of thing that test262 would test or not? Thoughts @nicolo-ribaudo, @rwaldron, @ljharb ? |
I think it falls into the kind of category where it's one of the infinite things the spec doesn't permit and thus implicitly forbids - but unless there's an implementation that has that bug, we wouldn't necessarily need a test for it. |
thanks @ljharb! Makes sense 😀 |
@rwaldron i mean, not necessarily - an implementation could potentially replace some of the steps with an observable call to another builtin method. in this case, some of my polyfills did that, and i had to revert that optimization because it broke some tests, so we're probably fine :-) |
Updated, I'm sorry that it took a while! Fyi, we are running these tests at tc39/proposal-change-array-by-copy#83 to make sure that they respect the behavior of the "reference implementation" (which matches 1:1 the spec). @rwaldron If you have any suggestion about how I should rename those files let me know (I think I copied the |
test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js
Outdated
Show resolved
Hide resolved
test/built-ins/Array/prototype/toSorted/comparefn-stop-after-error.js
Outdated
Show resolved
Hide resolved
@nicolo-ribaudo i think this needs to be updated and rebased |
This comment was marked as outdated.
This comment was marked as outdated.
512c7a6
to
71a83f7
Compare
@rwaldron Could you let me know if I've addressed your comments adequately? Thanks! |
EDIT: DONE TODO: we should add a new test to cover yesterdays spec change tc39/proposal-change-array-by-copy#85 maybe something like: let userLandCodeCalled = false;
const arr = new Uint8Array(2);
const nonPureValue = {
valueOf() {
userLandCodeCalled = true;
arr[0] = 1;
return 2;
}
};
const indexToChange = 1;
const changed = arr.with(indexToChange, nonPureValue);
assert(userLandCodeCalled);
assertEqual(changed[0], 1); // the copy should include the mutation (previously would have returned 0)
assertEqual(changed[1], 2); |
5ac196d
to
dece7fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial review.
test/built-ins/Array/prototype/Symbol.unscopables/change-array-by-copy.js
Outdated
Show resolved
Hide resolved
test/built-ins/Array/prototype/toReversed/length-integer-string.js
Outdated
Show resolved
Hide resolved
test/built-ins/Array/prototype/toReversed/this-value-boolean.js
Outdated
Show resolved
Hide resolved
test/built-ins/Array/prototype/toSorted/comparefn-called-after-get-elements.js
Outdated
Show resolved
Hide resolved
test/built-ins/Array/prototype/toReversed/this-value-boolean.js
Outdated
Show resolved
Hide resolved
.../built-ins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js
Outdated
Show resolved
Hide resolved
test/built-ins/Array/prototype/toSpliced/deleteCount-undefined.js
Outdated
Show resolved
Hide resolved
…ther elements of the array
…ests Use CompareArray in typed array tests Check BigInts and detached buffers as invalid `this` values in this-value-invalid tests Delete length property after overriding in length-property-ignored.js
cfd6eb0
to
d0c6700
Compare
…lid.js Co-authored-by: Ms2ger <Ms2ger@gmail.com>
…d.js Co-authored-by: Ms2ger <Ms2ger@gmail.com>
…-by-copy.js Co-authored-by: Ms2ger <Ms2ger@gmail.com>
da6ea35
to
2f9b3d9
Compare
2f9b3d9
to
b8c381f
Compare
@Ms2ger I think I've addressed all your comments. Github still says "1 change requested" by you, but I can't find it anywhere even after expanding all the resolved conversations :/ |
Let's move any further work to new PRs. |
This PR adds tests for https://github.com/tc39/proposal-change-array-by-copy, which reached consensus for Stage 3 at the March 2022 meeting.
I'm marking it as draft because I wrote these tests a few months ago, so I need to check that they are up-to-date with the current specification.
cc @acutmore @catamorphism