Replace strictSemicolons and allowTrailingCommas with onInsertedSemicolon and onTrailingComma

This commit is contained in:
Marijn Haverbeke
2015-03-12 21:57:40 +01:00
parent 9fb3a4f5ce
commit ba750b253b
3 changed files with 65 additions and 22 deletions

View File

@@ -28946,3 +28946,22 @@ test("function f() {} / 1 /", {
}
]
});
var semicolons = []
testAssert("var x\nreturn\n10", function() {
var result = semicolons.join(" ");
semicolons.length = 0;
if (result != "5 12 15")
return "Unexpected result for onInsertedSemicolon: " + result;
}, {onInsertedSemicolon: function(pos) { semicolons.push(pos); },
allowReturnOutsideFunction: true,
loose: false})
var trailingCommas = []
testAssert("[1,2,] + {foo: 1,}", function() {
var result = trailingCommas.join(" ");
trailingCommas.length = 0;
if (result != "4 16")
return "Unexpected result for onTrailingComma: " + result;
}, {onTrailingComma: function(pos) { trailingCommas.push(pos); },
loose: false})