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 2029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2040 Source source = addSource(r''' | 2040 Source source = addSource(r''' |
2041 m(x) { | 2041 m(x) { |
2042 while (x?.a) {} | 2042 while (x?.a) {} |
2043 } | 2043 } |
2044 '''); | 2044 '''); |
2045 computeLibrarySourceErrors(source); | 2045 computeLibrarySourceErrors(source); |
2046 assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]); | 2046 assertErrors(source, [HintCode.NULL_AWARE_IN_CONDITION]); |
2047 verify([source]); | 2047 verify([source]); |
2048 } | 2048 } |
2049 | 2049 |
2050 void test_overrideOnNonOverridingGetter_field_invalid() { | 2050 void test_overrideOnNonOverridingField_invalid() { |
2051 Source source = addSource(r''' | 2051 Source source = addSource(r''' |
2052 library dart.core; | 2052 library dart.core; |
2053 const override = null; | 2053 const override = null; |
2054 class A { | 2054 class A { |
2055 } | 2055 } |
2056 class B extends A { | 2056 class B extends A { |
2057 @override | 2057 @override |
2058 final int m = 1; | 2058 final int m = 1; |
2059 }'''); | 2059 }'''); |
2060 computeLibrarySourceErrors(source); | 2060 computeLibrarySourceErrors(source); |
2061 assertErrors(source, [HintCode.OVERRIDE_ON_NON_OVERRIDING_GETTER]); | 2061 assertErrors(source, [HintCode.OVERRIDE_ON_NON_OVERRIDING_FIELD]); |
2062 verify([source]); | 2062 verify([source]); |
2063 } | 2063 } |
2064 | 2064 |
2065 void test_overrideOnNonOverridingGetter_invalid() { | 2065 void test_overrideOnNonOverridingGetter_invalid() { |
2066 Source source = addSource(r''' | 2066 Source source = addSource(r''' |
2067 library dart.core; | 2067 library dart.core; |
2068 const override = null; | 2068 const override = null; |
2069 class A { | 2069 class A { |
2070 } | 2070 } |
2071 class B extends A { | 2071 class B extends A { |
(...skipping 1822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3894 n() { | 3894 n() { |
3895 var a = m(), b = m(); | 3895 var a = m(), b = m(); |
3896 } | 3896 } |
3897 }'''); | 3897 }'''); |
3898 computeLibrarySourceErrors(source); | 3898 computeLibrarySourceErrors(source); |
3899 assertErrors( | 3899 assertErrors( |
3900 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); | 3900 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); |
3901 verify([source]); | 3901 verify([source]); |
3902 } | 3902 } |
3903 } | 3903 } |
OLD | NEW |