aboutsummaryrefslogtreecommitdiff
path: root/test/mocha/imports.js
blob: e9b654cd059d73ab000cf302ad445afb05c37e93 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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);
        });
    });
});