Skip to content
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 test on handling broken promises in AsyncGenerator.prototype.return #3472

Merged
merged 3 commits into from
May 12, 2022

Conversation

legendecas
Copy link
Member

Tests for tc39/ecma262#2683.

@legendecas legendecas marked this pull request as ready for review April 10, 2022 16:44
@rwaldron rwaldron added the has consensus This has committee consensus label Apr 11, 2022
Copy link
Contributor

@ptomato ptomato left a comment

Choose a reason for hiding this comment

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

Thanks for these tests! I have to say, this is my first time really digging into how AsyncGenerators are specified, so several of my comments might come from misunderstanding something. But hopefully I've also suggested some improvements that make it easier to comprehend by someone new to this part of the specification.

Do we need to have tests for the "executing" and "awaiting-return" states as well? Or is this enough since steps 10 and 11 of https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-asyncgenerator-prototype-return weren't touched by the normative PR?

ptomato
ptomato previously approved these changes Apr 12, 2022
Copy link
Contributor

@ptomato ptomato left a comment

Choose a reason for hiding this comment

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

Anyone else want to take a look?

@legendecas
Copy link
Member Author

Do we need to have tests for the "executing" and "awaiting-return" states as well? Or is this enough since steps 10 and 11 of https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-asyncgenerator-prototype-return weren't touched by the normative PR?

I didn't find such tests. I can add those in a follow-up PR.

yield;
return 'this is never returned';
} catch (err) {
assert.sameValue(err.message, 'broken promise');
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this test is scrutinizing the completion semantics of this function, we should avoid making assertions within the body. Instead, we could store the value in a mutable binding declared in a higher scope, and assert that value in the test's final validation phase.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for your suggestion! Updated :)

Copy link
Contributor

@jugglinmike jugglinmike left a comment

Choose a reason for hiding this comment

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

Thanks, @legendecas, this looks good to me!

We'll coordinate with the ECMA262 maintainers to merge this and the corresponding spec patch.

@jugglinmike
Copy link
Contributor

Thanks again, @legendecas!

@legendecas legendecas deleted the ecma262-2683 branch May 13, 2022 00:26
catamorphism pushed a commit to nicolo-ribaudo/test262 that referenced this pull request May 30, 2022
…rn (tc39#3472)

* Add test on handling broken promises in AsyncGenerator.prototype.return

* fixup!

* fixup!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has consensus This has committee consensus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants