introduce templates (#4603)

This commit is contained in:
Alex Lam S.L
2021-02-01 09:20:13 +00:00
committed by GitHub
parent d4685640a0
commit ba6e29d6fd
9 changed files with 281 additions and 74 deletions

View File

@@ -115,8 +115,8 @@ describe("String literals", function() {
UglifyJS.parse(test);
}, function(e) {
return e instanceof UglifyJS.JS_Parse_Error
&& e.message === "Invalid hex-character pattern in string";
});
&& /^Invalid escape sequence: \\u/.test(e.message);
}, test);
});
});
it("Should reject invalid code points in Unicode escape sequence", function() {
@@ -130,8 +130,8 @@ describe("String literals", function() {
UglifyJS.parse(test);
}, function(e) {
return e instanceof UglifyJS.JS_Parse_Error
&& /^Invalid character code: /.test(e.message);
});
&& /^Invalid escape sequence: \\u{1/.test(e.message);
}, test);
});
});
});

View File

@@ -53,7 +53,10 @@ describe("Template literals", function() {
[ "`foo\\\\r\nbar`", "`foo\\\\r\nbar`" ],
].forEach(function(test) {
var input = "console.log(" + test[0] + ");";
var result = UglifyJS.minify(input);
var result = UglifyJS.minify(input, {
compress: false,
mangle: false,
});
if (result.error) throw result.error;
var expected = "console.log(" + test[1] + ");";
assert.strictEqual(result.code, expected, test[0]);