fix issues in tests flagged by LGTM (#5150)
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
// (beautified)
|
||||
console.log(function() {
|
||||
return 1 + .1 + .1;
|
||||
}());
|
||||
console.log(1 + .1 + .1);
|
||||
// output: 1.2000000000000002
|
||||
//
|
||||
// minify: 1.2
|
||||
|
||||
@@ -191,7 +191,7 @@ describe("comments", function() {
|
||||
});
|
||||
|
||||
it("Should correctly preserve new lines around comments", function() {
|
||||
var tests = [
|
||||
[
|
||||
[
|
||||
"// foo",
|
||||
"// bar",
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
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';
|
||||
|
||||
@@ -25,7 +25,7 @@ describe("minify", function() {
|
||||
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)";
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
var assert = require("assert");
|
||||
var exec = require("child_process").exec;
|
||||
var fs = require("fs");
|
||||
var reduce_test = require("../reduce");
|
||||
var semver = require("semver");
|
||||
|
||||
@@ -362,7 +362,7 @@ describe("sourcemaps", function() {
|
||||
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() {
|
||||
|
||||
@@ -12,7 +12,7 @@ describe("String literals", 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";
|
||||
@@ -44,7 +44,7 @@ describe("String literals", function() {
|
||||
'"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";
|
||||
|
||||
@@ -215,9 +215,9 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
|
||||
// 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);
|
||||
}
|
||||
});
|
||||
@@ -395,7 +395,7 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
|
||||
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))) {
|
||||
|
||||
@@ -278,11 +278,11 @@ function run_code_exec(code, toplevel, timeout) {
|
||||
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) {
|
||||
|
||||
@@ -2078,8 +2078,8 @@ if (require.main !== module) {
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user