OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer.test.generated.hint_code_test; | 5 library analyzer.test.generated.hint_code_test; |
6 | 6 |
7 import 'package:analyzer/src/generated/engine.dart'; | 7 import 'package:analyzer/src/generated/engine.dart'; |
8 import 'package:analyzer/src/generated/error.dart'; | 8 import 'package:analyzer/src/generated/error.dart'; |
9 import 'package:analyzer/src/generated/source_io.dart'; | 9 import 'package:analyzer/src/generated/source_io.dart'; |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
(...skipping 2868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2879 int _f; | 2879 int _f; |
2880 main() { | 2880 main() { |
2881 _f += 2; | 2881 _f += 2; |
2882 } | 2882 } |
2883 }'''); | 2883 }'''); |
2884 computeLibrarySourceErrors(source); | 2884 computeLibrarySourceErrors(source); |
2885 assertErrors(source, [HintCode.UNUSED_FIELD]); | 2885 assertErrors(source, [HintCode.UNUSED_FIELD]); |
2886 verify([source]); | 2886 verify([source]); |
2887 } | 2887 } |
2888 | 2888 |
| 2889 void test_unusedField_notUsed_constructorFieldInitializers() { |
| 2890 enableUnusedElement = true; |
| 2891 Source source = addSource(r''' |
| 2892 class A { |
| 2893 int _f; |
| 2894 A() : _f = 0; |
| 2895 }'''); |
| 2896 computeLibrarySourceErrors(source); |
| 2897 assertErrors(source, [HintCode.UNUSED_FIELD]); |
| 2898 verify([source]); |
| 2899 } |
| 2900 |
| 2901 void test_unusedField_notUsed_fieldFormalParameter() { |
| 2902 enableUnusedElement = true; |
| 2903 Source source = addSource(r''' |
| 2904 class A { |
| 2905 int _f; |
| 2906 A(this._f); |
| 2907 }'''); |
| 2908 computeLibrarySourceErrors(source); |
| 2909 assertErrors(source, [HintCode.UNUSED_FIELD]); |
| 2910 verify([source]); |
| 2911 } |
| 2912 |
2889 void test_unusedField_notUsed_noReference() { | 2913 void test_unusedField_notUsed_noReference() { |
2890 enableUnusedElement = true; | 2914 enableUnusedElement = true; |
2891 Source source = addSource(r''' | 2915 Source source = addSource(r''' |
2892 class A { | 2916 class A { |
2893 int _f; | 2917 int _f; |
2894 } | 2918 } |
2895 '''); | 2919 '''); |
2896 computeLibrarySourceErrors(source); | 2920 computeLibrarySourceErrors(source); |
2897 assertErrors(source, [HintCode.UNUSED_FIELD]); | 2921 assertErrors(source, [HintCode.UNUSED_FIELD]); |
2898 verify([source]); | 2922 verify([source]); |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3355 n() { | 3379 n() { |
3356 var a = m(), b = m(); | 3380 var a = m(), b = m(); |
3357 } | 3381 } |
3358 }'''); | 3382 }'''); |
3359 computeLibrarySourceErrors(source); | 3383 computeLibrarySourceErrors(source); |
3360 assertErrors( | 3384 assertErrors( |
3361 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); | 3385 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); |
3362 verify([source]); | 3386 verify([source]); |
3363 } | 3387 } |
3364 } | 3388 } |
OLD | NEW |