Index: test/span_test.dart |
diff --git a/test/span_test.dart b/test/span_test.dart |
index c62753b1a59d66b54c5901deb9cd5155559b068e..08154bd67eda3a9ac7af3efd73ec3ff55de7bb4c 100644 |
--- a/test/span_test.dart |
+++ b/test/span_test.dart |
@@ -36,6 +36,22 @@ main() { |
}); |
}); |
+ group('for new SourceSpanWithContext()', () { |
+ test('contextLine must contain text', () { |
+ var start = new SourceLocation(2); |
+ var end = new SourceLocation(5); |
+ expect(() => new SourceSpanWithContext( |
+ start, end, "abc", "--axc--"), throwsArgumentError); |
+ }); |
+ |
+ test('text starts at start.column in contentLine', () { |
+ var start = new SourceLocation(3); |
+ var end = new SourceLocation(5); |
+ expect(() => new SourceSpanWithContext( |
+ start, end, "abc", "--abc--"), throwsArgumentError); |
+ }); |
+ }); |
+ |
group('for union()', () { |
test('source URLs must match', () { |
var other = new SourceSpan( |
@@ -178,15 +194,33 @@ foo bar |
expect(span.message("oh no", color: true), |
equals(""" |
line 1, column 6 of foo.dart: oh no |
-${colors.RED}foo bar |
-^^^^^^^${colors.NONE}""")); |
+${colors.RED}foo bar${colors.NONE} |
+${colors.RED}^^^^^^^${colors.NONE}""")); |
}); |
test("uses the given color if it's passed", () { |
expect(span.message("oh no", color: colors.YELLOW), equals(""" |
line 1, column 6 of foo.dart: oh no |
-${colors.YELLOW}foo bar |
-^^^^^^^${colors.NONE}""")); |
+${colors.YELLOW}foo bar${colors.NONE} |
+${colors.YELLOW}^^^^^^^${colors.NONE}""")); |
+ }); |
+ }); |
+ |
+ group("message() with context", () { |
+ var spanWithContext; |
+ setUp(() { |
+ spanWithContext = new SourceSpanWithContext( |
+ new SourceLocation(5, sourceUrl: "foo.dart"), |
+ new SourceLocation(12, sourceUrl: "foo.dart"), |
+ "foo bar", |
+ "-----foo bar-----"); |
+ }); |
+ |
+ test("underlines under the right column", () { |
+ expect(spanWithContext.message("oh no", color: colors.YELLOW), equals(""" |
+line 1, column 6 of foo.dart: oh no |
+-----${colors.YELLOW}foo bar${colors.NONE}----- |
+ ${colors.YELLOW}^^^^^^^${colors.NONE}""")); |
}); |
}); |