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

Unified Diff: packages/source_span/test/highlight_test.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 5 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
« no previous file with comments | « packages/source_span/test/file_message_test.dart ('k') | packages/source_span/test/span_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/source_span/test/highlight_test.dart
diff --git a/packages/source_span/test/file_message_test.dart b/packages/source_span/test/highlight_test.dart
similarity index 51%
rename from packages/source_span/test/file_message_test.dart
rename to packages/source_span/test/highlight_test.dart
index 5935c58820e76a8ba7ea42d2c2ca2bdb51b19c4f..74faed52a820a9a8f48b21d53afef44658557d2c 100644
--- a/packages/source_span/test/file_message_test.dart
+++ b/packages/source_span/test/highlight_test.dart
@@ -13,86 +13,104 @@ main() {
foo bar baz
whiz bang boom
zip zap zop
-""", url: "foo.dart");
+""");
});
test("points to the span in the source", () {
- expect(file.span(4, 7).message("oh no"), equals("""
-line 1, column 5 of foo.dart: oh no
+ expect(file.span(4, 7).highlight(), equals("""
foo bar baz
^^^"""));
});
test("gracefully handles a missing source URL", () {
var span = new SourceFile("foo bar baz").span(4, 7);
- expect(span.message("oh no"), equals("""
-line 1, column 5: oh no
+ expect(span.highlight(), equals("""
foo bar baz
^^^"""));
});
test("highlights the first line of a multiline span", () {
- expect(file.span(4, 20).message("oh no"), equals("""
-line 1, column 5 of foo.dart: oh no
+ expect(file.span(4, 20).highlight(), equals("""
foo bar baz
^^^^^^^^"""));
});
test("works for a point span", () {
- expect(file.location(4).pointSpan().message("oh no"), equals("""
-line 1, column 5 of foo.dart: oh no
+ expect(file.location(4).pointSpan().highlight(), equals("""
foo bar baz
^"""));
});
test("works for a point span at the end of a line", () {
- expect(file.location(11).pointSpan().message("oh no"), equals("""
-line 1, column 12 of foo.dart: oh no
+ expect(file.location(11).pointSpan().highlight(), equals("""
foo bar baz
^"""));
});
test("works for a point span at the end of the file", () {
- expect(file.location(38).pointSpan().message("oh no"), equals("""
-line 3, column 12 of foo.dart: oh no
+ expect(file.location(38).pointSpan().highlight(), equals("""
+zip zap zop
+ ^"""));
+ });
+
+ test("works for a point span at the end of the file with no trailing newline",
+ () {
+ file = new SourceFile("zip zap zop");
+ expect(file.location(11).pointSpan().highlight(), equals("""
zip zap zop
^"""));
});
test("works for a point span in an empty file", () {
- expect(new SourceFile("").location(0).pointSpan().message("oh no"),
+ expect(new SourceFile("").location(0).pointSpan().highlight(),
equals("""
-line 1, column 1: oh no
^"""));
});
test("works for a single-line file without a newline", () {
- expect(new SourceFile("foo bar").span(0, 7).message("oh no"),
+ expect(new SourceFile("foo bar").span(0, 7).highlight(),
equals("""
-line 1, column 1: oh no
foo bar
^^^^^^^"""));
});
+ test("emits tabs for tabs", () {
+ expect(new SourceFile(" \t \t\tfoo bar").span(5, 8).highlight(),
+ equals("""
+ \t \t\tfoo bar
+ \t \t\t^^^"""));
+ });
+
+ test("supports lines of preceding context", () {
+ var span = new SourceSpanWithContext(
+ new SourceLocation(5, line: 3, column: 5, sourceUrl: "foo.dart"),
+ new SourceLocation(12, line: 3, column: 12, sourceUrl: "foo.dart"),
+ "foo bar",
+ "previous\nlines\n-----foo bar-----\nfollowing line\n");
+
+ expect(span.highlight(color: colors.YELLOW), equals("""
+previous
+lines
+-----${colors.YELLOW}foo bar${colors.NONE}-----
+ ${colors.YELLOW}^^^^^^^${colors.NONE}"""));
+ });
+
group("colors", () {
test("doesn't colorize if color is false", () {
- expect(file.span(4, 7).message("oh no", color: false), equals("""
-line 1, column 5 of foo.dart: oh no
+ expect(file.span(4, 7).highlight(color: false), equals("""
foo bar baz
^^^"""));
});
test("colorizes if color is true", () {
- expect(file.span(4, 7).message("oh no", color: true), equals("""
-line 1, column 5 of foo.dart: oh no
+ expect(file.span(4, 7).highlight(color: true), equals("""
foo ${colors.RED}bar${colors.NONE} baz
${colors.RED}^^^${colors.NONE}"""));
});
test("uses the given color if it's passed", () {
- expect(file.span(4, 7).message("oh no", color: colors.YELLOW), equals("""
-line 1, column 5 of foo.dart: oh no
+ expect(file.span(4, 7).highlight(color: colors.YELLOW), equals("""
foo ${colors.YELLOW}bar${colors.NONE} baz
${colors.YELLOW}^^^${colors.NONE}"""));
});
« no previous file with comments | « packages/source_span/test/file_message_test.dart ('k') | packages/source_span/test/span_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698