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

Unified Diff: tests/compiler/dart2js/message_span_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/message_span_test.dart
diff --git a/tests/compiler/dart2js/message_span_test.dart b/tests/compiler/dart2js/message_span_test.dart
index 57dbddb109696580c2d2ab788fb28795948e4b48..f90ae46d91dfeec1b94dc75ae9c24bd847d788d6 100644
--- a/tests/compiler/dart2js/message_span_test.dart
+++ b/tests/compiler/dart2js/message_span_test.dart
@@ -2,6 +2,7 @@
// 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.
+import 'dart:convert' show JSON, UTF8;
import 'package:async_helper/async_helper.dart';
import 'package:compiler/src/commandline_options.dart';
import 'package:compiler/src/diagnostics/messages.dart';
@@ -175,12 +176,17 @@ main() {
// Remove `filename:line:column:` and message.
String strippedLocationMessage = locationMessage
.substring(locationMessage.indexOf(MARKER) + MARKER.length + 1);
+ // Using JSON.encode to add string quotes and backslashes.
+ String expected = JSON.encode(
+ UTF8.decode(expectedSpanText.codeUnits, allowMalformed: true));
+ String actual = JSON.encode(UTF8
+ .decode(strippedLocationMessage.codeUnits, allowMalformed: true));
Expect.equals(
expectedSpanText,
strippedLocationMessage,
"Unexpected span for ${message.messageKind} in\n${test.code}"
- "\nExpected:${expectedSpanText.codeUnits}"
- "\nActual :${strippedLocationMessage.codeUnits}");
+ "\nExpected: $expected"
+ "\nActual : $actual");
kindToSpan.remove(message.messageKind);
}
}

Powered by Google App Engine
This is Rietveld 408576698