Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvrubezhny2014-01-22 17:01:31 +0000
committervrubezhny2014-01-22 17:01:31 +0000
commitc5d400a5bfa28a2db8621fd144dadec48a8eb310 (patch)
treecc17ca660e047a34c9ef5f1ce48d4b2e148d4390
parent29cf115223bfd2f34b352a89aff97d373007ece9 (diff)
downloadwebtools.jsdt.tests-R3_5_maintenance.tar.gz
webtools.jsdt.tests-R3_5_maintenance.tar.xz
webtools.jsdt.tests-R3_5_maintenance.zip
The infer engine is made to calculate the correct types for local declarations initialized by this reference value JUnit Test Case is added due to verify the issue. Signed-off-by: vrubezhny <vrubezhny@exadel.com>
-rw-r--r--tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/regression/InferTypesTests.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/regression/InferTypesTests.java b/tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/regression/InferTypesTests.java
index c0e85fb..ffd3772 100644
--- a/tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/regression/InferTypesTests.java
+++ b/tests/org.eclipse.wst.jsdt.core.tests.compiler/src/org/eclipse/wst/jsdt/core/tests/compiler/regression/InferTypesTests.java
@@ -2606,4 +2606,30 @@ public class InferTypesTests extends AbstractRegressionTest {
);
assertNull("There should not be a global function def()", declaration.findInferredType("@G".toCharArray()).findMethod("def".toCharArray(), null));
}
+
+ /*
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=411589 - Invalid this detection
+ */
+ public void testInitializationWithThisReference() {
+ CompilationUnitDeclaration declaration = this.runInferTest(
+ "(function() {\n" +
+ " var clazz = function() {\n" +
+ " var me = this;\n" +
+ " var you = me;\n" +
+ " me.funcMe = function() {return this;};\n" +
+ " you.funcYou = function() {return this;};\n" +
+ " this.funcWe = function() {return this;};\n" +
+ " }\n" +
+ "})();",
+ "X.js",
+ null,
+ getDefaultOptions()
+ );
+ assertNull("There should not be a global function funcMe()", declaration.findInferredType("@G".toCharArray()).findMethod("funcMe".toCharArray(), null));
+ assertNull("There should not be a global function funcYou()", declaration.findInferredType("@G".toCharArray()).findMethod("funcYou".toCharArray(), null));
+
+ assertNotNull("There should be a local method funcMe() in class clazz", declaration.findInferredType("clazz".toCharArray()).findMethod("funcMe".toCharArray(), null));
+ assertNotNull("There should be a local method funcYou() in class clazz", declaration.findInferredType("clazz".toCharArray()).findMethod("funcYou".toCharArray(), null));
+ assertNotNull("There should be a local method funcWe() in class clazz", declaration.findInferredType("clazz".toCharArray()).findMethod("funcWe".toCharArray(), null));
+ }
}

Back to the top