Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(543)

Unified Diff: editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/search/SearchEngineTest.java

Issue 10417044: Type inference in if, while, for and for-in statements (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changes for review comments Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/search/SearchEngineTest.java
diff --git a/editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/search/SearchEngineTest.java b/editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/search/SearchEngineTest.java
index cc4c6c54469df21aaaec019359553eaa3cdf4081..029c4d1fdb74f4494c64fa40479319954da00f0c 100644
--- a/editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/search/SearchEngineTest.java
+++ b/editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/search/SearchEngineTest.java
@@ -679,13 +679,17 @@ public class SearchEngineTest extends TestCase {
}
}
- public void test_SearchEngine_searchReferences_method_targetTypePropagate() throws Exception {
+ /**
+ * Type of "target" is propagate from value in variable declaration.
+ */
+ public void test_SearchEngine_searchReferences_method_typePropagate_declaration()
+ throws Exception {
TestProject testProject = new TestProject();
try {
String source = buildSource(
"// filler filler filler filler filler filler filler filler filler filler",
"class A {",
- " test() {}",
+ " test(var p) {}",
"}",
"bar() {",
" var a = new A();",
@@ -708,6 +712,39 @@ public class SearchEngineTest extends TestCase {
}
}
+ /**
+ * Type of "target" is propagate from the type of "is Type" condition.
+ */
+ public void test_SearchEngine_searchReferences_method_typePropagate_isType() throws Exception {
+ TestProject testProject = new TestProject();
+ try {
+ String source = buildSource(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {",
+ " test(var p) {}",
+ "}",
+ "bar(var v) {",
+ " if (v is A) {",
+ " v.test(1);",
+ " }",
+ "}",
+ "");
+ CompilationUnit unit = testProject.setUnitContent("Test.dart", source);
+ indexUnits(unit);
+ // find references
+ Method method = ((Type) unit.getChildren()[0]).getMethod("test", null);
+ List<SearchMatch> matches = getMethodReferences(method);
+ assertThat(matches).hasSize(1);
+ // assert references
+ SearchMatch match = matches.get(0);
+ int matchOffset = match.getSourceRange().getOffset();
+ assertEquals(source.indexOf("test(1);"), matchOffset);
+ assertTrue(match.isQualified());
+ } finally {
+ testProject.dispose();
+ }
+ }
+
public void test_SearchEngine_searchReferences_type() throws Exception {
Type type = moneyLibrary.getCompilationUnit("simple_money.dart").getType("SimpleMoney");
SearchEngine engine = createSearchEngine();

Powered by Google App Engine
This is Rietveld 408576698