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

Side by Side Diff: pkg/analyzer/test/src/task/strong/checker_test.dart

Issue 2782533002: Report errors for the new top-level inference rules. (Closed)
Patch Set: Update language_strong status for analyzer. Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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
2198 addFile('num n; int i = /*info:ASSIGNMENT_CAST*/n;'); 2198 addFile('num n; int i = /*info:ASSIGNMENT_CAST*/n;');
2199 await check(); 2199 await check();
2200 // TODO(jmesserly): should not be emitting the hint as well as the error. 2200 // TODO(jmesserly): should not be emitting the hint as well as the error.
2201 // It is a "strong mode hint" however, so it will not be user visible. 2201 // It is a "strong mode hint" however, so it will not be user visible.
2202 addFile( 2202 addFile(
2203 'num n; int i = /*info:ASSIGNMENT_CAST,error:INVALID_ASSIGNMENT*/n;'); 2203 'num n; int i = /*info:ASSIGNMENT_CAST,error:INVALID_ASSIGNMENT*/n;');
2204 await check(implicitCasts: false); 2204 await check(implicitCasts: false);
2205 } 2205 }
2206 2206
2207 test_implicitCasts_genericMethods() async { 2207 test_implicitCasts_genericMethods() async {
2208 addFile('var x = <String>[].map((x) => "");'); 2208 addFile('''
2209 var x = <String>[].map<String>((x) => "");
2210 ''');
2209 await check(implicitCasts: false); 2211 await check(implicitCasts: false);
2210 } 2212 }
2211 2213
2212 test_implicitCasts_numericOps() async { 2214 test_implicitCasts_numericOps() async {
2213 // Regression test for https://github.com/dart-lang/sdk/issues/26912 2215 // Regression test for https://github.com/dart-lang/sdk/issues/26912
2214 addFile(r''' 2216 addFile(r'''
2215 void f() { 2217 void f() {
2216 int x = 0; 2218 int x = 0;
2217 int y = 0; 2219 int y = 0;
2218 x += y; 2220 x += y;
2219 } 2221 }
2220 '''); 2222 ''');
2221 await check(implicitCasts: false); 2223 await check(implicitCasts: false);
2222 } 2224 }
2223 2225
2224 test_implicitDynamic_field() async { 2226 test_implicitDynamic_field() async {
2225 addFile(r''' 2227 addFile(r'''
2226 class C { 2228 class C {
2227 var /*error:IMPLICIT_DYNAMIC_FIELD*/x0; 2229 var /*error:IMPLICIT_DYNAMIC_FIELD*/x0;
2228 var /*error:IMPLICIT_DYNAMIC_FIELD*/x1 = (<dynamic>[])[0]; 2230 var /*error:IMPLICIT_DYNAMIC_FIELD*/x1 =
2231 /*error:TOP_LEVEL_UNSUPPORTED*/(<dynamic>[])[0];
2229 var /*error:IMPLICIT_DYNAMIC_FIELD*/x2, 2232 var /*error:IMPLICIT_DYNAMIC_FIELD*/x2,
2230 x3 = 42, 2233 x3 = 42,
2231 /*error:IMPLICIT_DYNAMIC_FIELD*/x4; 2234 /*error:IMPLICIT_DYNAMIC_FIELD*/x4;
2232 dynamic y0; 2235 dynamic y0;
2233 dynamic y1 = (<dynamic>[])[0]; 2236 dynamic y1 = (<dynamic>[])[0];
2234 } 2237 }
2235 '''); 2238 ''');
2236 await check(implicitDynamic: false); 2239 await check(implicitDynamic: false);
2237 } 2240 }
2238 2241
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
2445 B y = /*info:INFERRED_TYPE_ALLOCATION*/new B(); 2448 B y = /*info:INFERRED_TYPE_ALLOCATION*/new B();
2446 return /*info:INFERRED_TYPE_ALLOCATION*/new A(); 2449 return /*info:INFERRED_TYPE_ALLOCATION*/new A();
2447 } 2450 }
2448 '''); 2451 ''');
2449 await check(implicitDynamic: false); 2452 await check(implicitDynamic: false);
2450 } 2453 }
2451 2454
2452 test_implicitDynamic_variable() async { 2455 test_implicitDynamic_variable() async {
2453 addFile(r''' 2456 addFile(r'''
2454 var /*error:IMPLICIT_DYNAMIC_VARIABLE*/x0; 2457 var /*error:IMPLICIT_DYNAMIC_VARIABLE*/x0;
2455 var /*error:IMPLICIT_DYNAMIC_VARIABLE*/x1 = (<dynamic>[])[0]; 2458 var /*error:IMPLICIT_DYNAMIC_VARIABLE*/x1 =
2459 /*error:TOP_LEVEL_UNSUPPORTED*/(<dynamic>[])[0];
2456 var /*error:IMPLICIT_DYNAMIC_VARIABLE*/x2, 2460 var /*error:IMPLICIT_DYNAMIC_VARIABLE*/x2,
2457 x3 = 42, 2461 x3 = 42,
2458 /*error:IMPLICIT_DYNAMIC_VARIABLE*/x4; 2462 /*error:IMPLICIT_DYNAMIC_VARIABLE*/x4;
2459 dynamic y0; 2463 dynamic y0;
2460 dynamic y1 = (<dynamic>[])[0]; 2464 dynamic y1 = (<dynamic>[])[0];
2461 '''); 2465 ''');
2462 await check(implicitDynamic: false); 2466 await check(implicitDynamic: false);
2463 } 2467 }
2464 2468
2465 test_invalidOverrides_baseClassOverrideToChildInterface() async { 2469 test_invalidOverrides_baseClassOverrideToChildInterface() async {
(...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after
4138 class CheckerTest_Driver extends CheckerTest { 4142 class CheckerTest_Driver extends CheckerTest {
4139 @override 4143 @override
4140 bool get enableNewAnalysisDriver => true; 4144 bool get enableNewAnalysisDriver => true;
4141 4145
4142 @failingTest 4146 @failingTest
4143 @override 4147 @override
4144 test_covariantOverride_fields() async { 4148 test_covariantOverride_fields() async {
4145 await super.test_covariantOverride_fields(); 4149 await super.test_covariantOverride_fields();
4146 } 4150 }
4147 } 4151 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/task/dart_test.dart ('k') | pkg/analyzer/test/src/task/strong/inferred_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698