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

Zenparsing async generator functions #4576

Merged
merged 2 commits into from Sep 27, 2016
Merged

Conversation

hzoo
Copy link
Member

@hzoo hzoo commented Sep 27, 2016

@hzoo hzoo added PR: Spec Compliance 👓 A type of pull request used for our changelog categories PR: New Feature 🚀 A type of pull request used for our changelog categories es-proposal labels Sep 27, 2016
@@ -54,6 +54,7 @@ export default class File extends Store {
sourceType: this.opts.sourceType,
filename: this.opts.filename,
sourceFileName:this.opts.filename,
allowReturnOutsideFunction: true,
Copy link
Member Author

Choose a reason for hiding this comment

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

This is temporary until #3561 is ready and merged

Copy link
Member

Choose a reason for hiding this comment

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

The lets wait for #3561. I wouldn't add that now, as removing it again would be a breaking change if we are careful.

Copy link
Member Author

Choose a reason for hiding this comment

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

Definitely - this was just to make it pass in this pr

if (task.exec.code) {
let result = run(task);
if (result && typeof result.then === "function") {
return result;
Copy link
Member Author

Choose a reason for hiding this comment

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

Basically just returning the result of the runExec(execOpts, execCode); if it's a promise. We could also just always return

Copy link
Member

Choose a reason for hiding this comment

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

Do we need the .then check? I'd have thought we could return it without worrying to let Mocha worry about whether it is a promise.

@@ -1,5 +1,5 @@
let f = (() => {
var ref = babelHelpers.asyncToGenerator(function* () {
var _ref = babelHelpers.asyncToGenerator(function* () {
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure why this happened but some other code changed in the time between the original PR and now

var output = 0;
return forEach(genAnswers(), function(val) { output += val.value })
.then(function () {
assert.equal(output, 42);
Copy link
Member Author

Choose a reason for hiding this comment

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

assert.equal(output, 42); in a promise. Needs to use the allowReturnOutsideFunction parser option

@hzoo hzoo force-pushed the zenparsing-async-generator-functions branch 2 times, most recently from 2d39e11 to 23ee7ce Compare September 27, 2016 03:30
@codecov-io
Copy link

codecov-io commented Sep 27, 2016

Current coverage is 88.72% (diff: 100%)

Merging #4576 into master will increase coverage by 0.03%

@@             master      #4576   diff @@
==========================================
  Files           192        195     +3   
  Lines         13646      13751   +105   
  Methods        1413       1423    +10   
  Messages          0          0          
  Branches       3153       3169    +16   
==========================================
+ Hits          12102      12200    +98   
- Misses         1544       1551     +7   
  Partials          0          0          

Powered by Codecov. Last update b2eb5ec...b3bca86

@danez
Copy link
Member

danez commented Sep 27, 2016

/cc @zenparsing @domenic if you want to review, since you probably know the proposal best.

@hzoo hzoo force-pushed the zenparsing-async-generator-functions branch from 23ee7ce to 0766976 Compare September 27, 2016 13:27
@hzoo hzoo force-pushed the zenparsing-async-generator-functions branch from 0766976 to b3bca86 Compare September 27, 2016 13:29
@@ -151,7 +156,14 @@ export default function (
return throwMsg === true || err.message.indexOf(throwMsg) >= 0;
});
Copy link
Member

Choose a reason for hiding this comment

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

Should we try to handle the promise case here too, to allow async tests to reject.

Copy link
Member Author

@hzoo hzoo Sep 27, 2016

Choose a reason for hiding this comment

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

We should, do you want to do that in another pr if you want to and with an example test?

@hzoo hzoo merged commit 5ea57d5 into master Sep 27, 2016
@hzoo hzoo deleted the zenparsing-async-generator-functions branch October 1, 2016 19:07
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 7, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: New Feature 🚀 A type of pull request used for our changelog categories PR: Spec Compliance 👓 A type of pull request used for our changelog categories Spec: Async Generators
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants