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

Side by Side Diff: pkg/analysis_server/test/services/correction/change_test.dart

Issue 1266923004: More fixes for failures on the Windows bot (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
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.services.correction.change; 5 library test.services.correction.change;
6 6
7 import 'package:analysis_server/src/constants.dart'; 7 import 'package:analysis_server/src/constants.dart';
8 import 'package:analysis_server/src/protocol_server.dart'; 8 import 'package:analysis_server/src/protocol_server.dart';
9 import 'package:analyzer/src/generated/source.dart'; 9 import 'package:analyzer/src/generated/source.dart';
10 import 'package:test_reflective_loader/test_reflective_loader.dart'; 10 import 'package:test_reflective_loader/test_reflective_loader.dart';
11 import 'package:unittest/unittest.dart'; 11 import 'package:unittest/unittest.dart';
12 12
13 import '../../utils.dart';
14
13 main() { 15 main() {
14 groupSep = ' | '; 16 initializeTestEnvironment();
15 defineReflectiveTests(ChangeTest); 17 defineReflectiveTests(ChangeTest);
16 defineReflectiveTests(EditTest); 18 defineReflectiveTests(EditTest);
17 defineReflectiveTests(FileEditTest); 19 defineReflectiveTests(FileEditTest);
18 defineReflectiveTests(LinkedEditGroupTest); 20 defineReflectiveTests(LinkedEditGroupTest);
19 defineReflectiveTests(LinkedEditSuggestionTest); 21 defineReflectiveTests(LinkedEditSuggestionTest);
20 defineReflectiveTests(PositionTest); 22 defineReflectiveTests(PositionTest);
21 } 23 }
22 24
23 @reflectiveTest 25 @reflectiveTest
24 class ChangeTest { 26 class ChangeTest {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 expect(a == this, isFalse); 147 expect(a == this, isFalse);
146 expect(a == new SourceEdit(1, 2, 'bbb'), isFalse); 148 expect(a == new SourceEdit(1, 2, 'bbb'), isFalse);
147 expect(a == new SourceEdit(10, 2, 'aaa'), isFalse); 149 expect(a == new SourceEdit(10, 2, 'aaa'), isFalse);
148 } 150 }
149 151
150 void test_new() { 152 void test_new() {
151 SourceEdit edit = new SourceEdit(1, 2, 'foo', id: 'my-id'); 153 SourceEdit edit = new SourceEdit(1, 2, 'foo', id: 'my-id');
152 expect(edit.offset, 1); 154 expect(edit.offset, 1);
153 expect(edit.length, 2); 155 expect(edit.length, 2);
154 expect(edit.replacement, 'foo'); 156 expect(edit.replacement, 'foo');
155 expect(edit.toJson(), { 157 expect(edit.toJson(),
156 'offset': 1, 158 {'offset': 1, 'length': 2, 'replacement': 'foo', 'id': 'my-id'});
157 'length': 2,
158 'replacement': 'foo',
159 'id': 'my-id'
160 });
161 } 159 }
160
162 void test_toJson() { 161 void test_toJson() {
163 SourceEdit edit = new SourceEdit(1, 2, 'foo'); 162 SourceEdit edit = new SourceEdit(1, 2, 'foo');
164 var expectedJson = {OFFSET: 1, LENGTH: 2, REPLACEMENT: 'foo'}; 163 var expectedJson = {OFFSET: 1, LENGTH: 2, REPLACEMENT: 'foo'};
165 expect(edit.toJson(), expectedJson); 164 expect(edit.toJson(), expectedJson);
166 } 165 }
167 } 166 }
168 167
169 @reflectiveTest 168 @reflectiveTest
170 class FileEditTest { 169 class FileEditTest {
171 void test_add_sorts() { 170 void test_add_sorts() {
(...skipping 16 matching lines...) Expand all
188 SourceEdit edit100 = new SourceEdit(100, 2, 'c'); 187 SourceEdit edit100 = new SourceEdit(100, 2, 'c');
189 SourceFileEdit fileEdit = new SourceFileEdit('/test.dart', 0); 188 SourceFileEdit fileEdit = new SourceFileEdit('/test.dart', 0);
190 fileEdit.addAll([edit100, edit1a, edit10, edit1b]); 189 fileEdit.addAll([edit100, edit1a, edit10, edit1b]);
191 expect(fileEdit.edits, [edit100, edit10, edit1b, edit1a]); 190 expect(fileEdit.edits, [edit100, edit10, edit1b, edit1a]);
192 } 191 }
193 192
194 void test_new() { 193 void test_new() {
195 SourceFileEdit fileEdit = new SourceFileEdit('/test.dart', 100); 194 SourceFileEdit fileEdit = new SourceFileEdit('/test.dart', 100);
196 fileEdit.add(new SourceEdit(1, 2, 'aaa')); 195 fileEdit.add(new SourceEdit(1, 2, 'aaa'));
197 fileEdit.add(new SourceEdit(10, 20, 'bbb')); 196 fileEdit.add(new SourceEdit(10, 20, 'bbb'));
198 expect(fileEdit.toString(), '{"file":"/test.dart","fileStamp":100,"edits":[' 197 expect(
198 fileEdit.toString(),
199 '{"file":"/test.dart","fileStamp":100,"edits":['
199 '{"offset":10,"length":20,"replacement":"bbb"},' 200 '{"offset":10,"length":20,"replacement":"bbb"},'
200 '{"offset":1,"length":2,"replacement":"aaa"}]}'); 201 '{"offset":1,"length":2,"replacement":"aaa"}]}');
201 } 202 }
202 203
203 void test_toJson() { 204 void test_toJson() {
204 SourceFileEdit fileEdit = new SourceFileEdit('/test.dart', 100); 205 SourceFileEdit fileEdit = new SourceFileEdit('/test.dart', 100);
205 fileEdit.add(new SourceEdit(1, 2, 'aaa')); 206 fileEdit.add(new SourceEdit(1, 2, 'aaa'));
206 fileEdit.add(new SourceEdit(10, 20, 'bbb')); 207 fileEdit.add(new SourceEdit(10, 20, 'bbb'));
207 var expectedJson = { 208 var expectedJson = {
208 FILE: '/test.dart', 209 FILE: '/test.dart',
209 FILE_STAMP: 100, 210 FILE_STAMP: 100,
210 EDITS: [ 211 EDITS: [
211 {OFFSET: 10, LENGTH: 20, REPLACEMENT: 'bbb'}, 212 {OFFSET: 10, LENGTH: 20, REPLACEMENT: 'bbb'},
212 {OFFSET: 1, LENGTH: 2, REPLACEMENT: 'aaa'}, 213 {OFFSET: 1, LENGTH: 2, REPLACEMENT: 'aaa'},
213 ] 214 ]
214 }; 215 };
215 expect(fileEdit.toJson(), expectedJson); 216 expect(fileEdit.toJson(), expectedJson);
216 } 217 }
217 } 218 }
218 219
219 @reflectiveTest 220 @reflectiveTest
220 class LinkedEditGroupTest { 221 class LinkedEditGroupTest {
221 void test_new() { 222 void test_new() {
222 LinkedEditGroup group = new LinkedEditGroup.empty(); 223 LinkedEditGroup group = new LinkedEditGroup.empty();
223 group.addPosition(new Position('/a.dart', 1), 2); 224 group.addPosition(new Position('/a.dart', 1), 2);
224 group.addPosition(new Position('/b.dart', 10), 2); 225 group.addPosition(new Position('/b.dart', 10), 2);
225 expect(group.toString(), '{"positions":[' '{"file":"/a.dart","offset":1},' 226 expect(
227 group.toString(),
228 '{"positions":['
229 '{"file":"/a.dart","offset":1},'
226 '{"file":"/b.dart","offset":10}],"length":2,"suggestions":[]}'); 230 '{"file":"/b.dart","offset":10}],"length":2,"suggestions":[]}');
227 } 231 }
228 232
229 void test_toJson() { 233 void test_toJson() {
230 LinkedEditGroup group = new LinkedEditGroup.empty(); 234 LinkedEditGroup group = new LinkedEditGroup.empty();
231 group.addPosition(new Position('/a.dart', 1), 2); 235 group.addPosition(new Position('/a.dart', 1), 2);
232 group.addPosition(new Position('/b.dart', 10), 2); 236 group.addPosition(new Position('/b.dart', 10), 2);
233 group.addSuggestion( 237 group.addSuggestion(
234 new LinkedEditSuggestion('AA', LinkedEditSuggestionKind.TYPE)); 238 new LinkedEditSuggestion('AA', LinkedEditSuggestionKind.TYPE));
235 group.addSuggestion( 239 group.addSuggestion(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 expect(position.offset, 1); 290 expect(position.offset, 1);
287 expect(position.toString(), '{"file":"/test.dart","offset":1}'); 291 expect(position.toString(), '{"file":"/test.dart","offset":1}');
288 } 292 }
289 293
290 void test_toJson() { 294 void test_toJson() {
291 Position position = new Position('/test.dart', 1); 295 Position position = new Position('/test.dart', 1);
292 var expectedJson = {FILE: '/test.dart', OFFSET: 1}; 296 var expectedJson = {FILE: '/test.dart', OFFSET: 1};
293 expect(position.toJson(), expectedJson); 297 expect(position.toJson(), expectedJson);
294 } 298 }
295 } 299 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698