aboutsummaryrefslogtreecommitdiff
path: root/test/mocha/async.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-12-06 21:22:40 +0000
committerGitHub <noreply@github.com>2020-12-07 05:22:40 +0800
commit2cbbf5c375a0fae88345c3ed3bc2829b4b1ac250 (patch)
treef1dd106d04820e8002d2f99cba76206d690d7c96 /test/mocha/async.js
parent3c384cf9a8ed4230cf87f14ab017b613b38df628 (diff)
downloadtracifyjs-2cbbf5c375a0fae88345c3ed3bc2829b4b1ac250.tar.gz
tracifyjs-2cbbf5c375a0fae88345c3ed3bc2829b4b1ac250.zip
support async function (#4333)
Diffstat (limited to 'test/mocha/async.js')
-rw-r--r--test/mocha/async.js23
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);
+ });
+ });
+});