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

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

Issue 1843473002: Sort analyzer sources (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Remove generated file and fix misplaced comments Created 4 years, 9 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
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 02993c54c813e26e65e2c5c4c92d88c4f4660fff..88e243fcf835684a5f248420a39e023c57a50833 100644
--- a/pkg/analyzer/test/generated/static_type_warning_code_test.dart
+++ b/pkg/analyzer/test/generated/static_type_warning_code_test.dart
@@ -181,6 +181,111 @@ f() async {
[StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
+ void test_awaitForIn_declaredVariableRightType() {
+ assertNoErrorsInCode('''
+import 'dart:async';
+f() async {
+ Stream<int> stream;
+ await for (int i in stream) {}
+}
+''');
+ }
+
+ void test_awaitForIn_declaredVariableWrongType() {
+ assertErrorsInCode(
+ '''
+import 'dart:async';
+f() async {
+ Stream<String> stream;
+ await for (int i in stream) {}
+}
+''',
+ [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
+ }
+
+ void test_awaitForIn_downcast() {
+ assertNoErrorsInCode('''
+import 'dart:async';
+f() async {
+ Stream<num> stream;
+ await for (int i in stream) {}
+}
+''');
+ }
+
+ void test_awaitForIn_dynamicStream() {
+ assertNoErrorsInCode('''
+f() async {
+ dynamic stream;
+ await for (int i in stream) {}
+}
+''');
+ }
+
+ void test_awaitForIn_dynamicVariable() {
+ assertNoErrorsInCode('''
+import 'dart:async';
+f() async {
+ Stream<int> stream;
+ await for (var i in stream) {}
+}
+''');
+ }
+
+ void test_awaitForIn_existingVariableRightType() {
+ assertNoErrorsInCode('''
+import 'dart:async';
+f() async {
+ Stream<int> stream;
+ int i;
+ await for (i in stream) {}
+}
+''');
+ }
+
+ void test_awaitForIn_existingVariableWrongType() {
+ assertErrorsInCode(
+ '''
+import 'dart:async';
+f() async {
+ Stream<String> stream;
+ int i;
+ await for (i in stream) {}
+}
+''',
+ [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
+ }
+
+ void test_awaitForIn_notStream() {
+ assertErrorsInCode(
+ '''
+f() async {
+ await for (var i in true) {}
+}
+''',
+ [StaticTypeWarningCode.FOR_IN_OF_INVALID_TYPE]);
+ }
+
+ void test_awaitForIn_streamOfDynamic() {
+ assertNoErrorsInCode('''
+import 'dart:async';
+f() async {
+ Stream stream;
+ await for (int i in stream) {}
+}
+''');
+ }
+
+ void test_awaitForIn_upcast() {
+ assertNoErrorsInCode('''
+import 'dart:async';
+f() async {
+ Stream<int> stream;
+ await for (num i in stream) {}
+}
+''');
+ }
+
void test_bug21912() {
assertErrorsInCode(
'''
@@ -236,6 +341,137 @@ main() {
[StaticTypeWarningCode.EXPECTED_TWO_MAP_TYPE_ARGUMENTS]);
}
+ void test_forIn_declaredVariableRightType() {
+ assertNoErrorsInCode('''
+f() {
+ for (int i in <int>[]) {}
+}
+''');
+ }
+
+ void test_forIn_declaredVariableWrongType() {
+ assertErrorsInCode(
+ '''
+f() {
+ for (int i in <String>[]) {}
+}
+''',
+ [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
+ }
+
+ void test_forIn_downcast() {
+ assertNoErrorsInCode('''
+f() {
+ for (int i in <num>[]) {}
+}
+''');
+ }
+
+ void test_forIn_dynamic() {
+ assertNoErrorsInCode(
+ '''
+f() {
+ dynamic d; // Could be [].
+ for (var i in d) {}
+}
+''');
+ }
+
+ void test_forIn_dynamicIterable() {
+ assertNoErrorsInCode('''
+f() {
+ dynamic iterable;
+ for (int i in iterable) {}
+}
+''');
+ }
+
+ void test_forIn_dynamicVariable() {
+ assertNoErrorsInCode('''
+f() {
+ for (var i in <int>[]) {}
+}
+''');
+ }
+
+ void test_forIn_existingVariableRightType() {
+ assertNoErrorsInCode('''
+f() {
+ int i;
+ for (i in <int>[]) {}
+}
+''');
+ }
+
+ void test_forIn_existingVariableWrongType() {
+ assertErrorsInCode(
+ '''
+f() {
+ int i;
+ for (i in <String>[]) {}
+}
+''',
+ [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
+ }
+
+ void test_forIn_iterableOfDynamic() {
+ assertNoErrorsInCode('''
+f() {
+ for (int i in []) {}
+}
+''');
+ }
+
+ void test_forIn_notIterable() {
+ assertErrorsInCode(
+ '''
+f() {
+ for (var i in true) {}
+}
+''',
+ [StaticTypeWarningCode.FOR_IN_OF_INVALID_TYPE]);
+ }
+
+ void test_forIn_object() {
+ assertNoErrorsInCode(
+ '''
+f() {
+ Object o; // Could be [].
+ for (var i in o) {}
+}
+''');
+ }
+
+ void test_forIn_typeBoundBad() {
+ assertErrorsInCode(
+ '''
+class Foo<T extends Iterable<int>> {
+ void method(T iterable) {
+ for (String i in iterable) {}
+ }
+}
+''',
+ [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
+ }
+
+ void test_forIn_typeBoundGood() {
+ assertNoErrorsInCode('''
+class Foo<T extends Iterable<int>> {
+ void method(T iterable) {
+ for (var i in iterable) {}
+ }
+}
+''');
+ }
+
+ void test_forIn_upcast() {
+ assertNoErrorsInCode('''
+f() {
+ for (num i in <int>[]) {}
+}
+''');
+ }
+
void test_illegal_return_type_async_function() {
assertErrorsInCode(
'''
@@ -646,6 +882,7 @@ f() {
[StaticTypeWarningCode.NON_BOOL_CONDITION]);
}
+ // https://github.com/dart-lang/sdk/issues/24713
void test_nonBoolCondition_for() {
assertErrorsInCode(
r'''
@@ -856,7 +1093,6 @@ class A {
[StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
}
- // https://github.com/dart-lang/sdk/issues/24713
void test_returnOfInvalidType_not_issued_for_valid_generic_return() {
assertNoErrorsInCode(r'''
abstract class F<T, U> {
@@ -1907,242 +2143,6 @@ f(p) {
[StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS]);
}
- void test_forIn_notIterable() {
- assertErrorsInCode(
- '''
-f() {
- for (var i in true) {}
-}
-''',
- [StaticTypeWarningCode.FOR_IN_OF_INVALID_TYPE]);
- }
-
- void test_forIn_object() {
- assertNoErrorsInCode(
- '''
-f() {
- Object o; // Could be [].
- for (var i in o) {}
-}
-''');
- }
-
- void test_forIn_dynamic() {
- assertNoErrorsInCode(
- '''
-f() {
- dynamic d; // Could be [].
- for (var i in d) {}
-}
-''');
- }
-
- void test_forIn_declaredVariableWrongType() {
- assertErrorsInCode(
- '''
-f() {
- for (int i in <String>[]) {}
-}
-''',
- [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
- }
-
- void test_forIn_existingVariableWrongType() {
- assertErrorsInCode(
- '''
-f() {
- int i;
- for (i in <String>[]) {}
-}
-''',
- [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
- }
-
- void test_forIn_declaredVariableRightType() {
- assertNoErrorsInCode('''
-f() {
- for (int i in <int>[]) {}
-}
-''');
- }
-
- void test_forIn_existingVariableRightType() {
- assertNoErrorsInCode('''
-f() {
- int i;
- for (i in <int>[]) {}
-}
-''');
- }
-
- void test_forIn_dynamicVariable() {
- assertNoErrorsInCode('''
-f() {
- for (var i in <int>[]) {}
-}
-''');
- }
-
- void test_forIn_iterableOfDynamic() {
- assertNoErrorsInCode('''
-f() {
- for (int i in []) {}
-}
-''');
- }
-
- void test_forIn_dynamicIterable() {
- assertNoErrorsInCode('''
-f() {
- dynamic iterable;
- for (int i in iterable) {}
-}
-''');
- }
-
- void test_forIn_upcast() {
- assertNoErrorsInCode('''
-f() {
- for (num i in <int>[]) {}
-}
-''');
- }
-
- void test_forIn_downcast() {
- assertNoErrorsInCode('''
-f() {
- for (int i in <num>[]) {}
-}
-''');
- }
-
- void test_forIn_typeBoundBad() {
- assertErrorsInCode(
- '''
-class Foo<T extends Iterable<int>> {
- void method(T iterable) {
- for (String i in iterable) {}
- }
-}
-''',
- [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
- }
-
- void test_forIn_typeBoundGood() {
- assertNoErrorsInCode('''
-class Foo<T extends Iterable<int>> {
- void method(T iterable) {
- for (var i in iterable) {}
- }
-}
-''');
- }
-
- void test_awaitForIn_notStream() {
- assertErrorsInCode(
- '''
-f() async {
- await for (var i in true) {}
-}
-''',
- [StaticTypeWarningCode.FOR_IN_OF_INVALID_TYPE]);
- }
-
- void test_awaitForIn_declaredVariableWrongType() {
- assertErrorsInCode(
- '''
-import 'dart:async';
-f() async {
- Stream<String> stream;
- await for (int i in stream) {}
-}
-''',
- [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
- }
-
- void test_awaitForIn_existingVariableWrongType() {
- assertErrorsInCode(
- '''
-import 'dart:async';
-f() async {
- Stream<String> stream;
- int i;
- await for (i in stream) {}
-}
-''',
- [StaticTypeWarningCode.FOR_IN_OF_INVALID_ELEMENT_TYPE]);
- }
-
- void test_awaitForIn_declaredVariableRightType() {
- assertNoErrorsInCode('''
-import 'dart:async';
-f() async {
- Stream<int> stream;
- await for (int i in stream) {}
-}
-''');
- }
-
- void test_awaitForIn_existingVariableRightType() {
- assertNoErrorsInCode('''
-import 'dart:async';
-f() async {
- Stream<int> stream;
- int i;
- await for (i in stream) {}
-}
-''');
- }
-
- void test_awaitForIn_dynamicVariable() {
- assertNoErrorsInCode('''
-import 'dart:async';
-f() async {
- Stream<int> stream;
- await for (var i in stream) {}
-}
-''');
- }
-
- void test_awaitForIn_streamOfDynamic() {
- assertNoErrorsInCode('''
-import 'dart:async';
-f() async {
- Stream stream;
- await for (int i in stream) {}
-}
-''');
- }
-
- void test_awaitForIn_dynamicStream() {
- assertNoErrorsInCode('''
-f() async {
- dynamic stream;
- await for (int i in stream) {}
-}
-''');
- }
-
- void test_awaitForIn_upcast() {
- assertNoErrorsInCode('''
-import 'dart:async';
-f() async {
- Stream<int> stream;
- await for (num i in stream) {}
-}
-''');
- }
-
- void test_awaitForIn_downcast() {
- assertNoErrorsInCode('''
-import 'dart:async';
-f() async {
- Stream<num> stream;
- await for (int i in stream) {}
-}
-''');
- }
-
void test_yield_async_to_basic_type() {
assertErrorsInCode(
'''
« no previous file with comments | « pkg/analyzer/test/generated/static_type_analyzer_test.dart ('k') | pkg/analyzer/test/generated/static_warning_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698