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

Unified Diff: pkg/analyzer/test/generated/static_type_warning_code_test.dart

Issue 897673003: Implement new return type checking rules in analyzer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reformat and sort class members. 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/lib/src/generated/testing/test_type_provider.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 b2c1016215d8b8c6fb35899d7a2f93f8d57f4d7b..6b5f0a75996aacd8f9059d17ab1d3dcad703daf1 100644
--- a/pkg/analyzer/test/generated/static_type_warning_code_test.dart
+++ b/pkg/analyzer/test/generated/static_type_warning_code_test.dart
@@ -90,6 +90,78 @@ main() {
verify([source]);
}
+ void test_illegal_return_type_async_function() {
+ Source source = addSource('''
+int f() async {}
+''');
+ resolve(source);
+ assertErrors(
+ source,
+ [StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE, HintCode.MISSING_RETURN]);
+ verify([source]);
+ }
+
+ void test_illegal_return_type_async_generator_function() {
+ Source source = addSource('''
+int f() async* {}
+''');
+ resolve(source);
+ assertErrors(
+ source,
+ [StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE]);
+ verify([source]);
+ }
+
+ void test_illegal_return_type_async_generator_method() {
+ Source source = addSource('''
+class C {
+ int f() async* {}
+}
+''');
+ resolve(source);
+ assertErrors(
+ source,
+ [StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE]);
+ verify([source]);
+ }
+
+ void test_illegal_return_type_async_method() {
+ Source source = addSource('''
+class C {
+ int f() async {}
+}
+''');
+ resolve(source);
+ assertErrors(
+ source,
+ [StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE, HintCode.MISSING_RETURN]);
+ verify([source]);
+ }
+
+ void test_illegal_return_type_sync_generator_function() {
+ Source source = addSource('''
+int f() sync* {}
+''');
+ resolve(source);
+ assertErrors(
+ source,
+ [StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE]);
+ verify([source]);
+ }
+
+ void test_illegal_return_type_sync_generator_method() {
+ Source source = addSource('''
+class C {
+ int f() sync* {}
+}
+''');
+ resolve(source);
+ assertErrors(
+ source,
+ [StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE]);
+ verify([source]);
+ }
+
void test_inconsistentMethodInheritance_paramCount() {
Source source = addSource(r'''
abstract class A {
@@ -598,7 +670,11 @@ int f() async {
}
''');
resolve(source);
- assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
+ assertErrors(
+ source,
+ [
+ StaticTypeWarningCode.RETURN_OF_INVALID_TYPE,
+ StaticTypeWarningCode.ILLEGAL_ASYNC_RETURN_TYPE]);
verify([source]);
}
@@ -1661,7 +1737,11 @@ int f() async* {
}
''');
resolve(source);
- assertErrors(source, [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
+ assertErrors(
+ source,
+ [
+ StaticTypeWarningCode.YIELD_OF_INVALID_TYPE,
+ StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE]);
verify([source]);
}
@@ -1672,7 +1752,11 @@ Iterable<int> f() async* {
}
''');
resolve(source);
- assertErrors(source, [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
+ assertErrors(
+ source,
+ [
+ StaticTypeWarningCode.YIELD_OF_INVALID_TYPE,
+ StaticTypeWarningCode.ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE]);
verify([source]);
}
@@ -1703,7 +1787,7 @@ Stream<String> g() => null;
void test_yield_each_sync_to_mistyped_iterable() {
Source source = addSource('''
-Iterable<int> f() async* {
+Iterable<int> f() sync* {
yield* g();
}
Iterable<String> g() => null;
@@ -1720,7 +1804,11 @@ int f() sync* {
}
''');
resolve(source);
- assertErrors(source, [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
+ assertErrors(
+ source,
+ [
+ StaticTypeWarningCode.YIELD_OF_INVALID_TYPE,
+ StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE]);
verify([source]);
}
@@ -1743,7 +1831,11 @@ Stream<int> f() sync* {
}
''');
resolve(source);
- assertErrors(source, [StaticTypeWarningCode.YIELD_OF_INVALID_TYPE]);
+ assertErrors(
+ source,
+ [
+ StaticTypeWarningCode.YIELD_OF_INVALID_TYPE,
+ StaticTypeWarningCode.ILLEGAL_SYNC_GENERATOR_RETURN_TYPE]);
verify([source]);
}
}
« no previous file with comments | « pkg/analyzer/lib/src/generated/testing/test_type_provider.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698