-
Notifications
You must be signed in to change notification settings - Fork 487
Async Generator flow control tests #871
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
Conversation
82683c1
to
8bdcd58
Compare
Ping, it would be great to get a look at these and start filling in holes in coverage here |
Hi, @caitp! I'm back to the regular work time on test262, although, there are other older PR I've had to look before this one. I'll review this one first thing tomorrow. Can you confirm if you're planning to add more tests in this PR or this is the current work that we should land and expect/start a follow PR for coverage completion? |
well, if I come up with more tests, they'll be either in this PR or a followup. I don't think there's any problem with incrementally landing more coverage. |
It's not a problem, for sure. I just want to make the best time strategy for reviews and I really appreciate the work. |
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.
There's a few nit picks, some related to formatting. It is looking great so far.
---*/ | ||
|
||
var g = async function*() { | ||
$ERROR('Generator must not be resumed.'); |
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.
we can replace $ERROR
with throw new Test262Error('...
.
It should not block this PR, but it's a +1 if we can use the current conventional form.
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.
Done
/*--- | ||
author: Caitlin Potter <[email protected]> | ||
esid: pending | ||
description: > |
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.
in every file, the description tags are in a good shape for the info
tag. We still miss a short description
for each case.
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.
I'm open to suggestions on better description text, but otherwise I'm leaving these as-is, and the web runner can just deal with it
// Generator is closed | ||
it.next().then(function(ret) { | ||
assert.sameValue(ret.value, undefined); | ||
assert.sameValue(ret.done, true); |
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.
Interesting! You assert the iteration is done on line 22, but for this is still fine to assert the generator is really closed and won't resume. I like this.
+1
|
||
it.return('sent-value').then($DONE, function(err) { | ||
// Throw in finally block | ||
assert(err instanceof Err); |
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.
if you store the reference for new Error
you can throw it in the finally block and assert err
is the same reference, right?
It also saves the need for an Error subclass
|
||
}).catch($DONE); | ||
|
||
}).catch($DONE); |
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.
I wish we could have Promise#finally
already
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.
I don't think it would help with the nested Promises
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 there a specific reason these are nested instead of chained anyway?
it.next()
.then(function(ret) {
assert.sameValue(ret.value, 1, 'Initial yield');
assert.sameValue(ret.done, false, 'Initial yield');
return it.return('sent-value');
})
.then(function(ret) {
assert.sameValue(ret.value, 2, 'Yield in finally block');
assert.sameValue(ret.done, false, 'Yield in finally block');
return it.next();
})
.then(function(ret) {
assert.sameValue(ret.value, 'sent-value', 'AsyncGeneratorResolve(generator, resultValue, true)');
assert.sameValue(ret.done, true, 'AsyncGeneratorResolve(generator, resultValue, true)');
return it.next();
})
.then(function(ret) {
assert.sameValue(ret.value, undefined, 'Generator is closed');
assert.sameValue(ret.done, true, 'Generator is closed');
})
.then($DONE, $DONE);
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.
(returning a Promise and chaining is) harder to read, less obvious, etc
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.
I very much disagree, 4 level nested callbacks are much less readable than chaining promises, but I also don't care enough to block, it seems you've reached "annoyed" point on this PR (been there myself, sorry if I'm projecting) and I don't want to add to it any more. Thanks for the contribution!
assert.sameValue(ret.value, 1); | ||
assert.sameValue(ret.done, false); | ||
|
||
it.throw(new Err).then(function(ret) { |
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.
this is the same case I mentioned above for storing an instance of new Error
.
it.next().then(function(ret) { | ||
// Initial yield | ||
assert.sameValue(ret.value, 1); | ||
assert.sameValue(ret.done, false); |
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.
the comments are great to track the steps. If you don't mind, can you move them to become assertion messages?
This way we can have a powerful track of each assertion and, better, tells the implementors where each test is failing at.
Example for the case above:
assert.sameValue(ret.value, 1, 'Initial yield');
assert.sameValue(ret.done, false, 'Initial yield');
Even if they are the same message, I can already identify each one due to the respective expected values.
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.
I've done this --- but it gets complicated for the generator-closing operations. I've gone with using the spec step which leads to the promise capability resolve/reject call instead there, but that seems awkward too.
To avoid noises, I left some suggestions that can be applied to multiple places, but in a single comment as an example. Some cases are:
etc. Thank you for the tests, @caitp! I'm looking forward the next review round! |
8bdcd58
to
79baf2b
Compare
Could you please keep spec text in an "info:" section and use "description:" as a short description of why the individual test is interesting? |
The description lines are influenced by existing tests in the repository, which include spec citations. I would appreciate specific suggestions for individual tests. For example (test/language/expressions/arrow-function/syntax/arrowparameters-binding-identifier-eval.js): // Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 14.2.1
description: >
ArrowParameters[Yield] :
BindingIdentifier[?Yield]
...
Parameter named "eval", non-strict
flags: [noStrict]
---*/
var af = eval => eval;
assert.sameValue(typeof af, "function");
assert.sameValue(af(1), 1); |
Updating all the tests is preventatively expensive. Another example is the es6id there, which is now superseded by esid. We do drive-by cleanup and all new tests coming in should conform to the current standard. |
I'm happy to change the frontmatter to anything requested (within reason), but please be specific about those requests. |
Sorry for the confusion. A random example: https://github.com/tc39/test262/blob/82c2ca070976329e822a466e2d6bafa88b87bc4d/test/intl402/PluralRules/prototype/select/tainting.js Generally, "info:" can be used to dump spec text, and "description:" is for the brief description of what the test is trying to achieve or why it is interesting. We try to avoid having spec text in "description:" so that it can be used as a quick reference. The descriptions from your previous commit 098f9ca are fine. Relevant spec text sections can be put into "info:". |
@caitp You've done a lot of great work here, and I really appreciate your contribution. I will follow up with a new PR to address the remaining nit picky formatting things, mostly providing the frontmatter descriptions. Hopefully you may help me reviewing the new changes. |
Here's a starter suite of tests for basic flow control in Async Generators.
This relates primarily to the behaviour of AsyncGeneratorResumeNext, AsyncGeneratorStart, AsyncGeneratorResolve and AsyncGeneratorReject, as well as some coverage of changes to GeneratorYield.
There is stuff missing, as I haven't exhaustively written tests for all of the variations that are necessary.