minor clean-ups (#5701)

This commit is contained in:
Alex Lam S.L
2022-10-05 19:06:21 +01:00
committed by GitHub
parent be8ccc3ab5
commit 94a954c3d1
17 changed files with 89 additions and 77 deletions

View File

@@ -12,7 +12,7 @@ concat_1: {
var e = 1 + x() + 2 + "X" + 3 + "boo";
// be careful with concatentation with "\0" with octal-looking strings.
// be careful with concatenation with "\0" with octal-looking strings.
var f = "\0" + 360 + "\0" + 8 + "\0";
}
expect: {

View File

@@ -525,7 +525,7 @@ if_var_return_2: {
}
}
if_var_retrn_3: {
if_var_return_3: {
options = {
conditionals: true,
if_return: true,

View File

@@ -140,12 +140,12 @@ mangle: {
}
input: {
import foo, { bar } from "baz";
consoe.log(moo);
console.log(moo);
import * as moo from "moz";
}
expect: {
import o, { bar as m } from "baz";
consoe.log(r);
console.log(r);
import * as r from "moz";
}
}
@@ -157,12 +157,12 @@ rename_mangle: {
}
input: {
import foo, { bar } from "baz";
consoe.log(moo);
console.log(moo);
import * as moo from "moz";
}
expect: {
import o, { bar as m } from "baz";
consoe.log(r);
console.log(r);
import * as r from "moz";
}
}

View File

@@ -1,5 +1,5 @@
/**
* There was an incorrect sort behaviour documented in issue #143:
* There was an incorrect sort behavior documented in issue #143:
* (x = f(…)) <= x → x >= (x = f(…))
*
* For example, let the equation be:
@@ -12,37 +12,54 @@
* a >= (a = parseInt('100')) → 99 >= 100 → false
*/
tranformation_sort_order_equal: {
transformation_sort_order_equal: {
options = {
comparisons: true,
}
input: { (a = parseInt('100')) == a }
expect: { (a = parseInt('100')) == a }
input: {
console.log((a = parseInt("100")) == a);
}
expect: {
console.log((a = parseInt("100")) == a);
}
expect_stdout: "true"
}
tranformation_sort_order_unequal: {
transformation_sort_order_unequal: {
options = {
comparisons: true,
}
input: { (a = parseInt('100')) != a }
expect: { (a = parseInt('100')) != a }
input: {
console.log((a = parseInt("100")) != a);
}
expect: {
console.log((a = parseInt("100")) != a);
}
expect_stdout: "false"
}
tranformation_sort_order_lesser_or_equal: {
transformation_sort_order_lesser_or_equal: {
options = {
comparisons: true,
}
input: { (a = parseInt('100')) <= a }
expect: { (a = parseInt('100')) <= a }
input: {
console.log((a = parseInt("100")) <= a);
}
expect: {
console.log((a = parseInt("100")) <= a);
}
expect_stdout: "true"
}
tranformation_sort_order_greater_or_equal: {
transformation_sort_order_greater_or_equal: {
options = {
comparisons: true,
}
input: { (a = parseInt('100')) >= a }
expect: { (a = parseInt('100')) >= a }
}
input: {
console.log((a = parseInt("100")) >= a);
}
expect: {
console.log((a = parseInt("100")) >= a);
}
expect_stdout: "true"
}

View File

@@ -15,7 +15,7 @@ collapse: {
var a;
b = c();
a = typeof b === 'function' ? b() : b;
return 'stirng' == typeof a && d();
return 'string' == typeof a && d();
}
function f3(c) {
var a;
@@ -41,7 +41,7 @@ collapse: {
return void 0 !== ('function' === typeof b ? b() : b) && c();
}
function f2(b) {
return 'stirng' == typeof ('function' === typeof (b = c()) ? b() : b) && d();
return 'string' == typeof ('function' === typeof (b = c()) ? b() : b) && d();
}
function f3(c) {
var a;

View File

@@ -570,7 +570,7 @@ inlined_assignments: {
expect_stdout: "PASS"
}
inilne_for: {
inline_for: {
options = {
inline: true,
join_vars: true,
@@ -590,7 +590,7 @@ inilne_for: {
expect_stdout: "PASS"
}
inilne_var: {
inline_var: {
options = {
inline: true,
join_vars: true,

View File

@@ -400,7 +400,7 @@ describe("comments", function() {
assert.strictEqual(ast.print_to_string({comments: "all"}), "/*!test1*/\n/*test2*/\n//!test3\n//test4\n//test5\n//!test6\n//test7\n//!test8");
});
it("Should be able to filter commments with the 'some' option", function() {
it("Should be able to filter comments with the 'some' option", function() {
var ast = UglifyJS.parse("// foo\n/*@preserve*/\n// bar\n/*@license*/\n//@license with the wrong comment type\n/*@cc_on something*/");
assert.strictEqual(ast.print_to_string({comments: "some"}), "/*@preserve*/\n/*@license*/\n/*@cc_on something*/");
});

View File

@@ -348,7 +348,7 @@ describe("Directives", function() {
'"use strict";doSomething("foo");'
],
[
// Nothing gets optimised in the compressor because "use asm" is the first statement
// Nothing gets optimized in the compressor because "use asm" is the first statement
'"use asm";"use\\x20strict";1+1;',
'"use asm";"use\\x20strict";1+1;'
],

View File

@@ -245,7 +245,7 @@ describe("sourcemaps", function() {
if (result.error) throw result.error;
assert.strictEqual(result.code + "\n", read("test/input/issue-3294/output.js"));
});
it("Should work in presence of unrecognised annotations", function() {
it("Should work in presence of unrecognized annotations", function() {
var result = UglifyJS.minify(read("test/input/issue-3441/input.js"), {
compress: false,
mangle: false,

View File

@@ -1142,7 +1142,7 @@ function createStatement(recurmax, canThrow, canBreak, canContinue, cannotReturn
}
case STMT_FUNC_EXPR:
// "In non-strict mode code, functions can only be declared at top level, inside a block, or ..."
// (dont both with func decls in `if`; it's only a parser thing because you cant call them without a block)
// (don't make func decls in `if`; it's only a parser thing because you can't call them without a block)
return "{" + createFunction(recurmax, NO_DEFUN, canThrow, stmtDepth) + "}";
case STMT_TRY:
// catch var could cause some problems