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

Side by Side Diff: test/file_message_test.dart

Issue 1028813002: Introduce span with line 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 unified diff | Download patch
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:unittest/unittest.dart'; 5 import 'package:unittest/unittest.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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 in an empty file", () { 62 test("works for a point span in an empty file", () {
63 expect(new SourceFile("").location(0).pointSpan().message("oh no"), 63 expect(new SourceFile("").location(0).pointSpan().message("oh no"), equals(
64 equals(""" 64 """
65 line 1, column 1: oh no 65 line 1, column 1: oh no
66 66
67 ^""")); 67 ^"""));
68 }); 68 });
69 69
70 test("works for a single-line file without a newline", () { 70 test("works for a single-line file without a newline", () {
71 expect(new SourceFile("foo bar").span(0, 7).message("oh no"), 71 expect(new SourceFile("foo bar").span(0, 7).message("oh no"), equals("""
72 equals("""
73 line 1, column 1: oh no 72 line 1, column 1: oh no
74 foo bar 73 foo bar
75 ^^^^^^^""")); 74 ^^^^^^^"""));
76 }); 75 });
77 76
78 group("colors", () { 77 group("colors", () {
79 test("doesn't colorize if color is false", () { 78 test("doesn't colorize if color is false", () {
80 expect(file.span(4, 7).message("oh no", color: false), equals(""" 79 expect(file.span(4, 7).message("oh no", color: false), equals("""
81 line 1, column 5 of foo.dart: oh no 80 line 1, column 5 of foo.dart: oh no
82 foo bar baz 81 foo bar baz
83 ^^^""")); 82 ^^^"""));
84 }); 83 });
85 84
86 test("colorizes if color is true", () { 85 test("colorizes if color is true", () {
87 expect(file.span(4, 7).message("oh no", color: true), equals(""" 86 expect(file.span(4, 7).message("oh no", color: true), equals("""
88 line 1, column 5 of foo.dart: oh no 87 line 1, column 5 of foo.dart: oh no
89 foo ${colors.RED}bar${colors.NONE} baz 88 foo ${colors.RED}bar${colors.NONE} baz
90 ${colors.RED}^^^${colors.NONE}""")); 89 ${colors.RED}^^^${colors.NONE}"""));
91 }); 90 });
92 91
93 test("uses the given color if it's passed", () { 92 test("uses the given color if it's passed", () {
94 expect(file.span(4, 7).message("oh no", color: colors.YELLOW), equals(""" 93 expect(file.span(4, 7).message("oh no", color: colors.YELLOW), equals("""
95 line 1, column 5 of foo.dart: oh no 94 line 1, column 5 of foo.dart: oh no
96 foo ${colors.YELLOW}bar${colors.NONE} baz 95 foo ${colors.YELLOW}bar${colors.NONE} baz
97 ${colors.YELLOW}^^^${colors.NONE}""")); 96 ${colors.YELLOW}^^^${colors.NONE}"""));
98 }); 97 });
99 }); 98 });
100 } 99 }
OLDNEW
« lib/src/span.dart ('K') | « pubspec.yaml ('k') | test/file_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698