| Index: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/StaticWarningCodeTest.java
|
| diff --git a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/StaticWarningCodeTest.java b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/StaticWarningCodeTest.java
|
| index 0c664b468959ab9f3d179b55a5ae0022dff1e93c..1acbfbefaf03356f7bb4f8701d9a69b273158bfe 100644
|
| --- a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/StaticWarningCodeTest.java
|
| +++ b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/StaticWarningCodeTest.java
|
| @@ -921,6 +921,17 @@ public class StaticWarningCodeTest extends ResolverTestCase {
|
| verify(source);
|
| }
|
|
|
| + public void test_fieldInitializedInInitializerAndDeclaration_final() throws Exception {
|
| + Source source = addSource(createSource(//
|
| + "class A {",
|
| + " final int x = 0;",
|
| + " A() : x = 1 {}",
|
| + "}"));
|
| + resolve(source);
|
| + assertErrors(StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION);
|
| + verify(source);
|
| + }
|
| +
|
| public void test_fieldInitializerNotAssignable() throws Exception {
|
| Source source = addSource(createSource(//
|
| "class A {",
|
| @@ -943,6 +954,38 @@ public class StaticWarningCodeTest extends ResolverTestCase {
|
| verify(source);
|
| }
|
|
|
| + /**
|
| + * This test doesn't test the FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR code, but tests the
|
| + * FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION code instead. It is provided here to show
|
| + * coverage over all of the permutations of initializers in constructor declarations.
|
| + * <p>
|
| + * Note: FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION covers a subset of
|
| + * FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR, since it more specific, we use it instead of
|
| + * the broader code
|
| + */
|
| + public void test_finalInitializedInDeclarationAndConstructor_initializers() throws Exception {
|
| + Source source = addSource(createSource(//
|
| + "class A {",
|
| + " final x = 0;",
|
| + " A() : x = 0 {}",
|
| + "}"));
|
| + resolve(source);
|
| + assertErrors(StaticWarningCode.FIELD_INITIALIZED_IN_INITIALIZER_AND_DECLARATION);
|
| + verify(source);
|
| + }
|
| +
|
| + public void test_finalInitializedInDeclarationAndConstructor_initializingFormal()
|
| + throws Exception {
|
| + Source source = addSource(createSource(//
|
| + "class A {",
|
| + " final x = 0;",
|
| + " A(this.x) {}",
|
| + "}"));
|
| + resolve(source);
|
| + assertErrors(StaticWarningCode.FINAL_INITIALIZED_IN_DECLARATION_AND_CONSTRUCTOR);
|
| + verify(source);
|
| + }
|
| +
|
| public void test_finalNotInitialized_inConstructor() throws Exception {
|
| Source source = addSource(createSource(//
|
| "class A {",
|
|
|