google / traceur-compiler

Traceur is a JavaScript.next-to-JavaScript-of-today compiler
Apache License 2.0
8.17k stars 578 forks source link

Allow compiling async functions to generators #2102

Closed arv closed 8 years ago

arv commented 8 years ago

This is done by setting --async-functions=generator --generators=parse.

Related to #1231 Fixes #1780

arv commented 8 years ago

@johnjbarton The feature tests now run all test/feature/AsyncFunctions twice. Once with whatever options are set in the prolog and once where we override the options to transform to generators. The code for this is pretty ugly. Suggestions welcome.

johnjbarton commented 8 years ago

Regarding the two-pass tests, duplicating the files with different options is not a horrible alternative and probably makes the system simpler. But it's ok this way.

LGTM

arv commented 8 years ago

There is also one more complication and that is that we need to detect if there is native support for generators. For example Node 0.10 does not have generators. I thought of doing some optional skip directive fur the test runner...

arv commented 8 years ago

I ended up duplicating the test and adding support for conditional skip to the feature test runner. I also changed the options slightly, so that if --generator=parse then we generate code that contains generators.