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

Side by Side Diff: pkg/analysis_services/test/correction/change_test.dart

Issue 418373002: More tests for creating undefined methods and functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library test.services.correction.change; 8 library test.services.correction.change;
9 9
10 import 'package:analysis_services/constants.dart'; 10 import 'package:analysis_services/constants.dart';
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 void test_new() { 114 void test_new() {
115 Change change = new Change('msg'); 115 Change change = new Change('msg');
116 change.add(new FileEdit('/a.dart') 116 change.add(new FileEdit('/a.dart')
117 ..add(new Edit(1, 2, 'aaa')) 117 ..add(new Edit(1, 2, 'aaa'))
118 ..add(new Edit(10, 20, 'bbb'))); 118 ..add(new Edit(10, 20, 'bbb')));
119 change.add(new FileEdit('/b.dart') 119 change.add(new FileEdit('/b.dart')
120 ..add(new Edit(21, 22, 'xxx')) 120 ..add(new Edit(21, 22, 'xxx'))
121 ..add(new Edit(210, 220, 'yyy'))); 121 ..add(new Edit(210, 220, 'yyy')));
122 change.addLinkedPositionGroup(new LinkedPositionGroup('id-a') 122 change.addLinkedPositionGroup(new LinkedPositionGroup('id-a')
123 ..add(new Position('/ga.dart', 1, 2)) 123 ..addPosition(new Position('/ga.dart', 1, 2))
124 ..add(new Position('/ga.dart', 10, 2))); 124 ..addPosition(new Position('/ga.dart', 10, 2)));
125 change.addLinkedPositionGroup(new LinkedPositionGroup('id-b') 125 change.addLinkedPositionGroup(new LinkedPositionGroup('id-b')
126 ..add(new Position('/gb.dart', 10, 5)) 126 ..addPosition(new Position('/gb.dart', 10, 5))
127 ..add(new Position('/gb.dart', 100, 5))); 127 ..addPosition(new Position('/gb.dart', 100, 5)));
128 expect( 128 expect(
129 change.toString(), 129 change.toString(),
130 'Change(message=msg, edits=[FileEdit(file=/a.dart, edits=[' 130 'Change(message=msg, edits=[FileEdit(file=/a.dart, edits=['
131 'Edit(offset=1, length=2, replacement=:>aaa<:), ' 131 'Edit(offset=1, length=2, replacement=:>aaa<:), '
132 'Edit(offset=10, length=20, replacement=:>bbb<:)]), ' 132 'Edit(offset=10, length=20, replacement=:>bbb<:)]), '
133 'FileEdit(file=/b.dart, edits=[' 133 'FileEdit(file=/b.dart, edits=['
134 'Edit(offset=21, length=22, replacement=:>xxx<:), ' 134 'Edit(offset=21, length=22, replacement=:>xxx<:), '
135 'Edit(offset=210, length=220, replacement=:>yyy<:)])], ' 135 'Edit(offset=210, length=220, replacement=:>yyy<:)])], '
136 'linkedPositionGroups=[' 'LinkedPositionGroup(id=id-a, positions=[' 136 'linkedPositionGroups=[' 'LinkedPositionGroup(id=id-a, positions=['
137 'Position(file=/ga.dart, offset=1, length=2), ' 137 'Position(file=/ga.dart, offset=1, length=2), '
138 'Position(file=/ga.dart, offset=10, length=2)]), ' 138 'Position(file=/ga.dart, offset=10, length=2)]), '
139 'LinkedPositionGroup(id=id-b, positions=[' 139 'LinkedPositionGroup(id=id-b, positions=['
140 'Position(file=/gb.dart, offset=10, length=5), ' 140 'Position(file=/gb.dart, offset=10, length=5), '
141 'Position(file=/gb.dart, offset=100, length=5)])])'); 141 'Position(file=/gb.dart, offset=100, length=5)])])');
142 } 142 }
143 143
144 void test_toJson() { 144 void test_toJson() {
145 Change change = new Change('msg'); 145 Change change = new Change('msg');
146 change.add(new FileEdit('/a.dart') 146 change.add(new FileEdit('/a.dart')
147 ..add(new Edit(1, 2, 'aaa')) 147 ..add(new Edit(1, 2, 'aaa'))
148 ..add(new Edit(10, 20, 'bbb'))); 148 ..add(new Edit(10, 20, 'bbb')));
149 change.add(new FileEdit('/b.dart') 149 change.add(new FileEdit('/b.dart')
150 ..add(new Edit(21, 22, 'xxx')) 150 ..add(new Edit(21, 22, 'xxx'))
151 ..add(new Edit(210, 220, 'yyy'))); 151 ..add(new Edit(210, 220, 'yyy')));
152 change.addLinkedPositionGroup(new LinkedPositionGroup('id-a') 152 change.addLinkedPositionGroup(new LinkedPositionGroup('id-a')
153 ..add(new Position('/ga.dart', 1, 2)) 153 ..addPosition(new Position('/ga.dart', 1, 2))
154 ..add(new Position('/ga.dart', 10, 2))); 154 ..addPosition(new Position('/ga.dart', 10, 2)));
155 change.addLinkedPositionGroup(new LinkedPositionGroup('id-b') 155 change.addLinkedPositionGroup(new LinkedPositionGroup('id-b')
156 ..add(new Position('/gb.dart', 10, 5)) 156 ..addPosition(new Position('/gb.dart', 10, 5))
157 ..add(new Position('/gb.dart', 100, 5))); 157 ..addPosition(new Position('/gb.dart', 100, 5)));
158 var expectedJson = { 158 var expectedJson = {
159 MESSAGE: 'msg', 159 MESSAGE: 'msg',
160 EDITS: [{ 160 EDITS: [{
161 FILE: '/a.dart', 161 FILE: '/a.dart',
162 EDITS: [{ 162 EDITS: [{
163 OFFSET: 1, 163 OFFSET: 1,
164 LENGTH: 2, 164 LENGTH: 2,
165 REPLACEMENT: 'aaa' 165 REPLACEMENT: 'aaa'
166 }, { 166 }, {
167 OFFSET: 10, 167 OFFSET: 10,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 },] 309 },]
310 }); 310 });
311 } 311 }
312 } 312 }
313 313
314 314
315 @ReflectiveTestCase() 315 @ReflectiveTestCase()
316 class LinkedPositionGroupTest { 316 class LinkedPositionGroupTest {
317 void test_addWrongLength() { 317 void test_addWrongLength() {
318 LinkedPositionGroup group = new LinkedPositionGroup('my-id'); 318 LinkedPositionGroup group = new LinkedPositionGroup('my-id');
319 group.add(new Position('/a.dart', 1, 2)); 319 group.addPosition(new Position('/a.dart', 1, 2));
320 expect(() { 320 expect(() {
321 group.add(new Position('/b.dart', 10, 20)); 321 group.addPosition(new Position('/b.dart', 10, 20));
322 }, throws); 322 }, throws);
323 } 323 }
324 324
325 void test_fromJson() { 325 void test_fromJson() {
326 var json = { 326 var json = {
327 ID: 'my-id', 327 ID: 'my-id',
328 POSITIONS: [{ 328 POSITIONS: [{
329 FILE: '/a.dart', 329 FILE: '/a.dart',
330 OFFSET: 1, 330 OFFSET: 1,
331 LENGTH: 2 331 LENGTH: 2
332 }, { 332 }, {
333 FILE: '/b.dart', 333 FILE: '/b.dart',
334 OFFSET: 10, 334 OFFSET: 10,
335 LENGTH: 2 335 LENGTH: 2
336 }] 336 }]
337 }; 337 };
338 LinkedPositionGroup group = LinkedPositionGroup.fromJson(json); 338 LinkedPositionGroup group = LinkedPositionGroup.fromJson(json);
339 expect(group.id, 'my-id'); 339 expect(group.id, 'my-id');
340 expect(group.positions, hasLength(2)); 340 expect(group.positions, hasLength(2));
341 expect(group.positions[0], new Position('/a.dart', 1, 2)); 341 expect(group.positions[0], new Position('/a.dart', 1, 2));
342 expect(group.positions[1], new Position('/b.dart', 10, 2)); 342 expect(group.positions[1], new Position('/b.dart', 10, 2));
343 } 343 }
344 344
345 void test_new() { 345 void test_new() {
346 LinkedPositionGroup group = new LinkedPositionGroup('my-id'); 346 LinkedPositionGroup group = new LinkedPositionGroup('my-id');
347 group.add(new Position('/a.dart', 1, 2)); 347 group.addPosition(new Position('/a.dart', 1, 2));
348 group.add(new Position('/b.dart', 10, 2)); 348 group.addPosition(new Position('/b.dart', 10, 2));
349 expect( 349 expect(
350 group.toString(), 350 group.toString(),
351 'LinkedPositionGroup(id=my-id, positions=[' 351 'LinkedPositionGroup(id=my-id, positions=['
352 'Position(file=/a.dart, offset=1, length=2), ' 352 'Position(file=/a.dart, offset=1, length=2), '
353 'Position(file=/b.dart, offset=10, length=2)])'); 353 'Position(file=/b.dart, offset=10, length=2)])');
354 } 354 }
355 355
356 void test_toJson() { 356 void test_toJson() {
357 LinkedPositionGroup group = new LinkedPositionGroup('my-id'); 357 LinkedPositionGroup group = new LinkedPositionGroup('my-id');
358 group.add(new Position('/a.dart', 1, 2)); 358 group.addPosition(new Position('/a.dart', 1, 2));
359 group.add(new Position('/b.dart', 10, 2)); 359 group.addPosition(new Position('/b.dart', 10, 2));
360 var expectedJson = { 360 var expectedJson = {
361 ID: 'my-id', 361 ID: 'my-id',
362 POSITIONS: [{ 362 POSITIONS: [{
363 FILE: '/a.dart', 363 FILE: '/a.dart',
364 OFFSET: 1, 364 OFFSET: 1,
365 LENGTH: 2 365 LENGTH: 2
366 }, { 366 }, {
367 FILE: '/b.dart', 367 FILE: '/b.dart',
368 OFFSET: 10, 368 OFFSET: 10,
369 LENGTH: 2 369 LENGTH: 2
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 void test_toJson() { 416 void test_toJson() {
417 Position position = new Position('/test.dart', 1, 2); 417 Position position = new Position('/test.dart', 1, 2);
418 var expectedJson = { 418 var expectedJson = {
419 FILE: '/test.dart', 419 FILE: '/test.dart',
420 OFFSET: 1, 420 OFFSET: 1,
421 LENGTH: 2 421 LENGTH: 2
422 }; 422 };
423 expect(position.toJson(), expectedJson); 423 expect(position.toJson(), expectedJson);
424 } 424 }
425 } 425 }
OLDNEW
« no previous file with comments | « pkg/analysis_services/lib/src/correction/source_buffer.dart ('k') | pkg/analysis_services/test/correction/fix_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698