// (beautified)
-console.log(function() {
- return 1 + .1 + .1;
-}());
+console.log(1 + .1 + .1);
// output: 1.2000000000000002
//
// minify: 1.2
});
it("Should correctly preserve new lines around comments", function() {
- var tests = [
+ [
[
"// foo",
"// bar",
var assert = require("assert");
var exec = require("child_process").exec;
var path = require("path");
-var readFileSync = require("fs").readFileSync;
describe("bin/uglifyjs with input file globs", function() {
var uglifyjscmd = '"' + process.argv[0] + '" bin/uglifyjs';
if (result.error) throw result.error;
assert.strictEqual(result.code, "print(42);");
assert.strictEqual(JSON.stringify(options), value);
- })
+ });
it("Should skip inherited keys from `files`", function() {
var files = Object.create({ skip: this });
files[0] = "alert(1 + 1)";
var assert = require("assert");
-var exec = require("child_process").exec;
var fs = require("fs");
var reduce_test = require("../reduce");
var semver = require("semver");
it("Should not modify input source map", function() {
var orig = get_map();
var original = JSON.stringify(orig);
- var map = prepare_map(orig);
+ prepare_map(orig);
assert.strictEqual(JSON.stringify(orig), original);
});
it("Should copy over original sourcesContent", function() {
'"\u2029"',
].forEach(function(input) {
assert.throws(function() {
- var ast = UglifyJS.parse(input);
+ UglifyJS.parse(input);
}, function(e) {
return e instanceof UglifyJS.JS_Parse_Error
&& e.message === "Unterminated string constant";
'"use strict";\n"\\011"',
].forEach(function(input) {
assert.throws(function() {
- var output = UglifyJS.parse(input);
+ UglifyJS.parse(input);
}, function(e) {
return e instanceof UglifyJS.JS_Parse_Error
&& e.message === "Legacy octal escape sequences are not allowed in strict mode";
// hoist and return expressions from the IIFE function expression
var seq = [];
node.expression.body.forEach(function(node) {
- var expr = expr instanceof U.AST_Exit ? node.value : node.body;
+ var expr = node instanceof U.AST_Exit ? node.value : node.body;
if (expr instanceof U.AST_Node && !U.is_statement(expr) && can_hoist(expr)) {
- // collect expressions from each statements' body
+ // collect expressions from each statement's body
seq.push(expr);
}
});
var expr = [
node.expression, // switch expression
node.body[0] && node.body[0].expression, // first case expression or undefined
- node.body[0] && node.body[0], // first case body or undefined
+ node.body[0], // first case body or undefined
][ (node.start._permute * steps | 0) % 4 ];
node.start._permute += step;
if (expr && (!(expr instanceof U.AST_Statement) || !has_loopcontrol(expr, node, parent))) {
timeout: timeout || 5000,
});
if (result.status === 0) return result.stdout;
+ var msg = ("" + result.stderr).replace(/\r\n/g, "\n");
if (result.error && result.error.code == "ETIMEDOUT" || /FATAL ERROR:/.test(msg)) {
return new Error("Script execution timed out.");
}
if (result.error) return result.error;
- var msg = result.stderr.replace(/\r\n/g, "\n");
var end = msg.indexOf("\n\n-----===== UNCAUGHT EXCEPTION =====-----\n\n");
var details;
if (end >= 0) {
return;
}
-function run_code(code, toplevel) {
- return sandbox.run_code(sandbox.patch_module_statements(code), toplevel);
+function run_code(code, toplevel, timeout) {
+ return sandbox.run_code(sandbox.patch_module_statements(code), toplevel, timeout);
}
function writeln(stream, msg) {