aboutsummaryrefslogtreecommitdiff
path: root/test/mocha/imports.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-02-13 20:26:43 +0000
committerGitHub <noreply@github.com>2021-02-14 04:26:43 +0800
commitb7219ac489e47091f17091a08d7ef50980d68972 (patch)
treec46da154cf918ec3573ddb9b4dfd9df244919556 /test/mocha/imports.js
parenta6bb66931bfdd04d6ce05b640d89a8deff7ca3de (diff)
downloadtracifyjs-b7219ac489e47091f17091a08d7ef50980d68972.tar.gz
tracifyjs-b7219ac489e47091f17091a08d7ef50980d68972.zip
support `import` statements (#4646)
Diffstat (limited to 'test/mocha/imports.js')
-rw-r--r--test/mocha/imports.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/mocha/imports.js b/test/mocha/imports.js
new file mode 100644
index 00000000..e9b654cd
--- /dev/null
+++ b/test/mocha/imports.js
@@ -0,0 +1,28 @@
+var assert = require("assert");
+var UglifyJS = require("../node");
+
+describe("import", function() {
+ it("Should reject invalid `import` statement syntax", function() {
+ [
+ "import *;",
+ "import A;",
+ "import {};",
+ "import `path`;",
+ "import from 'path';",
+ "import * from 'path';",
+ "import A as B from 'path';",
+ "import { A }, B from 'path';",
+ "import * as A, B from 'path';",
+ "import * as A, {} from 'path';",
+ "import { * as A } from 'path';",
+ "import { 42 as A } from 'path';",
+ "import { A-B as C } from 'path';",
+ ].forEach(function(code) {
+ assert.throws(function() {
+ UglifyJS.parse(code);
+ }, function(e) {
+ return e instanceof UglifyJS.JS_Parse_Error;
+ }, code);
+ });
+ });
+});