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

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

Issue 1012913002: Casted variable declarations for 'if (v is! Type)' should be declared after IfStatement. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/assist_internal.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 df444d29ad03333c0ae31f93f21c6e2c88cfd1cb..52764fe41f8738b065886b262c6827cfc910f4aa 100644
--- a/pkg/analysis_server/test/services/correction/assist_test.dart
+++ b/pkg/analysis_server/test/services/correction/assist_test.dart
@@ -1576,7 +1576,7 @@ main(p) {
assertNoAssistAt('if (p', AssistKind.INTRODUCE_LOCAL_CAST_TYPE);
}
- void test_introduceLocalTestedType_OK_if() {
+ void test_introduceLocalTestedType_OK_if_is() {
resolveTestUnit('''
class MyTypeName {}
main(p) {
@@ -1604,6 +1604,34 @@ main(p) {
assertHasAssistAt('if (p', AssistKind.INTRODUCE_LOCAL_CAST_TYPE, expected);
}
+ void test_introduceLocalTestedType_OK_if_isNot() {
+ resolveTestUnit('''
+class MyTypeName {}
+main(p) {
+ if (p is! MyTypeName) {
+ return;
+ }
+}
+''');
+ String expected = '''
+class MyTypeName {}
+main(p) {
+ if (p is! MyTypeName) {
+ return;
+ }
+ MyTypeName myTypeName = p;
+}
+''';
+ assertHasAssistAt(
+ 'is! MyType', AssistKind.INTRODUCE_LOCAL_CAST_TYPE, expected);
+ _assertLinkedGroup(change.linkedEditGroups[0], [
+ 'myTypeName = '
+ ], expectedSuggestions(
+ LinkedEditSuggestionKind.VARIABLE, ['myTypeName', 'typeName', 'name']));
+ // another good location
+ assertHasAssistAt('if (p', AssistKind.INTRODUCE_LOCAL_CAST_TYPE, expected);
+ }
+
void test_introduceLocalTestedType_OK_while() {
resolveTestUnit('''
main(p) {
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/assist_internal.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698