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

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

Issue 895113002: Add static type checking of "yield" statements to analyzer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 2747 matching lines...) Expand 10 before | Expand all | Expand 10 after
2758 void test_loadLibraryDefined() { 2758 void test_loadLibraryDefined() {
2759 resolveWithErrors(<String>[r''' 2759 resolveWithErrors(<String>[r'''
2760 library lib1; 2760 library lib1;
2761 foo() => 22;''', r''' 2761 foo() => 22;''', r'''
2762 import 'lib1.dart' deferred as other; 2762 import 'lib1.dart' deferred as other;
2763 main() { 2763 main() {
2764 other.loadLibrary().then((_) => other.foo()); 2764 other.loadLibrary().then((_) => other.foo());
2765 }'''], <ErrorCode>[]); 2765 }'''], <ErrorCode>[]);
2766 } 2766 }
2767 2767
2768 void test_local_generator_async() {
2769 Source source = addSource('''
2770 f() {
2771 return () async* { yield 0; };
2772 }
2773 ''');
2774 resolve(source);
2775 assertNoErrors(source);
2776 verify([source]);
2777 }
2778
2779 void test_local_generator_sync() {
2780 Source source = addSource('''
2781 f() {
2782 return () sync* { yield 0; };
2783 }
2784 ''');
2785 resolve(source);
2786 assertNoErrors(source);
2787 verify([source]);
2788 }
2789
2768 void test_mapKeyTypeNotAssignable() { 2790 void test_mapKeyTypeNotAssignable() {
2769 Source source = addSource("var v = <String, int > {'a' : 1};"); 2791 Source source = addSource("var v = <String, int > {'a' : 1};");
2770 resolve(source); 2792 resolve(source);
2771 assertNoErrors(source); 2793 assertNoErrors(source);
2772 verify([source]); 2794 verify([source]);
2773 } 2795 }
2774 2796
2775 void test_memberWithClassName_setter() { 2797 void test_memberWithClassName_setter() {
2776 Source source = addSource(r''' 2798 Source source = addSource(r'''
2777 class A { 2799 class A {
(...skipping 2226 matching lines...) Expand 10 before | Expand all | Expand 10 after
5004 void test_wrongNumberOfParametersForSetter() { 5026 void test_wrongNumberOfParametersForSetter() {
5005 Source source = addSource(r''' 5027 Source source = addSource(r'''
5006 class A { 5028 class A {
5007 set x(a) {} 5029 set x(a) {}
5008 }'''); 5030 }''');
5009 resolve(source); 5031 resolve(source);
5010 assertNoErrors(source); 5032 assertNoErrors(source);
5011 verify([source]); 5033 verify([source]);
5012 } 5034 }
5013 5035
5036 void test_yield_async_to_dynamic_type() {
5037 Source source = addSource('''
5038 dynamic f() async* {
5039 yield 3;
5040 }
5041 ''');
5042 resolve(source);
5043 assertNoErrors(source);
5044 verify([source]);
5045 }
5046
5047 void test_yield_async_to_generic_type() {
5048 Source source = addSource('''
5049 import 'dart:async';
5050 Stream f() async* {
5051 yield 3;
5052 }
5053 ''');
5054 resolve(source);
5055 assertNoErrors(source);
5056 verify([source]);
5057 }
5058
5059 void test_yield_async_to_parameterized_type() {
5060 Source source = addSource('''
5061 import 'dart:async';
5062 Stream<int> f() async* {
5063 yield 3;
5064 }
5065 ''');
5066 resolve(source);
5067 assertNoErrors(source);
5068 verify([source]);
5069 }
5070
5071 void test_yield_async_to_untyped() {
5072 Source source = addSource('''
5073 f() async* {
5074 yield 3;
5075 }
5076 ''');
5077 resolve(source);
5078 assertNoErrors(source);
5079 verify([source]);
5080 }
5081
5082 void test_yield_sync_to_dynamic_type() {
5083 Source source = addSource('''
5084 dynamic f() sync* {
5085 yield 3;
5086 }
5087 ''');
5088 resolve(source);
5089 assertNoErrors(source);
5090 verify([source]);
5091 }
5092
5093 void test_yield_sync_to_generic_type() {
5094 Source source = addSource('''
5095 Iterable f() sync* {
5096 yield 3;
5097 }
5098 ''');
5099 resolve(source);
5100 assertNoErrors(source);
5101 verify([source]);
5102 }
5103
5104 void test_yield_sync_to_parameterized_type() {
5105 Source source = addSource('''
5106 Iterable<int> f() sync* {
5107 yield 3;
5108 }
5109 ''');
5110 resolve(source);
5111 assertNoErrors(source);
5112 verify([source]);
5113 }
5114
5115 void test_yield_sync_to_untyped() {
5116 Source source = addSource('''
5117 f() sync* {
5118 yield 3;
5119 }
5120 ''');
5121 resolve(source);
5122 assertNoErrors(source);
5123 verify([source]);
5124 }
5125
5014 void test_yieldEachInNonGenerator_asyncStar() { 5126 void test_yieldEachInNonGenerator_asyncStar() {
5015 Source source = addSource(r''' 5127 Source source = addSource(r'''
5016 f() async* { 5128 f() async* {
5017 yield* 0; 5129 yield* 0;
5018 }'''); 5130 }''');
5019 resolve(source); 5131 resolve(source);
5020 assertNoErrors(source); 5132 assertNoErrors(source);
5021 verify([source]); 5133 verify([source]);
5022 } 5134 }
5023 5135
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
5060 resolve(source); 5172 resolve(source);
5061 assertNoErrors(source); 5173 assertNoErrors(source);
5062 verify([source]); 5174 verify([source]);
5063 reset(); 5175 reset();
5064 } 5176 }
5065 5177
5066 void _check_wrongNumberOfParametersForOperator1(String name) { 5178 void _check_wrongNumberOfParametersForOperator1(String name) {
5067 _check_wrongNumberOfParametersForOperator(name, "a"); 5179 _check_wrongNumberOfParametersForOperator(name, "a");
5068 } 5180 }
5069 } 5181 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/testing/test_type_provider.dart ('k') | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698