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

Unified Diff: pkg/analysis_server/test/services/correction/assist_test.dart

Issue 806933002: Issue 21883. Add checks if type parameters can be used. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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/analysis_server/test/services/correction/assist_test.dart
diff --git a/pkg/analysis_server/test/services/correction/assist_test.dart b/pkg/analysis_server/test/services/correction/assist_test.dart
index cac20900ccd74a5b2f61d558768b126b0f100937..793c8708aef6b9cd12b0eba051715e4ffbd17d76 100644
--- a/pkg/analysis_server/test/services/correction/assist_test.dart
+++ b/pkg/analysis_server/test/services/correction/assist_test.dart
@@ -166,6 +166,25 @@ main() {
assertNoAssistAt('item in', AssistKind.ADD_TYPE_ANNOTATION);
}
+ void test_addTypeAnnotation_declaredIdentifier_generic_OK() {
+ _indexTestUnit('''
+class A<T> {
+ main(List<List<T>> items) {
+ for (var item in items) {
+ }
+ }
+}
+''');
+ assertHasAssistAt('item in', AssistKind.ADD_TYPE_ANNOTATION, '''
+class A<T> {
+ main(List<List<T>> items) {
+ for (List<T> item in items) {
+ }
+ }
+}
+''');
+ }
+
void test_addTypeAnnotation_declaredIdentifier_OK() {
_indexTestUnit('''
main(List<String> items) {
@@ -226,6 +245,40 @@ main(List<String> items) {
''');
}
+ void test_addTypeAnnotation_local_generic_OK_literal() {
+ _indexTestUnit('''
+class A {
+ main(List<int> items) {
+ var v = items;
+ }
+}
+''');
+ assertHasAssistAt('v =', AssistKind.ADD_TYPE_ANNOTATION, '''
+class A {
+ main(List<int> items) {
+ List<int> v = items;
+ }
+}
+''');
+ }
+
+ void test_addTypeAnnotation_local_generic_OK_local() {
+ _indexTestUnit('''
+class A<T> {
+ main(List<T> items) {
+ var v = items;
+ }
+}
+''');
+ assertHasAssistAt('v =', AssistKind.ADD_TYPE_ANNOTATION, '''
+class A<T> {
+ main(List<T> items) {
+ List<T> v = items;
+ }
+}
+''');
+ }
+
void test_addTypeAnnotation_local_OK_addImport_dartUri() {
addSource('/my_lib.dart', r'''
import 'dart:async';
@@ -2254,28 +2307,28 @@ main() {
}
}
- void test_splitAndCondition_wrong_notAnd() {
+ void test_splitAndCondition_wrong_hasElse() {
_indexTestUnit('''
main() {
- if (1 == 1 || 2 == 2) {
- print(0);
+ if (1 == 1 && 2 == 2) {
+ print(1);
+ } else {
+ print(2);
}
}
''');
- assertNoAssistAt('|| 2', AssistKind.SPLIT_AND_CONDITION);
+ assertNoAssistAt('&& 2', AssistKind.SPLIT_AND_CONDITION);
}
- void test_splitAndCondition_wrong_hasElse() {
+ void test_splitAndCondition_wrong_notAnd() {
_indexTestUnit('''
main() {
- if (1 == 1 && 2 == 2) {
- print(1);
- } else {
- print(2);
+ if (1 == 1 || 2 == 2) {
+ print(0);
}
}
''');
- assertNoAssistAt('&& 2', AssistKind.SPLIT_AND_CONDITION);
+ assertNoAssistAt('|| 2', AssistKind.SPLIT_AND_CONDITION);
}
void test_splitAndCondition_wrong_notPartOfIf() {

Powered by Google App Engine
This is Rietveld 408576698