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

Unified Diff: tests/compiler/dart2js/location_collector_test.dart

Issue 2788373002: Add Source.getTextLine and use it to display source snippets in error messages. (Closed)
Patch Set: dartfmt Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: tests/compiler/dart2js/location_collector_test.dart
diff --git a/tests/compiler/dart2js/line_column_provider_test.dart b/tests/compiler/dart2js/location_collector_test.dart
similarity index 77%
rename from tests/compiler/dart2js/line_column_provider_test.dart
rename to tests/compiler/dart2js/location_collector_test.dart
index ccdda3b3623a49f7a865b5b7625ac51cf9b70be6..d35f8b1b35eecf776edc21dbf07442f4142014c0 100644
--- a/tests/compiler/dart2js/line_column_provider_test.dart
+++ b/tests/compiler/dart2js/location_collector_test.dart
@@ -2,18 +2,19 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-// Unittest for the [LineColumnCollector].
+// Unittest for the [LocationCollector].
-import 'package:expect/expect.dart';
import 'package:compiler/src/io/code_output.dart';
-import 'package:compiler/src/io/line_column_provider.dart';
+import 'package:compiler/src/io/location_provider.dart';
+import 'package:expect/expect.dart';
+import 'package:kernel/ast.dart' show Location;
import 'output_collector.dart';
test(List events, Map<int, List<int>> expectedPositions) {
BufferedOutputSink sink = new BufferedOutputSink();
- LineColumnProvider lineColumnProvider = new LineColumnCollector();
- CodeOutput output = new StreamCodeOutput(sink, [lineColumnProvider]);
+ LocationProvider locationProvider = new LocationCollector();
+ CodeOutput output = new StreamCodeOutput(sink, [locationProvider]);
for (var event in events) {
if (event is String) {
output.add(event);
@@ -26,26 +27,27 @@ test(List events, Map<int, List<int>> expectedPositions) {
expectedPositions.forEach((int offset, List<int> expectedPosition) {
if (expectedPosition == null) {
Expect.throws(
- () => lineColumnProvider.getLine(offset),
+ () => locationProvider.getLocation(offset),
(e) => true,
'Expected out-of-bounds offset: $offset\n'
'text:"""${sink.text}"""\n'
- 'lineColumnProvider:$lineColumnProvider');
+ 'locationProvider:$locationProvider');
} else {
- int line = lineColumnProvider.getLine(offset);
- int column = lineColumnProvider.getColumn(line, offset);
+ Location location = locationProvider.getLocation(offset);
+ int line = location.line - 1;
+ int column = location.column - 1;
Expect.equals(
expectedPosition[0],
line,
'Unexpected result: $offset -> $expectedPosition = [$line,$column]\n'
'text:"""${sink.text}"""\n'
- 'lineColumnProvider:$lineColumnProvider');
+ 'locationProvider:$locationProvider');
Expect.equals(
expectedPosition[1],
column,
'Unexpected result: $offset -> $expectedPosition = [$line,$column]\n'
'text:"""${sink.text}"""\n'
- 'lineColumnProvider:$lineColumnProvider');
+ 'locationProvider:$locationProvider');
}
});
}

Powered by Google App Engine
This is Rietveld 408576698