diff options
Diffstat (limited to 'test/mocha/async.js')
-rw-r--r-- | test/mocha/async.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/mocha/async.js b/test/mocha/async.js new file mode 100644 index 00000000..dc1aa2f4 --- /dev/null +++ b/test/mocha/async.js @@ -0,0 +1,23 @@ +var assert = require("assert"); +var UglifyJS = require("../node"); + +describe("async", function() { + it("Should reject `await` as symbol name within async functions only", function() { + [ + "function await() {}", + "function(await) {}", + "function() { await; }", + "function() { await:{} }", + "function() { var await; }", + "function() { function await() {} }", + "function() { try {} catch (await) {} }", + ].forEach(function(code) { + UglifyJS.parse("(" + code + ")();"); + assert.throws(function() { + UglifyJS.parse("(async " + code + ")();"); + }, function(e) { + return e instanceof UglifyJS.JS_Parse_Error; + }, code); + }); + }); +}); |