OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.src.task.strong.checker_test; | 5 library analyzer.test.src.task.strong.checker_test; |
6 | 6 |
7 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 7 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
8 | 8 |
9 import 'strong_test_helper.dart'; | 9 import 'strong_test_helper.dart'; |
10 | 10 |
(...skipping 2187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2198 '''); | 2198 '''); |
2199 } | 2199 } |
2200 | 2200 |
2201 test_implicitCasts() async { | 2201 test_implicitCasts() async { |
2202 addFile('num n; int i = /*info:ASSIGNMENT_CAST*/n;'); | 2202 addFile('num n; int i = /*info:ASSIGNMENT_CAST*/n;'); |
2203 await check(); | 2203 await check(); |
2204 addFile('num n; int i = /*error:INVALID_ASSIGNMENT*/n;'); | 2204 addFile('num n; int i = /*error:INVALID_ASSIGNMENT*/n;'); |
2205 await check(implicitCasts: false); | 2205 await check(implicitCasts: false); |
2206 } | 2206 } |
2207 | 2207 |
2208 test_implicitCasts_return() async { | |
2209 addFile(r''' | |
2210 import 'dart:async'; | |
2211 | |
2212 Future<List<String>> foo() async { | |
2213 List<Object> x = <Object>["hello", "world"]; | |
2214 return /*info:DOWN_CAST_IMPLICIT*/x; | |
2215 } | |
2216 '''); | |
2217 await check(); | |
2218 } | |
2219 | |
2220 test_implicitCasts_genericMethods() async { | 2208 test_implicitCasts_genericMethods() async { |
2221 addFile(''' | 2209 addFile(''' |
2222 var x = <String>[].map<String>((x) => ""); | 2210 var x = <String>[].map<String>((x) => ""); |
2223 '''); | 2211 '''); |
2224 await check(implicitCasts: false); | 2212 await check(implicitCasts: false); |
2225 } | 2213 } |
2226 | 2214 |
2227 test_implicitCasts_numericOps() async { | 2215 test_implicitCasts_numericOps() async { |
2228 // Regression test for https://github.com/dart-lang/sdk/issues/26912 | 2216 // Regression test for https://github.com/dart-lang/sdk/issues/26912 |
2229 addFile(r''' | 2217 addFile(r''' |
2230 void f() { | 2218 void f() { |
2231 int x = 0; | 2219 int x = 0; |
2232 int y = 0; | 2220 int y = 0; |
2233 x += y; | 2221 x += y; |
2234 } | 2222 } |
2235 '''); | 2223 '''); |
2236 await check(implicitCasts: false); | 2224 await check(implicitCasts: false); |
2237 } | 2225 } |
2238 | 2226 |
| 2227 test_implicitCasts_return() async { |
| 2228 addFile(r''' |
| 2229 import 'dart:async'; |
| 2230 |
| 2231 Future<List<String>> foo() async { |
| 2232 List<Object> x = <Object>["hello", "world"]; |
| 2233 return /*info:DOWN_CAST_IMPLICIT*/x; |
| 2234 } |
| 2235 '''); |
| 2236 await check(); |
| 2237 } |
| 2238 |
2239 test_implicitDynamic_field() async { | 2239 test_implicitDynamic_field() async { |
2240 addFile(r''' | 2240 addFile(r''' |
2241 class C { | 2241 class C { |
2242 var /*error:IMPLICIT_DYNAMIC_FIELD*/x0; | 2242 var /*error:IMPLICIT_DYNAMIC_FIELD*/x0; |
2243 var /*error:IMPLICIT_DYNAMIC_FIELD*/x1 = (<dynamic>[])[0]; | 2243 var /*error:IMPLICIT_DYNAMIC_FIELD*/x1 = (<dynamic>[])[0]; |
2244 var /*error:IMPLICIT_DYNAMIC_FIELD*/x2, | 2244 var /*error:IMPLICIT_DYNAMIC_FIELD*/x2, |
2245 x3 = 42, | 2245 x3 = 42, |
2246 /*error:IMPLICIT_DYNAMIC_FIELD*/x4; | 2246 /*error:IMPLICIT_DYNAMIC_FIELD*/x4; |
2247 dynamic y0; | 2247 dynamic y0; |
2248 dynamic y1 = (<dynamic>[])[0]; | 2248 dynamic y1 = (<dynamic>[])[0]; |
(...skipping 1958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4207 class CheckerTest_Driver extends CheckerTest { | 4207 class CheckerTest_Driver extends CheckerTest { |
4208 @override | 4208 @override |
4209 bool get enableNewAnalysisDriver => true; | 4209 bool get enableNewAnalysisDriver => true; |
4210 | 4210 |
4211 @failingTest | 4211 @failingTest |
4212 @override | 4212 @override |
4213 test_covariantOverride_fields() async { | 4213 test_covariantOverride_fields() async { |
4214 await super.test_covariantOverride_fields(); | 4214 await super.test_covariantOverride_fields(); |
4215 } | 4215 } |
4216 } | 4216 } |
OLD | NEW |