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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
var assert = require("assert");
var UglifyJS = require("../node");
describe("export", function() {
it("Should reject invalid `export ...` statement syntax", function() {
[
"export *;",
"export A;",
"export 42;",
"export var;",
"export * as A;",
"export A as B;",
"export const A;",
"export function(){};",
].forEach(function(code) {
assert.throws(function() {
UglifyJS.parse(code);
}, function(e) {
return e instanceof UglifyJS.JS_Parse_Error;
}, code);
});
});
it("Should reject invalid `export { ... }` statement syntax", function() {
[
"export { * };",
"export { * as A };",
"export { 42 as A };",
"export { A as B-C };",
"export { default as A };",
].forEach(function(code) {
assert.throws(function() {
UglifyJS.parse(code);
}, function(e) {
return e instanceof UglifyJS.JS_Parse_Error;
}, code);
});
});
it("Should reject invalid `export default ...` statement syntax", function() {
[
"export default *;",
"export default var;",
"export default A as B;",
].forEach(function(code) {
assert.throws(function() {
UglifyJS.parse(code);
}, function(e) {
return e instanceof UglifyJS.JS_Parse_Error;
}, code);
});
});
it("Should reject invalid `export ... from ...` statement syntax", function() {
[
"export from 'path';",
"export * from `path`;",
"export A as B from 'path';",
"export default from 'path';",
"export { A }, B from 'path';",
"export * as A, B from 'path';",
"export * as A, {} from 'path';",
"export { * as A } from 'path';",
"export { 42 as A } from 'path';",
"export { 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);
});
});
});
|