Permalink
Browse files

change the internal ast such that "var c,d;" is represented by a sing…

…le localDeclaration (instead of 2) so that something like "if () var c,d" works correctly
  • Loading branch information...
1 parent 50bc1b1 commit 4a73427d5a330383012249c3bcb84f7bb45eee96 pberkland committed Nov 2, 2007
@@ -392,6 +392,9 @@ protected Map getCompilerOptions() {
defaultOptions.put(CompilerOptions.OPTION_ReportSyntheticAccessEmulation, CompilerOptions.WARNING);
defaultOptions.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.PRESERVE);
defaultOptions.put(CompilerOptions.OPTION_ReportUnnecessaryElse, CompilerOptions.WARNING );
+ defaultOptions.put(CompilerOptions.OPTION_Unresolved_Field, CompilerOptions.ERROR );
+ defaultOptions.put(CompilerOptions.OPTION_Unresolved_Method, CompilerOptions.ERROR );
+ defaultOptions.put(CompilerOptions.OPTION_Unresolved_Type, CompilerOptions.ERROR );
return defaultOptions;
}
@@ -36,17 +36,15 @@ public void test003() { // var
"var i=1,c=4;" +
"\n",
"X.js",
- "var i = 1;\n" +
- "var c = 4;" +
+ "var i = 1, c = 4;" +
"\n"
);
this.runParseTest(
"var i=1,c;" +
"\n",
"X.js",
- "var i = 1;\n" +
- "var c;" +
+ "var i = 1, c;" +
"\n"
);
}
@@ -64,8 +62,7 @@ public void test003a() { // var
"var i=1,c;" +
"\n",
"X.js",
- "var i = 1;\n" +
- "var c;" +
+ "var i = 1, c;" +
"\n"
);
}
@@ -773,7 +770,7 @@ public void test041() {
this.runParseTest(
"(function (){});\n",
"X.js",
- "(function (){});\n"
+ "function () {\n};\n"
);
}
@@ -846,7 +843,7 @@ public void test045() {
this.runParseTest(
"((weight + 1)/2)",
"X.js",
- "((weight + 1)/2)"
+ "((weight + 1) / 2);\n"
);
}
@@ -877,6 +874,70 @@ public void test050() {
);
}
+ public void test051() {
+ // method on function object
+ this.runParseTest(
+ "var c=function(){}.bind();",
+ "X.js",
+ "var c = function () {\n}.bind();\n"
+ );
+ }
+
+ public void test051b() {
+ // method on function object
+ this.runParseTest(
+
+ "transforms = map(function (){\n"+
+ "}.bind()).reject(function (){\n"+
+ "});",
+
+ "X.js",
+ "transforms = map(function () {\n"+
+ "}.bind()).reject(function () {\n"+
+ "});\n"
+ );
+ }
+
+ public void test051c() {
+ // method on function object
+ this.runParseTest(
+
+ "map(function(){"+
+ "if(true) {"+
+ "} else if(true)"+
+ "var components = value.match(),"+
+ "unit = null;"+
+ "}.bind(this));",
+
+ "X.js",
+ "map(function () {\n"+
+ " if (true)\n {\n"+
+ " }\n else\n if (true)\n"+
+ " var components = value.match(),"+
+ " unit = null;"+
+ "\n}.bind(this));\n"
+ );
+ }
+
+ public void test051d() {
+ this.runParseTest(
+
+ "function bb(){"+
+ "if(true)"+
+ "var components = value.match(),"+
+ "unit = null;"+
+ "};",
+
+ "X.js",
+ "function bb() {\n"+
+ " if (true)\n"+
+ " var components = value.match(),"+
+ " unit = null;"+
+ "\n}\n;\n"
+ );
+ }
+
+
}
@@ -574,6 +574,22 @@ public void test044() {
}
+ public void test045() {
+ this.runNegativeTest(
+ new String[] {
+ "X.js",
+ " var a,b=1;\n" +
+ " var c= b;\n" +
+ " function abc(){" +
+ " var d= 1,e=4;\n" +
+ " var f=e;}\n" +
+ ""
+ },
+ ""
+ );
+
+ }
+
}
@@ -41,38 +41,44 @@ public EvaluationSetup(Test test, String complianceLevel) {
super(test, complianceLevel);
}
+
protected void setUp() {
if (this.context == null) { // non null if called from subclass
+
// Launch VM in evaluation mode
- int evalPort = Util.getFreePort();
- try {
- LocalVMLauncher launcher = LocalVMLauncher.getLauncher();
- launcher.setVMPath(JRE_PATH);
- launcher.setEvalPort(evalPort);
- launcher.setEvalTargetPath(EVAL_DIRECTORY);
- this.launchedVM = launcher.launch();
- } catch (TargetException e) {
- throw new Error(e.getMessage());
- }
-
- // Thread that read the stout of the VM so that the VM doesn't block
- try {
- startReader("VM's stdout reader", this.launchedVM.getInputStream(), System.out);
- } catch (TargetException e) {
- }
-
- // Thread that read the sterr of the VM so that the VM doesn't block
- try {
- startReader("VM's sterr reader", this.launchedVM.getErrorStream(), System.err);
- } catch (TargetException e) {
- }
-
+ int evalPort;
+ if (EvaluationTest.JSDT_ENABLE) {
+ evalPort = Util.getFreePort();
+ try {
+ LocalVMLauncher launcher = LocalVMLauncher.getLauncher();
+ launcher.setVMPath(JRE_PATH);
+ launcher.setEvalPort(evalPort);
+ launcher.setEvalTargetPath(EVAL_DIRECTORY);
+ this.launchedVM = launcher.launch();
+ } catch (TargetException e) {
+ throw new Error(e.getMessage());
+ }
+ // Thread that read the stout of the VM so that the VM doesn't block
+ try {
+ startReader("VM's stdout reader", this.launchedVM
+ .getInputStream(), System.out);
+ } catch (TargetException e) {
+ }
+ // Thread that read the sterr of the VM so that the VM doesn't block
+ try {
+ startReader("VM's sterr reader", this.launchedVM
+ .getErrorStream(), System.err);
+ } catch (TargetException e) {
+ }
+ }
// Create context
this.context = new EvaluationContext();
+ if (EvaluationTest.JSDT_ENABLE) {
// Create target
this.target = new TargetInterface();
this.target.connect("localhost", evalPort, 10000);
+ }
// Create name environment
this.env = new FileSystem(Util.getJavaClassLibs(), new String[0], null);
@@ -42,7 +42,9 @@
import org.eclipse.wst.jsdt.internal.eval.IRequestor;
import org.eclipse.wst.jsdt.internal.eval.InstallException;
+
public class EvaluationTest extends AbstractCompilerTest implements StopableTestCase {
+ public static final boolean JSDT_ENABLE=false;
public class Requestor implements IRequestor {
public int resultIndex = -1;

0 comments on commit 4a73427

Please sign in to comment.