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

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

Issue 1495263003: Allow return of Future in async function (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Rename duplicate tests Created 5 years 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
« no previous file with comments | « pkg/analyzer/lib/src/task/strong/checker.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // TODO(jmesserly): this file needs to be refactored, it's a port from 5 // TODO(jmesserly): this file needs to be refactored, it's a port from
6 // package:dev_compiler's tests 6 // package:dev_compiler's tests
7 /// General type checking tests 7 /// General type checking tests
8 library test.src.task.strong.checker_test; 8 library test.src.task.strong.checker_test;
9 9
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 2346 matching lines...) Expand 10 before | Expand all | Expand 10 after
2357 testChecker('async', { 2357 testChecker('async', {
2358 '/main.dart': ''' 2358 '/main.dart': '''
2359 import 'dart:async'; 2359 import 'dart:async';
2360 import 'dart:math' show Random; 2360 import 'dart:math' show Random;
2361 2361
2362 dynamic x; 2362 dynamic x;
2363 2363
2364 foo1() async => x; 2364 foo1() async => x;
2365 Future foo2() async => x; 2365 Future foo2() async => x;
2366 Future<int> foo3() async => (/*info:DynamicCast*/x); 2366 Future<int> foo3() async => (/*info:DynamicCast*/x);
2367 Future<int> foo4() async => (/*severe:StaticTypeError*/new Future<int>.v alue(/*info:DynamicCast*/x)); 2367 Future<int> foo4() async => (new Future<int>.value(/*info:DynamicCast*/x ));
2368 Future<int> foo5() async => (/*severe:StaticTypeError*/new Future<String >.value(/*info:DynamicCast*/x));
2368 2369
2369 bar1() async { return x; } 2370 bar1() async { return x; }
2370 Future bar2() async { return x; } 2371 Future bar2() async { return x; }
2371 Future<int> bar3() async { return (/*info:DynamicCast*/x); } 2372 Future<int> bar3() async { return (/*info:DynamicCast*/x); }
2372 Future<int> bar4() async { return (/*severe:StaticTypeError*/new Future< int>.value(/*info:DynamicCast*/x)); } 2373 Future<int> bar4() async { return (new Future<int>.value(/*info:DynamicC ast*/x)); }
2374 Future<int> bar5() async { return (/*severe:StaticTypeError*/new Future< String>.value(/*info:DynamicCast*/x)); }
2373 2375
2374 int y; 2376 int y;
2375 Future<int> z; 2377 Future<int> z;
2376 2378
2377 void baz() async { 2379 void baz() async {
2378 int a = /*info:DynamicCast*/await x; 2380 int a = /*info:DynamicCast*/await x;
2379 int b = await y; 2381 int b = await y;
2380 int c = await z; 2382 int c = await z;
2381 String d = /*severe:StaticTypeError*/await z; 2383 String d = /*severe:StaticTypeError*/await z;
2382 } 2384 }
2383 2385
2384 Future<bool> get issue_264 async { 2386 Future<bool> get issue_264 async {
2385 await 42; 2387 await 42;
2386 if (new Random().nextBool()) { 2388 if (new Random().nextBool()) {
2387 return true; 2389 return true;
2388 } else { 2390 } else {
2389 return /*severe:StaticTypeError*/new Future<bool>.value(false); 2391 return new Future<bool>.value(false);
2390 } 2392 }
2391 } 2393 }
2392 ''' 2394 '''
2393 }); 2395 });
2394 2396
2395 testChecker('async*', { 2397 testChecker('async*', {
2396 '/main.dart': ''' 2398 '/main.dart': '''
2397 import 'dart:async'; 2399 import 'dart:async';
2398 2400
2399 dynamic x; 2401 dynamic x;
(...skipping 24 matching lines...) Expand all
2424 2426
2425 baz1() sync* { yield* (/*info:DynamicCast*/x); } 2427 baz1() sync* { yield* (/*info:DynamicCast*/x); }
2426 Iterable baz2() sync* { yield* (/*info:DynamicCast*/x); } 2428 Iterable baz2() sync* { yield* (/*info:DynamicCast*/x); }
2427 Iterable<int> baz3() sync* { yield* (/*warning:DownCastComposite*/x); } 2429 Iterable<int> baz3() sync* { yield* (/*warning:DownCastComposite*/x); }
2428 Iterable<int> baz4() sync* { yield* new Iterable<int>(); } 2430 Iterable<int> baz4() sync* { yield* new Iterable<int>(); }
2429 Iterable<int> baz5() sync* { yield* (/*info:InferredTypeAllocation*/new Iterable()); } 2431 Iterable<int> baz5() sync* { yield* (/*info:InferredTypeAllocation*/new Iterable()); }
2430 ''' 2432 '''
2431 }); 2433 });
2432 }); 2434 });
2433 } 2435 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/strong/checker.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698