Allow single line comments ending \u2028\u2029
This commit is contained in:
parent
9676167aac
commit
722276fb35
|
|
@ -261,7 +261,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
|
|||
var text = S.text;
|
||||
for (var i = S.pos, n = S.text.length; i < n; ++i) {
|
||||
var ch = text[i];
|
||||
if (ch == '\n' || ch == '\r')
|
||||
if ("\n\r\u2028\u2029".indexOf(ch) >= 0)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
|
|
|
|||
27
test/mocha/comment.js
Normal file
27
test/mocha/comment.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
var assert = require("assert");
|
||||
var uglify = require("../../");
|
||||
|
||||
describe("Comment", function() {
|
||||
it("Should recognize eol of single line comments", function() {
|
||||
var tests = [
|
||||
"//Some comment\n>",
|
||||
"//Some comment\r>",
|
||||
"//Some comment\r\n>",
|
||||
"//Some comment\u2028>",
|
||||
"//Some comment\u2029>"
|
||||
];
|
||||
|
||||
var fail = function(e) {
|
||||
return e instanceof uglify.JS_Parse_Error &&
|
||||
e.message === "SyntaxError: Unexpected token: operator (>)" &&
|
||||
e.line === 2 &&
|
||||
e.col === 0;
|
||||
}
|
||||
|
||||
for (var i = 0; i < tests.length; i++) {
|
||||
assert.throws(function() {
|
||||
uglify.parse(tests[i], {fromString: true})
|
||||
}, fail, tests[i]);
|
||||
}
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user