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

Side by Side Diff: pkg/analysis_server/test/edit/assists_test.dart

Issue 1140373002: Convert two tests to use async/await. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/test/edit/fixes_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.edit.assists; 5 library test.edit.assists;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/edit/edit_domain.dart'; 9 import 'package:analysis_server/src/edit/edit_domain.dart';
10 import 'package:analysis_server/src/plugin/server_plugin.dart'; 10 import 'package:analysis_server/src/plugin/server_plugin.dart';
(...skipping 29 matching lines...) Expand all
40 @override 40 @override
41 void setUp() { 41 void setUp() {
42 super.setUp(); 42 super.setUp();
43 createProject(); 43 createProject();
44 ExtensionManager manager = new ExtensionManager(); 44 ExtensionManager manager = new ExtensionManager();
45 ServerPlugin plugin = new ServerPlugin(); 45 ServerPlugin plugin = new ServerPlugin();
46 manager.processPlugins([plugin]); 46 manager.processPlugins([plugin]);
47 handler = new EditDomainHandler(server, plugin); 47 handler = new EditDomainHandler(server, plugin);
48 } 48 }
49 49
50 Future test_removeTypeAnnotation() { 50 Future test_removeTypeAnnotation() async {
51 addTestFile(''' 51 addTestFile('''
52 main() { 52 main() {
53 int v = 1; 53 int v = 1;
54 } 54 }
55 '''); 55 ''');
56 return waitForTasksFinished().then((_) { 56 await waitForTasksFinished();
57 prepareAssists('v ='); 57 prepareAssists('v =');
58 _assertHasChange('Remove type annotation', ''' 58 _assertHasChange('Remove type annotation', '''
59 main() { 59 main() {
60 var v = 1; 60 var v = 1;
61 } 61 }
62 '''); 62 ''');
63 });
64 } 63 }
65 64
66 Future test_splitVariableDeclaration() { 65 Future test_splitVariableDeclaration() async {
67 addTestFile(''' 66 addTestFile('''
68 main() { 67 main() {
69 int v = 1; 68 int v = 1;
70 } 69 }
71 '''); 70 ''');
72 return waitForTasksFinished().then((_) { 71 await waitForTasksFinished();
73 prepareAssists('v ='); 72 prepareAssists('v =');
74 _assertHasChange('Split variable declaration', ''' 73 _assertHasChange('Split variable declaration', '''
75 main() { 74 main() {
76 int v; 75 int v;
77 v = 1; 76 v = 1;
78 } 77 }
79 '''); 78 ''');
80 });
81 } 79 }
82 80
83 Future test_surroundWithIf() { 81 Future test_surroundWithIf() async {
84 addTestFile(''' 82 addTestFile('''
85 main() { 83 main() {
86 print(1); 84 print(1);
87 print(2); 85 print(2);
88 } 86 }
89 '''); 87 ''');
90 return waitForTasksFinished().then((_) { 88 await waitForTasksFinished();
91 int offset = findOffset(' print(1)'); 89 int offset = findOffset(' print(1)');
92 int length = findOffset('}') - offset; 90 int length = findOffset('}') - offset;
93 prepareAssistsAt(offset, length); 91 prepareAssistsAt(offset, length);
94 _assertHasChange("Surround with 'if'", ''' 92 _assertHasChange("Surround with 'if'", '''
95 main() { 93 main() {
96 if (condition) { 94 if (condition) {
97 print(1); 95 print(1);
98 print(2); 96 print(2);
99 } 97 }
100 } 98 }
101 '''); 99 ''');
102 });
103 } 100 }
104 101
105 void _assertHasChange(String message, String expectedCode) { 102 void _assertHasChange(String message, String expectedCode) {
106 for (SourceChange change in changes) { 103 for (SourceChange change in changes) {
107 if (change.message == message) { 104 if (change.message == message) {
108 String resultCode = 105 String resultCode =
109 SourceEdit.applySequence(testCode, change.edits[0].edits); 106 SourceEdit.applySequence(testCode, change.edits[0].edits);
110 expect(resultCode, expectedCode); 107 expect(resultCode, expectedCode);
111 return; 108 return;
112 } 109 }
113 } 110 }
114 fail("Expected to find |$message| in\n" + changes.join('\n')); 111 fail("Expected to find |$message| in\n" + changes.join('\n'));
115 } 112 }
116 } 113 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/edit/fixes_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698