OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 library polymer.test.refactor_test; | |
6 | |
7 import 'package:unittest/compact_vm_config.dart'; | |
8 import 'package:unittest/unittest.dart'; | |
9 import 'package:polymer/src/refactor.dart'; | |
10 import 'package:source_maps/span.dart'; | |
11 | |
12 main() { | |
13 useCompactVMConfiguration(); | |
14 var original = "0123456789abcdefghij"; | |
15 var file = new SourceFile.text('', original); | |
16 | |
17 test('non conflicting, in order edits', () { | |
18 var txn = new TextEditTransaction(original, file); | |
19 txn.edit(2, 4, '.'); | |
20 txn.edit(5, 5, '|'); | |
21 txn.edit(6, 6, '-'); | |
22 txn.edit(6, 7, '_'); | |
23 expect((txn.commit()..build('')).text, "01.4|5-_789abcdefghij"); | |
24 }); | |
25 | |
26 test('non conflicting, out of order edits', () { | |
27 var txn = new TextEditTransaction(original, file); | |
28 txn.edit(2, 4, '.'); | |
29 txn.edit(5, 5, '|'); | |
30 | |
31 // Regresion test for issue #404: there is no conflict/overlap for edits | |
32 // that don't remove any of the original code. | |
33 txn.edit(6, 7, '_'); | |
34 txn.edit(6, 6, '-'); | |
35 expect((txn.commit()..build('')).text, "01.4|5-_789abcdefghij"); | |
36 | |
37 }); | |
38 | |
39 test('non conflicting edits', () { | |
40 var txn = new TextEditTransaction(original, file); | |
41 txn.edit(2, 4, '.'); | |
42 txn.edit(3, 3, '-'); | |
43 expect(() => txn.commit(), throwsA(predicate( | |
44 (e) => e.toString().contains('overlapping edits')))); | |
45 }); | |
46 } | |
OLD | NEW |