@@ -856,23 +856,21 @@ function createVarName(maybe, dontStore) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function try_beautify(code, result) {
|
function try_beautify(code, result) {
|
||||||
try {
|
var beautified = UglifyJS.minify(code, {
|
||||||
var beautified = UglifyJS.minify(code, {
|
compress: false,
|
||||||
compress: false,
|
mangle: false,
|
||||||
mangle: false,
|
output: {
|
||||||
output: {
|
beautify: true,
|
||||||
beautify: true,
|
bracketize: true,
|
||||||
bracketize: true,
|
},
|
||||||
},
|
});
|
||||||
}).code;
|
if (beautified.error) {
|
||||||
if (sandbox.same_stdout(sandbox.run_code(beautified), result)) {
|
|
||||||
console.log("// (beautified)");
|
|
||||||
console.log(beautified);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log("// !!! beautify failed !!!");
|
console.log("// !!! beautify failed !!!");
|
||||||
console.log(e.stack);
|
console.log(beautified.error.stack);
|
||||||
|
} else if (sandbox.same_stdout(sandbox.run_code(beautified.code), result)) {
|
||||||
|
console.log("// (beautified)");
|
||||||
|
console.log(beautified.code);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
console.log("//");
|
console.log("//");
|
||||||
console.log(code);
|
console.log(code);
|
||||||
@@ -908,12 +906,13 @@ function log_suspects(minify_options, component) {
|
|||||||
var o = JSON.parse(JSON.stringify(options));
|
var o = JSON.parse(JSON.stringify(options));
|
||||||
o[name] = false;
|
o[name] = false;
|
||||||
m[component] = o;
|
m[component] = o;
|
||||||
try {
|
var result = UglifyJS.minify(original_code, m);
|
||||||
var r = sandbox.run_code(UglifyJS.minify(original_code, m).code);
|
if (result.error) {
|
||||||
return sandbox.same_stdout(original_result, r);
|
|
||||||
} catch (e) {
|
|
||||||
console.log("Error testing options." + component + "." + name);
|
console.log("Error testing options." + component + "." + name);
|
||||||
console.log(e);
|
console.log(result.error);
|
||||||
|
} else {
|
||||||
|
var r = sandbox.run_code(result.code);
|
||||||
|
return sandbox.same_stdout(original_result, r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -981,18 +980,16 @@ for (var round = 1; round <= num_iterations; round++) {
|
|||||||
original_code = createTopLevelCode();
|
original_code = createTopLevelCode();
|
||||||
original_result = sandbox.run_code(original_code);
|
original_result = sandbox.run_code(original_code);
|
||||||
(typeof original_result != "string" ? fallback_options : minify_options).forEach(function(options) {
|
(typeof original_result != "string" ? fallback_options : minify_options).forEach(function(options) {
|
||||||
try {
|
uglify_code = UglifyJS.minify(original_code, JSON.parse(options));
|
||||||
uglify_code = UglifyJS.minify(original_code, JSON.parse(options)).code;
|
if (!uglify_code.error) {
|
||||||
} catch (e) {
|
uglify_code = uglify_code.code;
|
||||||
uglify_code = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
ok = typeof uglify_code == "string";
|
|
||||||
if (ok) {
|
|
||||||
uglify_result = sandbox.run_code(uglify_code);
|
uglify_result = sandbox.run_code(uglify_code);
|
||||||
ok = sandbox.same_stdout(original_result, uglify_result);
|
ok = sandbox.same_stdout(original_result, uglify_result);
|
||||||
} else if (typeof original_result != "string") {
|
} else {
|
||||||
ok = uglify_code.name == original_result.name;
|
uglify_code = uglify_code.error;
|
||||||
|
if (typeof original_result != "string") {
|
||||||
|
ok = uglify_code.name == original_result.name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (verbose || (verbose_interval && !(round % INTERVAL_COUNT)) || !ok) log(options);
|
if (verbose || (verbose_interval && !(round % INTERVAL_COUNT)) || !ok) log(options);
|
||||||
else if (verbose_error && typeof original_result != "string") {
|
else if (verbose_error && typeof original_result != "string") {
|
||||||
|
|||||||
Reference in New Issue
Block a user