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

Unified Diff: test/span_test.dart

Issue 1041163005: Support multiple occurrences of text in context (Closed) Base URL: git@github.com:dart-lang/source_span.git@master
Patch Set: Created 5 years, 9 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 | « pubspec.yaml ('k') | test/utils_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/span_test.dart
diff --git a/test/span_test.dart b/test/span_test.dart
index 39b0b9433ddc779998867a97ec8ebd60f77e7575..2657f5ffdbaea00318b97b9c05abcbbfbcf67627 100644
--- a/test/span_test.dart
+++ b/test/span_test.dart
@@ -65,6 +65,21 @@ main() {
new SourceSpanWithContext(start, end, "abc", "\n---abc--");
new SourceSpanWithContext(start, end, "abc", "\n\n---abc--");
});
+
+ test('text can occur multiple times in context', () {
+ var start1 = new SourceLocation(4, line: 55, column: 2);
+ var end1 = new SourceLocation(7, line: 55, column: 5);
+ var start2 = new SourceLocation(4, line: 55, column: 8);
+ var end2 = new SourceLocation(7, line: 55, column: 11);
+ new SourceSpanWithContext(start1, end1, "abc", "--abc---abc--\n");
+ new SourceSpanWithContext(start1, end1, "abc", "--abc--abc--\n");
+ new SourceSpanWithContext(start2, end2, "abc", "--abc---abc--\n");
+ new SourceSpanWithContext(start2, end2, "abc", "---abc--abc--\n");
+ expect(() => new SourceSpanWithContext(
+ start1, end1, "abc", "---abc--abc--\n"), throwsArgumentError);
+ expect(() => new SourceSpanWithContext(
+ start2, end2, "abc", "--abc--abc--\n"), throwsArgumentError);
+ });
});
group('for union()', () {
@@ -238,6 +253,18 @@ line 1, column 6 of foo.dart: oh no
${colors.YELLOW}^^^^^^^${colors.NONE}"""));
});
+ test("underlines correctly when text appears twice", () {
+ var span = new SourceSpanWithContext(
+ new SourceLocation(9, column: 9, sourceUrl: "foo.dart"),
+ new SourceLocation(12, column: 12, sourceUrl: "foo.dart"),
+ "foo",
+ "-----foo foo-----");
+ expect(span.message("oh no", color: colors.YELLOW), equals("""
+line 1, column 10 of foo.dart: oh no
+-----foo ${colors.YELLOW}foo${colors.NONE}-----
+ ${colors.YELLOW}^^^${colors.NONE}"""));
+ });
+
test("supports lines of preceeding context", () {
var span = new SourceSpanWithContext(
new SourceLocation(5, line: 3, column: 5, sourceUrl: "foo.dart"),
« no previous file with comments | « pubspec.yaml ('k') | test/utils_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698