Merge branch 'master' into harmony
This commit is contained in:
@@ -30,5 +30,27 @@ describe("line-endings", function() {
|
||||
var result = Uglify.minify(js, options);
|
||||
assert.strictEqual(result.code, expected_code);
|
||||
});
|
||||
|
||||
it("Should not allow line terminators in regexp", function() {
|
||||
var inputs = [
|
||||
"/\n/",
|
||||
"/\r/",
|
||||
"/\u2028/",
|
||||
"/\u2029/",
|
||||
"/someRandomTextLike[]()*AndThen\n/"
|
||||
]
|
||||
var test = function(input) {
|
||||
return function() {
|
||||
Uglify.parse(input);
|
||||
}
|
||||
}
|
||||
var fail = function(e) {
|
||||
return e instanceof Uglify.JS_Parse_Error &&
|
||||
e.message === "Unexpected line terminator";
|
||||
}
|
||||
for (var i = 0; i < inputs.length; i++) {
|
||||
assert.throws(test(inputs[i]), fail);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
34
test/mocha/new.js
Normal file
34
test/mocha/new.js
Normal file
@@ -0,0 +1,34 @@
|
||||
var assert = require("assert");
|
||||
var uglify = require("../../");
|
||||
|
||||
describe("New", function() {
|
||||
it("Should attach callback parens after some tokens", function() {
|
||||
var tests = [
|
||||
"new x(1);",
|
||||
"new (function(foo){this.foo=foo;})(1);",
|
||||
"new true;",
|
||||
"new (0);",
|
||||
"new (!0);",
|
||||
"new (bar = function(foo) {this.foo=foo;})(123);"
|
||||
];
|
||||
var expected = [
|
||||
"new x(1);",
|
||||
"new function(foo) {\n this.foo = foo;\n}(1);",
|
||||
"new true;",
|
||||
"new 0;",
|
||||
"new (!0);",
|
||||
"new (bar = function(foo) {\n this.foo = foo;\n})(123);"
|
||||
];
|
||||
for (var i = 0; i < tests.length; i++) {
|
||||
assert.strictEqual(
|
||||
uglify.minify(tests[i], {
|
||||
fromString: true,
|
||||
output: {beautify: true},
|
||||
compress: false,
|
||||
mangle: false
|
||||
}).code,
|
||||
expected[i]
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user