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

Side by Side Diff: pkg/analyzer/test/generated/non_error_resolver_test.dart

Issue 898513002: Fix async/await type checking in analyzer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reformat and sort methods Created 5 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 engine.non_error_resolver_test; 5 library engine.non_error_resolver_test;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/error.dart'; 9 import 'package:analyzer/src/generated/error.dart';
10 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; 10 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode;
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 foo.x = true; 288 foo.x = true;
289 }'''); 289 }''');
290 addNamedSource("/lib1.dart", r''' 290 addNamedSource("/lib1.dart", r'''
291 library lib1; 291 library lib1;
292 bool x = false;'''); 292 bool x = false;''');
293 resolve(source); 293 resolve(source);
294 assertNoErrors(source); 294 assertNoErrors(source);
295 verify([source]); 295 verify([source]);
296 } 296 }
297 297
298 void test_async_dynamic_with_return() {
299 Source source = addSource('''
300 dynamic f() async {
301 return;
302 }
303 ''');
304 resolve(source);
305 assertNoErrors(source);
306 verify([source]);
307 }
308
309 void test_async_dynamic_with_return_value() {
310 Source source = addSource('''
311 dynamic f() async {
312 return 5;
313 }
314 ''');
315 resolve(source);
316 assertNoErrors(source);
317 verify([source]);
318 }
319
320 void test_async_dynamic_without_return() {
321 Source source = addSource('''
322 dynamic f() async {}
323 ''');
324 resolve(source);
325 assertNoErrors(source);
326 verify([source]);
327 }
328
329 void test_async_expression_function_type() {
330 Source source = addSource('''
331 import 'dart:async';
332 typedef Future<int> F(int i);
333 main() {
334 F f = (int i) async => i;
335 }
336 ''');
337 resolve(source);
338 assertNoErrors(source);
339 verify([source]);
340 }
341
342 void test_async_future_dynamic_with_return() {
343 Source source = addSource('''
344 import 'dart:async';
345 Future<dynamic> f() async {
346 return;
347 }
348 ''');
349 resolve(source);
350 assertNoErrors(source);
351 verify([source]);
352 }
353
354 void test_async_future_dynamic_with_return_value() {
355 Source source = addSource('''
356 import 'dart:async';
357 Future<dynamic> f() async {
358 return 5;
359 }
360 ''');
361 resolve(source);
362 assertNoErrors(source);
363 verify([source]);
364 }
365
366 void test_async_future_dynamic_without_return() {
367 Source source = addSource('''
368 import 'dart:async';
369 Future<dynamic> f() async {}
370 ''');
371 resolve(source);
372 assertNoErrors(source);
373 verify([source]);
374 }
375
376 void test_async_future_int_with_return_future_int() {
377 Source source = addSource('''
378 import 'dart:async';
379 Future<int> f() async {
380 return new Future<int>.value(5);
381 }
382 ''');
383 resolve(source);
384 assertNoErrors(source);
385 verify([source]);
386 }
387
388 void test_async_future_int_with_return_value() {
389 Source source = addSource('''
390 import 'dart:async';
391 Future<int> f() async {
392 return 5;
393 }
394 ''');
395 resolve(source);
396 assertNoErrors(source);
397 verify([source]);
398 }
399
400 void test_async_future_null_with_return() {
401 Source source = addSource('''
402 import 'dart:async';
403 Future<Null> f() async {
404 return;
405 }
406 ''');
407 resolve(source);
408 assertNoErrors(source);
409 verify([source]);
410 }
411
412 void test_async_future_null_without_return() {
413 Source source = addSource('''
414 import 'dart:async';
415 Future<Null> f() async {}
416 ''');
417 resolve(source);
418 assertNoErrors(source);
419 verify([source]);
420 }
421
422 void test_async_future_object_with_return() {
423 Source source = addSource('''
424 import 'dart:async';
425 Future<Object> f() async {
426 return;
427 }
428 ''');
429 resolve(source);
430 assertNoErrors(source);
431 verify([source]);
432 }
433
434 void test_async_future_object_with_return_value() {
435 Source source = addSource('''
436 import 'dart:async';
437 Future<Object> f() async {
438 return 5;
439 }
440 ''');
441 resolve(source);
442 assertNoErrors(source);
443 verify([source]);
444 }
445
446 void test_async_future_object_without_return() {
447 Source source = addSource('''
448 import 'dart:async';
449 Future<Object> f() async {}
450 ''');
451 resolve(source);
452 assertNoErrors(source);
453 verify([source]);
454 }
455
456 void test_async_future_with_return() {
457 Source source = addSource('''
458 import 'dart:async';
459 Future f() async {
460 return;
461 }
462 ''');
463 resolve(source);
464 assertNoErrors(source);
465 verify([source]);
466 }
467
468 void test_async_future_with_return_value() {
469 Source source = addSource('''
470 import 'dart:async';
471 Future f() async {
472 return 5;
473 }
474 ''');
475 resolve(source);
476 assertNoErrors(source);
477 verify([source]);
478 }
479
480 void test_async_future_without_return() {
481 Source source = addSource('''
482 import 'dart:async';
483 Future f() async {}
484 ''');
485 resolve(source);
486 assertNoErrors(source);
487 verify([source]);
488 }
489
490 void test_async_with_return() {
491 Source source = addSource('''
492 f() async {
493 return;
494 }
495 ''');
496 resolve(source);
497 assertNoErrors(source);
498 verify([source]);
499 }
500
501 void test_async_with_return_value() {
502 Source source = addSource('''
503 f() async {
504 return 5;
505 }
506 ''');
507 resolve(source);
508 assertNoErrors(source);
509 verify([source]);
510 }
511
512 void test_async_without_return() {
513 Source source = addSource('''
514 f() async {}
515 ''');
516 resolve(source);
517 assertNoErrors(source);
518 verify([source]);
519 }
520
298 void test_asyncForInWrongContext_async() { 521 void test_asyncForInWrongContext_async() {
299 Source source = addSource(r''' 522 Source source = addSource(r'''
300 f(list) async { 523 f(list) async {
301 await for (var e in list) { 524 await for (var e in list) {
302 } 525 }
303 }'''); 526 }''');
304 resolve(source); 527 resolve(source);
305 assertNoErrors(source); 528 assertNoErrors(source);
306 verify([source]); 529 verify([source]);
307 } 530 }
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 void test_constDeferredClass_new() { 998 void test_constDeferredClass_new() {
776 resolveWithErrors(<String>[r''' 999 resolveWithErrors(<String>[r'''
777 library lib1; 1000 library lib1;
778 class A { 1001 class A {
779 const A.b(); 1002 const A.b();
780 }''', r''' 1003 }''', r'''
781 library root; 1004 library root;
782 import 'lib1.dart' deferred as a; 1005 import 'lib1.dart' deferred as a;
783 main() { 1006 main() {
784 new a.A.b(); 1007 new a.A.b();
785 }'''], 1008 }'''], <ErrorCode>[]);
786 <ErrorCode>[]);
787 } 1009 }
788 1010
789 void test_constEval_functionTypeLiteral() { 1011 void test_constEval_functionTypeLiteral() {
790 Source source = addSource(r''' 1012 Source source = addSource(r'''
791 typedef F(); 1013 typedef F();
792 const C = F;'''); 1014 const C = F;''');
793 resolve(source); 1015 resolve(source);
794 assertNoErrors(source); 1016 assertNoErrors(source);
795 verify([source]); 1017 verify([source]);
796 } 1018 }
(...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after
2512 verify([source]); 2734 verify([source]);
2513 } 2735 }
2514 2736
2515 void test_loadLibraryDefined() { 2737 void test_loadLibraryDefined() {
2516 resolveWithErrors(<String>[r''' 2738 resolveWithErrors(<String>[r'''
2517 library lib1; 2739 library lib1;
2518 foo() => 22;''', r''' 2740 foo() => 22;''', r'''
2519 import 'lib1.dart' deferred as other; 2741 import 'lib1.dart' deferred as other;
2520 main() { 2742 main() {
2521 other.loadLibrary().then((_) => other.foo()); 2743 other.loadLibrary().then((_) => other.foo());
2522 }'''], 2744 }'''], <ErrorCode>[]);
2523 <ErrorCode>[]);
2524 } 2745 }
2525 2746
2526 void test_mapKeyTypeNotAssignable() { 2747 void test_mapKeyTypeNotAssignable() {
2527 Source source = addSource("var v = <String, int > {'a' : 1};"); 2748 Source source = addSource("var v = <String, int > {'a' : 1};");
2528 resolve(source); 2749 resolve(source);
2529 assertNoErrors(source); 2750 assertNoErrors(source);
2530 verify([source]); 2751 verify([source]);
2531 } 2752 }
2532 2753
2533 void test_memberWithClassName_setter() { 2754 void test_memberWithClassName_setter() {
(...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after
3970 library lib1; 4191 library lib1;
3971 f1() {}''', r''' 4192 f1() {}''', r'''
3972 library lib2; 4193 library lib2;
3973 f2() {}''', r''' 4194 f2() {}''', r'''
3974 library lib3; 4195 library lib3;
3975 f3() {}''', r''' 4196 f3() {}''', r'''
3976 library root; 4197 library root;
3977 import 'lib1.dart' deferred as lib1; 4198 import 'lib1.dart' deferred as lib1;
3978 import 'lib2.dart' as lib; 4199 import 'lib2.dart' as lib;
3979 import 'lib3.dart' as lib; 4200 import 'lib3.dart' as lib;
3980 main() { lib1.f1(); lib.f2(); lib.f3(); }'''], 4201 main() { lib1.f1(); lib.f2(); lib.f3(); }'''], <ErrorCode>[]);
3981 <ErrorCode>[]);
3982 } 4202 }
3983 4203
3984 void test_staticAccessToInstanceMember_annotation() { 4204 void test_staticAccessToInstanceMember_annotation() {
3985 Source source = addSource(r''' 4205 Source source = addSource(r'''
3986 class A { 4206 class A {
3987 const A.name(); 4207 const A.name();
3988 } 4208 }
3989 @A.name() 4209 @A.name()
3990 main() { 4210 main() {
3991 }'''); 4211 }''');
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
4796 resolve(source); 5016 resolve(source);
4797 assertNoErrors(source); 5017 assertNoErrors(source);
4798 verify([source]); 5018 verify([source]);
4799 reset(); 5019 reset();
4800 } 5020 }
4801 5021
4802 void _check_wrongNumberOfParametersForOperator1(String name) { 5022 void _check_wrongNumberOfParametersForOperator1(String name) {
4803 _check_wrongNumberOfParametersForOperator(name, "a"); 5023 _check_wrongNumberOfParametersForOperator(name, "a");
4804 } 5024 }
4805 } 5025 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698