Chromium Code Reviews| Index: pkg/source_maps/test/refactor_test.dart |
| diff --git a/pkg/source_maps/test/refactor_test.dart b/pkg/source_maps/test/refactor_test.dart |
| index 5d0abf1e25f8f83016b4f583ea9ae72a1ccc43f2..08b896510cde9e273431650247f510455b3fed4a 100644 |
| --- a/pkg/source_maps/test/refactor_test.dart |
| +++ b/pkg/source_maps/test/refactor_test.dart |
| @@ -6,13 +6,13 @@ library polymer.test.refactor_test; |
| import 'package:unittest/unittest.dart'; |
| import 'package:source_maps/refactor.dart'; |
| -import 'package:source_maps/span.dart'; |
| import 'package:source_maps/parser.dart' show parse, Mapping; |
| +import 'package:source_span/source_span.dart'; |
| main() { |
| group('conflict detection', () { |
| var original = "0123456789abcdefghij"; |
| - var file = new SourceFile.text('', original); |
| + var file = new SourceFile(original); |
| test('no conflict, in order', () { |
| var txn = new TextEditTransaction(original, file); |
| @@ -48,7 +48,7 @@ main() { |
| test('generated source maps', () { |
| var original = |
| "0123456789\n0*23456789\n01*3456789\nabcdefghij\nabcd*fghij\n"; |
| - var file = new SourceFile.text('', original); |
| + var file = new SourceFile(original); |
| var txn = new TextEditTransaction(original, file); |
| txn.edit(27, 29, '__\n '); |
| txn.edit(34, 35, '___'); |
| @@ -60,42 +60,90 @@ main() { |
| // Line 1 and 2 are unmodified: mapping any column returns the beginning |
| // of the corresponding line: |
| - expect(_span(1, 1, map, file), "line 1, column 1 of .: \n0123456789"); |
| - expect(_span(1, 5, map, file), "line 1, column 1 of .: \n0123456789"); |
| - expect(_span(2, 1, map, file), "line 2, column 1 of .: \n0*23456789"); |
| - expect(_span(2, 8, map, file), "line 2, column 1 of .: \n0*23456789"); |
| + expect(_span(1, 1, map, file), |
| + "line 1, column 1: \n" |
| + "0123456789\n" |
| + "^"); |
| + expect(_span(1, 5, map, file), |
| + "line 1, column 1: \n" |
| + "0123456789\n" |
| + "^"); |
| + expect(_span(2, 1, map, file), |
| + "line 2, column 1: \n" |
| + "0*23456789\n" |
| + "^"); |
| + expect(_span(2, 8, map, file), |
| + "line 2, column 1: \n" |
| + "0*23456789\n" |
| + "^"); |
| // Line 3 is modified part way: mappings before the edits have the right |
| // mapping, after the edits the mapping is null. |
| - expect(_span(3, 1, map, file), "line 3, column 1 of .: \n01*3456789"); |
| - expect(_span(3, 5, map, file), "line 3, column 1 of .: \n01*3456789"); |
| + expect(_span(3, 1, map, file), |
| + "line 3, column 1: \n" |
| + "01*3456789\n" |
| + "^"); |
| + expect(_span(3, 5, map, file), |
| + "line 3, column 1: \n" |
| + "01*3456789\n" |
| + "^"); |
| // Start of edits map to beginning of the edit secion: |
| - expect(_span(3, 6, map, file), "line 3, column 6 of .: \n01*3456789"); |
| - expect(_span(3, 7, map, file), "line 3, column 6 of .: \n01*3456789"); |
| + expect(_span(3, 6, map, file), |
| + "line 3, column 6: \n" |
| + "01*3456789\n" |
| + " ^"); |
| + expect(_span(3, 7, map, file), |
| + "line 3, column 6: \n" |
| + "01*3456789\n" |
| + " ^"); |
| // Lines added have no mapping (they should inherit the last mapping), |
| // but the end of the edit region continues were we left off: |
| expect(_span(4, 1, map, file), isNull); |
| - expect(_span(4, 5, map, file), "line 3, column 8 of .: \n01*3456789"); |
| + expect(_span(4, 5, map, file), |
| + "line 3, column 8: \n" |
| + "01*3456789\n" |
| + " ^"); |
| // Subsequent lines are still mapped correctly: |
| // a (in a___cd...) |
| - expect(_span(5, 1, map, file), "line 4, column 1 of .: \nabcdefghij"); |
| + expect(_span(5, 1, map, file), |
| + "line 4, column 1: \n" |
| + "abcdefghij\n" |
| + "^"); |
| // _ (in a___cd...) |
| - expect(_span(5, 2, map, file), "line 4, column 2 of .: \nabcdefghij"); |
| + expect(_span(5, 2, map, file), |
| + "line 4, column 2: \n" |
| + "abcdefghij\n" |
| + " ^"); |
| // _ (in a___cd...) |
| - expect(_span(5, 3, map, file), "line 4, column 2 of .: \nabcdefghij"); |
| + expect(_span(5, 3, map, file), |
| + "line 4, column 2: \n" |
| + "abcdefghij\n" |
| + " ^"); |
| // _ (in a___cd...) |
| - expect(_span(5, 4, map, file), "line 4, column 2 of .: \nabcdefghij"); |
| + expect(_span(5, 4, map, file), |
| + "line 4, column 2: \n" |
| + "abcdefghij\n" |
| + " ^"); |
| // c (in a___cd...) |
| - expect(_span(5, 5, map, file), "line 4, column 3 of .: \nabcdefghij"); |
| - expect(_span(6, 1, map, file), "line 5, column 1 of .: \nabcd*fghij"); |
| - expect(_span(6, 8, map, file), "line 5, column 1 of .: \nabcd*fghij"); |
| + expect(_span(5, 5, map, file), |
| + "line 4, column 3: \n" |
| + "abcdefghij\n" |
| + " ^"); |
| + expect(_span(6, 1, map, file), |
| + "line 5, column 1: \n" |
| + "abcd*fghij\n" |
| + "^"); |
| + expect(_span(6, 8, map, file), |
| + "line 5, column 1: \n" |
| + "abcd*fghij\n" |
| + "^"); |
| }); |
| } |
| String _span(int line, int column, Mapping map, SourceFile file) { |
| var span = map.spanFor(line - 1, column - 1, files: {'': file}); |
| - return span == null ? null : span.getLocationMessage('').trim(); |
| + return span == null ? null : span.message('').trim(); |
|
Siggi Cherem (dart-lang)
2014/07/31 21:01:38
mmm... seeing this test made me realize that 'mess
nweiz
2014/07/31 22:01:24
What's the point of formatting a message if it's n
|
| } |