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

Unified Diff: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java

Issue 14668014: Report CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
diff --git a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
index aee4ea4614f99389b43d2c4a4ca851c2db94242b..1de9d0a1483e58cac40b932e3cece4ad6803895a 100644
--- a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
+++ b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
@@ -215,15 +215,6 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
verify(source);
}
- public void fail_recursiveFactoryRedirect() throws Exception {
- Source source = addSource(createSource(//
- // TODO
- ));
- resolve(source);
- assertErrors(CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT);
- verify(source);
- }
-
public void fail_recursiveFunctionTypeAlias_direct() throws Exception {
Source source = addSource(createSource(//
"typedef F(F f);"));
@@ -2168,6 +2159,76 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
verify(source);
}
+ public void test_recursiveFactoryRedirect() throws Exception {
+ Source source = addSource(createSource(//
+ "class A {",
+ " factory A() = C;",
+ "}",
+ "class B {",
+ " factory B() = A;",
+ "}",
+ "class C {",
+ " factory C() = B;",
+ "}"));
+ resolve(source);
+ assertErrors(
+ CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
+ CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
+ CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT);
+ verify(source);
+ }
+
+ public void test_recursiveFactoryRedirect_directSelfReference() throws Exception {
+ Source source = addSource(createSource(//
+ "class A {",
+ " factory A() = A;",
+ "}"));
+ resolve(source);
+ assertErrors(CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT);
+ verify(source);
+ }
+
+ public void test_recursiveFactoryRedirect_named() throws Exception {
+ Source source = addSource(createSource(//
+ "class A {",
+ " factory A.nameA() = C.nameC;",
+ "}",
+ "class B {",
+ " factory B.nameB() = A.nameA;",
+ "}",
+ "class C {",
+ " factory C.nameC() = B.nameB;",
+ "}"));
+ resolve(source);
+ assertErrors(
+ CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
+ CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
+ CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT);
+ verify(source);
+ }
+
+ /**
+ * "A" references "C" which has cycle with "B". But we should not report problem for "A" - it is
+ * not the part of a cycle.
+ */
+ public void test_recursiveFactoryRedirect_outsideCycle() throws Exception {
+ Source source = addSource(createSource(//
+ "class A {",
+ " factory A() = C;",
+ "}",
+ "class B {",
+ " factory B() = C;",
+ "}",
+ "class C {",
+ " factory C() = B;",
+ "}"));
+ resolve(source);
+ assertErrors(
+ CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT,
+ CompileTimeErrorCode.RECURSIVE_FACTORY_REDIRECT);
+ verify(source);
+ }
+
public void test_rethrowOutsideCatch() throws Exception {
Source source = addSource(createSource(//
"f() {",

Powered by Google App Engine
This is Rietveld 408576698