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

Unified Diff: pkg/analyzer/test/generated/static_type_warning_code_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, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/test/generated/resolver_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/static_type_warning_code_test.dart
diff --git a/pkg/analyzer/test/generated/static_type_warning_code_test.dart b/pkg/analyzer/test/generated/static_type_warning_code_test.dart
index 12c028cf1bf17c7363412a5902887f13074c1a89..f7c50e5806cfcd73cb71125c0f7d69728be9b742 100644
--- a/pkg/analyzer/test/generated/static_type_warning_code_test.dart
+++ b/pkg/analyzer/test/generated/static_type_warning_code_test.dart
@@ -1653,4 +1653,72 @@ f(p) {
[StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
verify([source]);
}
+
+ void test_yield_async_to_basic_type() {
+ Source source = addSource('''
+int f() async* {
+ yield 3;
+}
+''');
+ resolve(source);
+ assertErrors(source, [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
+ verify([source]);
+ }
+
+ void test_yield_async_to_iterable() {
+ Source source = addSource('''
+Iterable<int> f() async* {
+ yield 3;
+}
+''');
+ resolve(source);
+ assertErrors(source, [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
+ verify([source]);
+ }
+
+ void test_yield_async_to_mistyped_stream() {
+ Source source = addSource('''
+import 'dart:async';
+Stream<int> f() async* {
+ yield "foo";
+}
+''');
+ resolve(source);
+ assertErrors(source, [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
+ verify([source]);
+ }
+
+ void test_yield_sync_to_basic_type() {
+ Source source = addSource('''
+int f() sync* {
+ yield 3;
+}
+''');
+ resolve(source);
+ assertErrors(source, [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
+ verify([source]);
+ }
+
+ void test_yield_sync_to_mistyped_iterable() {
+ Source source = addSource('''
+Iterable<int> f() sync* {
+ yield "foo";
+}
+''');
+ resolve(source);
+ assertErrors(source, [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
+ verify([source]);
+ }
+
+ void test_yield_sync_to_stream() {
+ Source source = addSource('''
+import 'dart:async';
+Stream<int> f() sync* {
+ yield 3;
+}
+''');
+ resolve(source);
+ assertErrors(source, [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
+ verify([source]);
+ }
}
« no previous file with comments | « pkg/analyzer/test/generated/resolver_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698