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