Skip to content

tests for Iterator.prototype.join - #4768

Merged
ptomato merged 3 commits into
mainfrom
iterator-join
Jul 27, 2026
Merged

tests for Iterator.prototype.join#4768
ptomato merged 3 commits into
mainfrom
iterator-join

Conversation

@bakkot

@bakkot bakkot commented Dec 8, 2025

Copy link
Copy Markdown
Member

Fixes #4697.

Tested against a polyfill.

@bakkot
bakkot requested review from a team as code owners December 8, 2025 03:03
@bakkot bakkot mentioned this pull request Dec 8, 2025
14 tasks
Comment thread test/built-ins/Iterator/prototype/join/separator-tostring.js
Iterator.prototype.join.call(it, throwy);
});

assert.sameValue(gotNext, false);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
assert.sameValue(gotNext, false);
assert(!gotNext);

?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Arguably this is more readable in terms of the failures you get. Certainly it is not worse. In any case I don't think it's worth changing.

var coercible = {
toString: function () {
if (called) {
throw new Test262Error('toString should be called exactly once');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To assert exactly-once behaviour, I would just use a counter and assert on the counter at the end.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That is also a valid way to do it but I'm happy with this as-is.

lando-worker Bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Apr 28, 2026
These are from tc39/test262#4768 which is
currently under review. Once the tests land upstream, these can be
removed. This will be handled as part of shipping the feature when
it reaches Stage 3.

Differential Revision: https://phabricator.services.mozilla.com/D296726

@ptomato ptomato left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These look good, let's merge them in any case.

There's one remaining item from the testing plan #4697 that I don't think is covered in this PR: ".next is looked up only after toString'ing the separator".

I hadn't read the testing plan too carefully until now, but it seems fairly complete to me. It occurred to me that you could test the following two things:

  • iterator with get next() { throw new Test262Error() }
  • iterator with get return() { throw new Test262Error() }

...these cases would exercise code paths in implementations that these tests don't yet exercise, but I don't think they'd produce observably different results than the test cases you've already got, so it's debatable whether these two cases are meaningful.

Comment thread test/built-ins/Iterator/prototype/join/contents-nullish.js
@bakkot

bakkot commented Jul 25, 2026

Copy link
Copy Markdown
Member Author

Unfortunately I can no longer push to this branch. fixed by #5085

Comment thread test/built-ins/Iterator/prototype/join/next-lookup-after-separator-tostring.js Outdated
@ptomato
ptomato merged commit defaaf1 into main Jul 27, 2026
21 checks passed
@ptomato
ptomato deleted the iterator-join branch July 27, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test plan for Iterator.prototype.join

4 participants