| OLD | NEW |
| 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:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 REPLACEMENT: 'foo' | 188 REPLACEMENT: 'foo' |
| 189 }; | 189 }; |
| 190 expect(edit.toJson(), expectedJson); | 190 expect(edit.toJson(), expectedJson); |
| 191 } | 191 } |
| 192 | 192 |
| 193 } | 193 } |
| 194 | 194 |
| 195 | 195 |
| 196 @ReflectiveTestCase() | 196 @ReflectiveTestCase() |
| 197 class FileEditTest { | 197 class FileEditTest { |
| 198 void test_addAll() { | |
| 199 SourceEdit edit1a = new SourceEdit(1, 0, 'a1'); | |
| 200 SourceEdit edit1b = new SourceEdit(1, 0, 'a2'); | |
| 201 SourceEdit edit10 = new SourceEdit(10, 1, 'b'); | |
| 202 SourceEdit edit100 = new SourceEdit(100, 2, 'c'); | |
| 203 SourceFileEdit fileEdit = new SourceFileEdit('/test.dart', 0); | |
| 204 fileEdit.addAll([edit100, edit1a, edit10, edit1b]); | |
| 205 expect(fileEdit.edits, [edit100, edit10, edit1b, edit1a]); | |
| 206 } | |
| 207 | |
| 208 void test_add_sorts() { | 198 void test_add_sorts() { |
| 209 SourceEdit edit1a = new SourceEdit(1, 0, 'a1'); | 199 SourceEdit edit1a = new SourceEdit(1, 0, 'a1'); |
| 210 SourceEdit edit1b = new SourceEdit(1, 0, 'a2'); | 200 SourceEdit edit1b = new SourceEdit(1, 0, 'a2'); |
| 211 SourceEdit edit10 = new SourceEdit(10, 1, 'b'); | 201 SourceEdit edit10 = new SourceEdit(10, 1, 'b'); |
| 212 SourceEdit edit100 = new SourceEdit(100, 2, 'c'); | 202 SourceEdit edit100 = new SourceEdit(100, 2, 'c'); |
| 213 SourceFileEdit fileEdit = new SourceFileEdit('/test.dart', 0); | 203 SourceFileEdit fileEdit = new SourceFileEdit('/test.dart', 0); |
| 214 fileEdit.add(edit100); | 204 fileEdit.add(edit100); |
| 215 fileEdit.add(edit1a); | 205 fileEdit.add(edit1a); |
| 216 fileEdit.add(edit1b); | 206 fileEdit.add(edit1b); |
| 217 fileEdit.add(edit10); | 207 fileEdit.add(edit10); |
| 218 expect(fileEdit.edits, [edit100, edit10, edit1b, edit1a]); | 208 expect(fileEdit.edits, [edit100, edit10, edit1b, edit1a]); |
| 219 } | 209 } |
| 220 | 210 |
| 211 void test_addAll() { |
| 212 SourceEdit edit1a = new SourceEdit(1, 0, 'a1'); |
| 213 SourceEdit edit1b = new SourceEdit(1, 0, 'a2'); |
| 214 SourceEdit edit10 = new SourceEdit(10, 1, 'b'); |
| 215 SourceEdit edit100 = new SourceEdit(100, 2, 'c'); |
| 216 SourceFileEdit fileEdit = new SourceFileEdit('/test.dart', 0); |
| 217 fileEdit.addAll([edit100, edit1a, edit10, edit1b]); |
| 218 expect(fileEdit.edits, [edit100, edit10, edit1b, edit1a]); |
| 219 } |
| 220 |
| 221 void test_new() { | 221 void test_new() { |
| 222 SourceFileEdit fileEdit = new SourceFileEdit('/test.dart', 100); | 222 SourceFileEdit fileEdit = new SourceFileEdit('/test.dart', 100); |
| 223 fileEdit.add(new SourceEdit(1, 2, 'aaa')); | 223 fileEdit.add(new SourceEdit(1, 2, 'aaa')); |
| 224 fileEdit.add(new SourceEdit(10, 20, 'bbb')); | 224 fileEdit.add(new SourceEdit(10, 20, 'bbb')); |
| 225 expect( | 225 expect( |
| 226 fileEdit.toString(), | 226 fileEdit.toString(), |
| 227 '{"file":"/test.dart","fileStamp":100,"edits":[' | 227 '{"file":"/test.dart","fileStamp":100,"edits":[' |
| 228 '{"offset":10,"length":20,"replacement":"bbb"},' | 228 '{"offset":10,"length":20,"replacement":"bbb"},' |
| 229 '{"offset":1,"length":2,"replacement":"aaa"}]}'); | 229 '{"offset":1,"length":2,"replacement":"aaa"}]}'); |
| 230 } | 230 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 334 |
| 335 void test_toJson() { | 335 void test_toJson() { |
| 336 Position position = new Position('/test.dart', 1); | 336 Position position = new Position('/test.dart', 1); |
| 337 var expectedJson = { | 337 var expectedJson = { |
| 338 FILE: '/test.dart', | 338 FILE: '/test.dart', |
| 339 OFFSET: 1 | 339 OFFSET: 1 |
| 340 }; | 340 }; |
| 341 expect(position.toJson(), expectedJson); | 341 expect(position.toJson(), expectedJson); |
| 342 } | 342 } |
| 343 } | 343 } |
| OLD | NEW |