Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

tests for Iterator.prototype.join#4768

Open
bakkot wants to merge 1 commit into
maintc39/test262:mainfrom
iterator-jointc39/test262:iterator-joinCopy head branch name to clipboard
Open

tests for Iterator.prototype.join#4768
bakkot wants to merge 1 commit into
maintc39/test262:mainfrom
iterator-jointc39/test262:iterator-joinCopy head branch name to clipboard

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
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.

---*/

assert.sameValue(
['one', null, 'two', undefined, 'three'].values().join(),

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.

optional: Might be good to test a nullish value as the last value of the iterator, as well.


/*---
esid: sec-iterator.prototype.join
description: Iterator.prototype.join does not close its receiver if the iterator itself throws.

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.

Description is for another file

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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.