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

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

Issue 492243002: Introduce convenience methods into generated analysis server classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | 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 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/protocol2.dart' show SourceEdit; 8 import 'package:analysis_server/src/protocol2.dart' show SourceEdit;
9 import 'package:analysis_server/src/services/correction/change.dart'; 9 import 'package:analysis_server/src/services/correction/change.dart';
10 import 'package:analysis_testing/reflective_tests.dart'; 10 import 'package:analysis_testing/reflective_tests.dart';
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 change.toString(); 137 change.toString();
138 } 138 }
139 } 139 }
140 140
141 141
142 @ReflectiveTestCase() 142 @ReflectiveTestCase()
143 class EditTest { 143 class EditTest {
144 void test_applySequence() { 144 void test_applySequence() {
145 SourceEdit edit1 = new SourceEdit(5, 2, 'abc'); 145 SourceEdit edit1 = new SourceEdit(5, 2, 'abc');
146 SourceEdit edit2 = new SourceEdit(1, 0, '!'); 146 SourceEdit edit2 = new SourceEdit(1, 0, '!');
147 expect(applySequence('0123456789', [edit1, edit2]), '0!1234abc789'); 147 expect(SourceEdit.applySequence('0123456789', [edit1, edit2]), '0!1234abc789 ');
148 } 148 }
149 149
150 void test_eqEq() { 150 void test_eqEq() {
151 SourceEdit a = new SourceEdit(1, 2, 'aaa'); 151 SourceEdit a = new SourceEdit(1, 2, 'aaa');
152 SourceEdit a2 = new SourceEdit(1, 2, 'aaa'); 152 SourceEdit a2 = new SourceEdit(1, 2, 'aaa');
153 SourceEdit b = new SourceEdit(1, 2, 'aaa'); 153 SourceEdit b = new SourceEdit(1, 2, 'aaa');
154 expect(a == a, isTrue); 154 expect(a == a, isTrue);
155 expect(a == new SourceEdit(1, 2, 'aaa'), isTrue); 155 expect(a == new SourceEdit(1, 2, 'aaa'), isTrue);
156 expect(a == this, isFalse); 156 expect(a == this, isFalse);
157 expect(a == new SourceEdit(1, 2, 'bbb'), isFalse); 157 expect(a == new SourceEdit(1, 2, 'bbb'), isFalse);
158 expect(a == new SourceEdit(10, 2, 'aaa'), isFalse); 158 expect(a == new SourceEdit(10, 2, 'aaa'), isFalse);
159 } 159 }
160 160
161 void test_new() { 161 void test_new() {
162 SourceEdit edit = new SourceEdit(1, 2, 'foo', id: 'my-id'); 162 SourceEdit edit = new SourceEdit(1, 2, 'foo', id: 'my-id');
163 expect(edit.offset, 1); 163 expect(edit.offset, 1);
164 expect(edit.length, 2); 164 expect(edit.length, 2);
165 expect(edit.replacement, 'foo'); 165 expect(edit.replacement, 'foo');
166 expect( 166 expect(
167 edit.toJson(), 167 edit.toJson(),
168 {'offset': 1, 'length': 2, 'replacement': 'foo', 'id': 'my-id'}); 168 {'offset': 1, 'length': 2, 'replacement': 'foo', 'id': 'my-id'});
169 } 169 }
170 170
171 void test_editFromRange() { 171 void test_editFromRange() {
172 SourceRange range = new SourceRange(1, 2); 172 SourceRange range = new SourceRange(1, 2);
173 SourceEdit edit = editFromRange(range, 'foo'); 173 SourceEdit edit = new SourceEdit.range(range, 'foo');
174 expect(edit.offset, 1); 174 expect(edit.offset, 1);
175 expect(edit.length, 2); 175 expect(edit.length, 2);
176 expect(edit.replacement, 'foo'); 176 expect(edit.replacement, 'foo');
177 } 177 }
178 void test_toJson() { 178 void test_toJson() {
179 SourceEdit edit = new SourceEdit(1, 2, 'foo'); 179 SourceEdit edit = new SourceEdit(1, 2, 'foo');
180 var expectedJson = { 180 var expectedJson = {
181 OFFSET: 1, 181 OFFSET: 1,
182 LENGTH: 2, 182 LENGTH: 2,
183 REPLACEMENT: 'foo' 183 REPLACEMENT: 'foo'
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 329
330 void test_toJson() { 330 void test_toJson() {
331 Position position = new Position('/test.dart', 1); 331 Position position = new Position('/test.dart', 1);
332 var expectedJson = { 332 var expectedJson = {
333 FILE: '/test.dart', 333 FILE: '/test.dart',
334 OFFSET: 1 334 OFFSET: 1
335 }; 335 };
336 expect(position.toJson(), expectedJson); 336 expect(position.toJson(), expectedJson);
337 } 337 }
338 } 338 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698