Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updated automatic comma insertion support (cf #950)

  • Loading branch information...
commit f3d3a0fc90ce7f1bc765ee5d0f8b672e4802f867 1 parent d316102
@guyzmo authored
Showing with 51 additions and 1 deletion.
  1. +4 −1 src/stable/jshint.js
  2. +47 −0 tests/stable/unit/parser.js
View
5 src/stable/jshint.js
@@ -867,7 +867,10 @@ var JSHINT = (function () {
error("E030", state.tokens.curr, state.tokens.curr.id);
}
- while (rbp < state.tokens.next.lbp) {
+ var end_of_expr = state.tokens.next.identifier &&
+ !state.tokens.curr.led &&
+ state.tokens.curr.line !== state.tokens.next.line;
+ while (rbp < state.tokens.next.lbp && !end_of_expr) {
isArray = state.tokens.curr.value === "Array";
isObject = state.tokens.curr.value === "Object";
View
47 tests/stable/unit/parser.js
@@ -2945,3 +2945,50 @@ exports["regression test for GH-890"] = function (test) {
test.done();
};
+
+exports["automatic comma insertion GH-950"] = function (test) {
+ var code = [
+ "var a = b",
+ "instanceof c;",
+
+ "var a = { b: 'X' }",
+ "delete a.b",
+
+ "var y = true",
+ " && true && false;",
+
+ "function test() {",
+ " return",
+ " { a: 1 }",
+ "}",
+ ];
+
+ var run = TestRun(test)
+ .addError(2, "Bad line breaking before 'instanceof'.")
+ .addError(6, "Bad line breaking before '&&'.")
+ .addError(9, "Label 'a' on 1 statement.")
+ .addError(9, "Expected an assignment or function call and instead saw an expression.");
+
+ run.test(code, {asi: true});
+ run.test(code, {es5: true, asi: true});
+ run.test(code, {esnext: true, asi: true});
+ run.test(code, {moz: true, asi: true});
+
+ var run = TestRun(test)
+ .addError(2, "Bad line breaking before 'instanceof'.")
+ .addError(3, "Missing semicolon.")
+ .addError(4, "Missing semicolon.")
+ .addError(6, "Bad line breaking before '&&'.")
+ .addError(8, "Line breaking error 'return'.")
+ .addError(8, "Missing semicolon.")
+ .addError(9, "Label 'a' on 1 statement.")
+ .addError(9, "Expected an assignment or function call and instead saw an expression.")
+ .addError(9, "Missing semicolon.");
+
+ run.test(code, {asi: false});
+ run.test(code, {es5: true, asi: false});
+ run.test(code, {esnext: true, asi: false});
+ run.test(code, {moz: true, asi: false});
+
+ test.done();
+};
Please sign in to comment.
Something went wrong with that request. Please try again.