aboutsummaryrefslogtreecommitdiff
path: root/test/mocha/exports.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/mocha/exports.js')
-rw-r--r--test/mocha/exports.js71
1 files changed, 71 insertions, 0 deletions
diff --git a/test/mocha/exports.js b/test/mocha/exports.js
new file mode 100644
index 00000000..fa448ff0
--- /dev/null
+++ b/test/mocha/exports.js
@@ -0,0 +1,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);
+ });
+ });
+});