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

Side by Side Diff: test/file_message_test.dart

Issue 2056913002: Fix a message bug. (Closed) Base URL: git@github.com:dart-lang/source_span@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'package:test/test.dart'; 5 import 'package:test/test.dart';
6 import 'package:source_span/source_span.dart'; 6 import 'package:source_span/source_span.dart';
7 import 'package:source_span/src/colors.dart' as colors; 7 import 'package:source_span/src/colors.dart' as colors;
8 8
9 main() { 9 main() {
10 var file; 10 var file;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 ^""")); 52 ^"""));
53 }); 53 });
54 54
55 test("works for a point span at the end of the file", () { 55 test("works for a point span at the end of the file", () {
56 expect(file.location(38).pointSpan().message("oh no"), equals(""" 56 expect(file.location(38).pointSpan().message("oh no"), equals("""
57 line 3, column 12 of foo.dart: oh no 57 line 3, column 12 of foo.dart: oh no
58 zip zap zop 58 zip zap zop
59 ^""")); 59 ^"""));
60 }); 60 });
61 61
62 test("works for a point span at the end of the file with no trailing newline",
63 () {
64 file = new SourceFile("zip zap zop");
65 expect(file.location(11).pointSpan().message("oh no"), equals("""
66 line 1, column 12: oh no
67 zip zap zop
68 ^"""));
69 });
70
62 test("works for a point span in an empty file", () { 71 test("works for a point span in an empty file", () {
63 expect(new SourceFile("").location(0).pointSpan().message("oh no"), 72 expect(new SourceFile("").location(0).pointSpan().message("oh no"),
64 equals(""" 73 equals("""
65 line 1, column 1: oh no 74 line 1, column 1: oh no
66 75
67 ^""")); 76 ^"""));
68 }); 77 });
69 78
70 test("works for a single-line file without a newline", () { 79 test("works for a single-line file without a newline", () {
71 expect(new SourceFile("foo bar").span(0, 7).message("oh no"), 80 expect(new SourceFile("foo bar").span(0, 7).message("oh no"),
(...skipping 19 matching lines...) Expand all
91 }); 100 });
92 101
93 test("uses the given color if it's passed", () { 102 test("uses the given color if it's passed", () {
94 expect(file.span(4, 7).message("oh no", color: colors.YELLOW), equals(""" 103 expect(file.span(4, 7).message("oh no", color: colors.YELLOW), equals("""
95 line 1, column 5 of foo.dart: oh no 104 line 1, column 5 of foo.dart: oh no
96 foo ${colors.YELLOW}bar${colors.NONE} baz 105 foo ${colors.YELLOW}bar${colors.NONE} baz
97 ${colors.YELLOW}^^^${colors.NONE}""")); 106 ${colors.YELLOW}^^^${colors.NONE}"""));
98 }); 107 });
99 }); 108 });
100 } 109 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698