Skip to content

Commit

Permalink
fix automatic insertion of semicolon before new line followed by
Browse files Browse the repository at this point in the history
comment
  • Loading branch information
mguillem committed Oct 13, 2011
1 parent ac9b83c commit 676a674
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/org/mozilla/javascript/Parser.java
Expand Up @@ -333,7 +333,6 @@ private int peekToken()
lineno++;
sawEOL = true;
} else {
sawEOL = false;
if (compilerEnv.isRecordingComments()) {
recordComment(lineno);
}
Expand Down
10 changes: 10 additions & 0 deletions testsrc/org/mozilla/javascript/tests/ParserTest.java
Expand Up @@ -28,6 +28,16 @@ public void testAutoSemiColonBetweenNames() {
assertEquals("z", third.getString());
}

public void testParseAutoSemiColonBeforeNewlineAndComments() throws IOException {
AstRoot root = parseAsReader(
"var s = 3\n"
+ "/* */var t = 1;");
assertNotNull(root.getComments());
assertEquals(1, root.getComments().size());

assertEquals("var s = 3;\nvar t = 1;\n", root.toSource());
}

public void testLinenoAssign() {
AstRoot root = parse("\n\na = b");
ExpressionStatement st = (ExpressionStatement) root.getFirstChild();
Expand Down

0 comments on commit 676a674

Please sign in to comment.