@@ -89,7 +89,7 @@ if (program.mangleProps) {
|
||||
if (typeof program.mangleProps != "object") program.mangleProps = {};
|
||||
if (!Array.isArray(program.mangleProps.reserved)) program.mangleProps.reserved = [];
|
||||
require("../tools/domprops").forEach(function(name) {
|
||||
UglifyJS.push_uniq(program.mangleProps.reserved, name);
|
||||
UglifyJS._push_uniq(program.mangleProps.reserved, name);
|
||||
});
|
||||
}
|
||||
if (typeof options.mangle != "object") options.mangle = {};
|
||||
@@ -187,7 +187,7 @@ function run() {
|
||||
}
|
||||
var result = UglifyJS.minify(files, options);
|
||||
} catch (ex) {
|
||||
if (ex instanceof UglifyJS.JS_Parse_Error) {
|
||||
if (ex.name == "SyntaxError") {
|
||||
console.error("Parse error at " + ex.filename + ":" + ex.line + "," + ex.col);
|
||||
var col = ex.col;
|
||||
var lines = files[ex.filename].split(/\r?\n/);
|
||||
|
||||
13
test/exports.js
Normal file
13
test/exports.js
Normal file
@@ -0,0 +1,13 @@
|
||||
exports["Compressor"] = Compressor;
|
||||
exports["JS_Parse_Error"] = JS_Parse_Error;
|
||||
exports["OutputStream"] = OutputStream;
|
||||
exports["SourceMap"] = SourceMap;
|
||||
exports["TreeWalker"] = TreeWalker;
|
||||
exports["base54"] = base54;
|
||||
exports["defaults"] = defaults;
|
||||
exports["mangle_properties"] = mangle_properties;
|
||||
exports["minify"] = minify;
|
||||
exports["parse"] = parse;
|
||||
exports["string_template"] = string_template;
|
||||
exports["tokenizer"] = tokenizer;
|
||||
exports["is_identifier"] = is_identifier;
|
||||
@@ -1,4 +1,4 @@
|
||||
var UglifyJS = require('../../');
|
||||
var UglifyJS = require("../node");
|
||||
var assert = require("assert");
|
||||
|
||||
describe("Accessor tokens", function() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var UglifyJS = require('../../');
|
||||
var UglifyJS = require("../node");
|
||||
var assert = require("assert");
|
||||
|
||||
describe("arguments", function() {
|
||||
|
||||
@@ -19,7 +19,7 @@ describe("bin/uglifyjs", function () {
|
||||
eval(stdout);
|
||||
|
||||
assert.strictEqual(typeof WrappedUglifyJS, 'object');
|
||||
assert.strictEqual(true, WrappedUglifyJS.parse('foo;') instanceof WrappedUglifyJS.AST_Node);
|
||||
assert.strictEqual(WrappedUglifyJS.minify("foo([true,,2+3]);").code, "foo([!0,,5]);");
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var UglifyJS = require('../../');
|
||||
var UglifyJS = require("../node");
|
||||
var assert = require("assert");
|
||||
|
||||
describe("comment filters", function() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var assert = require("assert");
|
||||
var uglify = require("../../");
|
||||
var uglify = require("../node");
|
||||
|
||||
describe("Comment", function() {
|
||||
it("Should recognize eol of single line comments", function() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var assert = require("assert");
|
||||
var uglify = require("../../");
|
||||
var uglify = require("../node");
|
||||
|
||||
describe("Directives", function() {
|
||||
it ("Should allow tokenizer to store directives state", function() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var UglifyJS = require('../../');
|
||||
var UglifyJS = require("../node");
|
||||
var assert = require("assert");
|
||||
|
||||
describe("Getters and setters", function() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var Uglify = require('../../');
|
||||
var Uglify = require("../node");
|
||||
var assert = require("assert");
|
||||
|
||||
describe("line-endings", function() {
|
||||
|
||||
@@ -183,13 +183,4 @@ describe("minify", function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Compressor", function() {
|
||||
it("should be backward compatible with ast.transform(compressor)", function() {
|
||||
var ast = Uglify.parse("function f(a){for(var i=0;i<a;i++)console.log(i)}");
|
||||
ast.figure_out_scope();
|
||||
ast = ast.transform(Uglify.Compressor());
|
||||
assert.strictEqual(ast.print_to_string(), "function f(a){for(var i=0;i<a;i++)console.log(i)}");
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var assert = require("assert");
|
||||
var uglify = require("../../");
|
||||
var uglify = require("../node");
|
||||
|
||||
describe("Number literals", function () {
|
||||
it("Should not allow legacy octal literals in strict mode", function() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var UglifyJS = require("../../");
|
||||
var UglifyJS = require("../node");
|
||||
var assert = require("assert");
|
||||
|
||||
describe("operator", function() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var assert = require("assert");
|
||||
var exec = require("child_process").exec;
|
||||
var uglify = require("../../");
|
||||
var uglify = require("../node");
|
||||
|
||||
describe("spidermonkey export/import sanity test", function() {
|
||||
it("should produce a functional build when using --self with spidermonkey", function(done) {
|
||||
@@ -15,18 +15,7 @@ describe("spidermonkey export/import sanity test", function() {
|
||||
|
||||
eval(stdout);
|
||||
assert.strictEqual(typeof SpiderUglify, "object");
|
||||
|
||||
var ast = SpiderUglify.parse("foo([true,,2+3]);");
|
||||
assert.strictEqual(true, ast instanceof SpiderUglify.AST_Node);
|
||||
|
||||
ast.figure_out_scope();
|
||||
ast = SpiderUglify.Compressor({}).compress(ast);
|
||||
assert.strictEqual(true, ast instanceof SpiderUglify.AST_Node);
|
||||
|
||||
var stream = SpiderUglify.OutputStream({});
|
||||
ast.print(stream);
|
||||
var code = stream.toString();
|
||||
assert.strictEqual(code, "foo([!0,,5]);");
|
||||
assert.strictEqual(SpiderUglify.minify("foo([true,,2+3]);").code, "foo([!0,,5]);");
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var UglifyJS = require('../../');
|
||||
var UglifyJS = require("../node");
|
||||
var assert = require("assert");
|
||||
|
||||
describe("String literals", function() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var assert = require("assert");
|
||||
var uglify = require("../../");
|
||||
var uglify = require("../node");
|
||||
|
||||
describe("With", function() {
|
||||
it("Should throw syntaxError when using with statement in strict mode", function() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Testing UglifyJS <-> SpiderMonkey AST conversion
|
||||
// through generative testing.
|
||||
|
||||
var UglifyJS = require(".."),
|
||||
var UglifyJS = require("./node"),
|
||||
escodegen = require("escodegen"),
|
||||
esfuzz = require("esfuzz"),
|
||||
estraverse = require("estraverse"),
|
||||
|
||||
6
test/node.js
Normal file
6
test/node.js
Normal file
@@ -0,0 +1,6 @@
|
||||
var fs = require("fs");
|
||||
|
||||
new Function("MOZ_SourceMap", "exports", require("../tools/node").FILES.map(function(file) {
|
||||
if (/exports\.js$/.test(file)) file = require.resolve("./exports");
|
||||
return fs.readFileSync(file, "utf8");
|
||||
}).join("\n\n"))(require("source-map"), exports);
|
||||
@@ -1,6 +1,6 @@
|
||||
#! /usr/bin/env node
|
||||
|
||||
var U = require("../tools/node");
|
||||
var U = require("./node");
|
||||
var path = require("path");
|
||||
var fs = require("fs");
|
||||
var assert = require("assert");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var UglifyJS = require("..");
|
||||
var UglifyJS = require("./node");
|
||||
var ok = require("assert");
|
||||
|
||||
module.exports = function () {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
stream._handle.setBlocking(true);
|
||||
});
|
||||
|
||||
var UglifyJS = require("..");
|
||||
var UglifyJS = require("./node");
|
||||
var randomBytes = require("crypto").randomBytes;
|
||||
var sandbox = require("./sandbox");
|
||||
|
||||
|
||||
@@ -1,15 +1,4 @@
|
||||
exports["Compressor"] = Compressor;
|
||||
exports["Dictionary"] = Dictionary;
|
||||
exports["JS_Parse_Error"] = JS_Parse_Error;
|
||||
exports["OutputStream"] = OutputStream;
|
||||
exports["SourceMap"] = SourceMap;
|
||||
exports["TreeWalker"] = TreeWalker;
|
||||
exports["base54"] = base54;
|
||||
exports["defaults"] = defaults;
|
||||
exports["mangle_properties"] = mangle_properties;
|
||||
exports["minify"] = minify;
|
||||
exports["parse"] = parse;
|
||||
exports["push_uniq"] = push_uniq;
|
||||
exports["string_template"] = string_template;
|
||||
exports["tokenizer"] = tokenizer;
|
||||
exports["is_identifier"] = is_identifier;
|
||||
exports["_push_uniq"] = push_uniq;
|
||||
|
||||
@@ -18,15 +18,19 @@ var FILES = UglifyJS.FILES = [
|
||||
return require.resolve(file);
|
||||
});
|
||||
|
||||
new Function("MOZ_SourceMap", "exports", FILES.map(function(file){
|
||||
return fs.readFileSync(file, "utf8");
|
||||
}).join("\n\n"))(
|
||||
new Function("MOZ_SourceMap", "exports", function() {
|
||||
var code = FILES.map(function(file) {
|
||||
return fs.readFileSync(file, "utf8");
|
||||
});
|
||||
code.push("exports.describe_ast = " + describe_ast.toString());
|
||||
return code.join("\n\n");
|
||||
}())(
|
||||
require("source-map"),
|
||||
UglifyJS
|
||||
);
|
||||
|
||||
UglifyJS.describe_ast = function() {
|
||||
var out = UglifyJS.OutputStream({ beautify: true });
|
||||
function describe_ast() {
|
||||
var out = OutputStream({ beautify: true });
|
||||
function doitem(ctor) {
|
||||
out.print("AST_" + ctor.TYPE);
|
||||
var props = ctor.SELF_PROPS.filter(function(prop){
|
||||
@@ -56,6 +60,6 @@ UglifyJS.describe_ast = function() {
|
||||
});
|
||||
}
|
||||
};
|
||||
doitem(UglifyJS.AST_Node);
|
||||
doitem(AST_Node);
|
||||
return out + "";
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user