From 2cbbf5c375a0fae88345c3ed3bc2829b4b1ac250 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sun, 6 Dec 2020 21:22:40 +0000 Subject: support async function (#4333) --- test/mocha/async.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/mocha/async.js (limited to 'test/mocha/async.js') 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); + }); + }); +}); -- cgit v1.2.3