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

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

Issue 14569025: Report CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIALIZER (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 1de9d0a1483e58cac40b932e3cece4ad6803895a..d1ce437c14c742e84ddf79fc36927dd541f9772e 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
@@ -258,26 +258,6 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
verify(source);
}
- public void fail_referenceToDeclaredVariableInInitializer_getter() throws Exception {
- Source source = addSource(createSource(//
- "f() {",
- " int x = x + 1;",
- "}"));
- resolve(source);
- assertErrors(CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIALIZER);
- verify(source);
- }
-
- public void fail_referenceToDeclaredVariableInInitializer_setter() throws Exception {
- Source source = addSource(createSource(//
- "f() {",
- " int x = x++;",
- "}"));
- resolve(source);
- assertErrors(CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIALIZER);
- verify(source);
- }
-
public void fail_reservedWordAsIdentifier() throws Exception {
Source source = addSource(createSource(//
"int class = 2;"));
@@ -2229,6 +2209,47 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
verify(source);
}
+ public void test_referenceToDeclaredVariableInInitializer_closure() throws Exception {
+ Source source = addSource(createSource(//
+ "f() {",
+ " var x = (x) {};",
+ "}"));
+ resolve(source);
+ assertErrors(CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIALIZER);
+ verify(source);
+ }
+
+ public void test_referenceToDeclaredVariableInInitializer_getter() throws Exception {
+ Source source = addSource(createSource(//
+ "f() {",
+ " int x = x + 1;",
+ "}"));
+ resolve(source);
+ assertErrors(CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIALIZER);
+ verify(source);
+ }
+
+ public void test_referenceToDeclaredVariableInInitializer_setter() throws Exception {
+ Source source = addSource(createSource(//
+ "f() {",
+ " int x = x++;",
+ "}"));
+ resolve(source);
+ assertErrors(CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIALIZER);
+ verify(source);
+ }
+
+ public void test_referenceToDeclaredVariableInInitializer_unqualifiedInvocation()
+ throws Exception {
+ Source source = addSource(createSource(//
+ "f() {",
+ " var x = x();",
+ "}"));
+ resolve(source);
+ assertErrors(CompileTimeErrorCode.REFERENCE_TO_DECLARED_VARIABLE_IN_INITIALIZER);
+ verify(source);
+ }
+
public void test_rethrowOutsideCatch() throws Exception {
Source source = addSource(createSource(//
"f() {",
@@ -2337,10 +2358,10 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
public void test_superInInvalidContext_topLevelVariableInitializer() throws Exception {
Source source = addSource(createSource(//
- "var v = super.v;"));
+ "var v = super.y;"));
resolve(source);
assertErrors(CompileTimeErrorCode.SUPER_IN_INVALID_CONTEXT);
- // no verify(), 'super.v' is not resolved
+ // no verify(), 'super.y' is not resolved
}
public void test_undefinedClass_const() throws Exception {

Powered by Google App Engine
This is Rietveld 408576698