Skip to content

Commit 496fd5d

Browse files
GabrielRatenerGeoffreyBooth
authored andcommitted
Add Implicit Async Functions (#3757)
* changed jison acceptable versions * added await support * wrong function bug fix * added tests for async/await * invalid to have await, yield(from) in same function * changed error handling and tests * bug fix * made error handling test more rigorous * consolidated harmony test files * added async constructor support and tests * removed .orig files * Fixed browser testing issue * Minor cleanup * Async test-suite and Cake support, simplified/removed funky tests * Skip async/await tests when not supported in runtime * cleanup * Replaced polyfill with native JS async/await * Oops * Make 'async' reserved word * Remove all async polyfills * fix merge conflict * make async testing opt-in * restore test, remove confusing polyfill language * Revert changes to test runners * Only run async tests where async/await is supported (Node 7+ with --harmony, for now) * remove 'async' from JS reserved words * The async tests should use their own special async-capable version of `global.test`, which is only loaded for the async tests and only loaded by async-capable environments * Reverting rename of `async`, it’s not a reserved word so there’s no longer a need for this change * async test refactoring and additions * oops * sync * better error reporting for `await` * more stuff geoffrey wants * fixed litcoffee tests * change test title
1 parent a1bcf7f commit 496fd5d

13 files changed

+538
-210
lines changed

Cakefile

+12-8
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,14 @@ task 'bench', 'quick benchmark of compilation time', ->
228228
# Run the CoffeeScript test suite.
229229
runTests = (CoffeeScript) ->
230230
CoffeeScript.register()
231-
startTime = Date.now()
232-
currentFile = null
233-
passedTests = 0
234-
failures = []
231+
startTime = Date.now()
232+
233+
# These are attached to `global` so that they’re accessible from within
234+
# `test/async.coffee`, which has an async-capable version of
235+
# `global.test`.
236+
global.currentFile = null
237+
global.passedTests = 0
238+
global.failures = []
235239

236240
global[name] = func for name, func of require 'assert'
237241

@@ -288,10 +292,10 @@ runTests = (CoffeeScript) ->
288292
# Run every test in the `test` folder, recording failures.
289293
files = fs.readdirSync 'test'
290294

291-
# Ignore generators test file if generators are not available
292-
generatorsAreAvailable = '--harmony' in process.execArgv or
293-
'--harmony-generators' in process.execArgv
294-
files.splice files.indexOf('generators.coffee'), 1 if not generatorsAreAvailable
295+
# Ignore async test file if async/await is not available
296+
asyncSupported = parseInt(process.versions.node.split('.')[0]) >= 7 and
297+
('--harmony' in process.execArgv or '--harmony-async-await' in process.execArgv)
298+
files.splice files.indexOf('async.coffee'), 1 unless asyncSupported
295299

296300
for file in files when helpers.isCoffee file
297301
literate = helpers.isLiterate file

extras/coffee-script.js

+6-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/coffee-script/grammar.js

+12-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/coffee-script/lexer.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/coffee-script/nodes.js

+51-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)