[340756] [validation] False syntax error in with (x) var y; JUnit test cases are added for the issue. JUnit test cases StatementRecoveryTest.test0011 and StatementRecoveryTest.test0013 are updated due regarding the new parser gramma. Signed-off-by: vrubezhny <vrubezhny@exadel.com>
diff --git a/tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/parser/StatementRecoveryTest.java b/tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/parser/StatementRecoveryTest.java index d1b118a..2a299bf 100644 --- a/tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/parser/StatementRecoveryTest.java +++ b/tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/parser/StatementRecoveryTest.java
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -972,18 +972,12 @@ String expectedDietPlusBodyWithStatementRecoveryUnitToString = "function X() {\n" + - " function foo() {\n" + - " if (true)\n" + - " {\n" + - " foo();\n" + - " }\n" + - " for (; ; ) \n" + - " ;\n" + - " if (true)\n" + - " {\n" + - " foo();\n" + - " }\n" + - " }\n" + + "}\n" + + "function foo() {\n" + + " if (true)\n" + + " {\n" + + " foo();\n" + + " }\n" + "}\n"; String expectedFullUnitToString = @@ -1082,10 +1076,9 @@ String expectedDietPlusBodyWithStatementRecoveryUnitToString = "function X() {\n" + - " function foo() {\n" + - " for (var i in $missing$) \n" + - " ;\n" + - " }\n" + + "}\n" + + "function foo() {\n" + + " var i;\n" + "}\n"; String expectedFullUnitToString =
diff --git a/tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/regression/BasicParserTests.java b/tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/regression/BasicParserTests.java index ae47df5..fd723a9 100644 --- a/tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/regression/BasicParserTests.java +++ b/tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/regression/BasicParserTests.java
@@ -488,6 +488,7 @@ "\n" ); } + public void test009a() { // for this.runParseTest( "for (;i<3;i++)\n" + @@ -498,6 +499,16 @@ "\n" ); } + + public void test009b() { // for + this.runParseTest( + "for (i=1;i<3;i++) var y\n" + + "\n", + "X.js", + "for (i = 1; (i < 3); i ++) \n var y;"+ + "\n" + ); + } public void test010() { // for in this.runParseTest( @@ -509,19 +520,7 @@ "\n" ); } - - - public void test011() { // for in - this.runParseTest( - "with (foo)\n" + - " bar;" + - "\n", - "X.js", - "with (foo)\n"+ - " bar;\n" - ); - } - + public void test010a() { // for in this.runParseTest( "for (a in this.vars)\n" + @@ -533,6 +532,53 @@ ); } + public void test010b() { // for in + this.runParseTest( + "for (var a in this.vars) var y\n" + + "\n", + "X.js", + "for (var a in this.vars) \n var y;"+ + "\n" + ); + } + + public void test011() { // with + this.runParseTest( + "with (foo)\n" + + " bar;" + + "\n", + "X.js", + "with (foo)\n"+ + " bar;\n" + ); + } + + public void test011a() { // with + this.runParseTest( + "with (foo) var bar\n", + "X.js", + "with (foo)\n" + + " var bar;\n" + ); + } + + public void test012() { // while + this.runParseTest( + "while (foo)\n" + + " bar;" + + "\n", + "X.js", + "while (foo) bar;\n" + ); + } + + public void test012a() { // while + this.runParseTest( + "while (foo) var bar\n", + "X.js", + "while (foo) var bar;\n" + ); + } public void test015() { // missing semicolon this.runParseTest( @@ -546,6 +592,8 @@ ); } + + public void test015a() { // missing semicolon this.runParseTest( "function bar() {\n"+