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

Side by Side Diff: packages/source_span/test/span_test.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 4 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: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 span; 10 var span;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 ${colors.RED}foo bar${colors.NONE} 227 ${colors.RED}foo bar${colors.NONE}
228 ${colors.RED}^^^^^^^${colors.NONE}""")); 228 ${colors.RED}^^^^^^^${colors.NONE}"""));
229 }); 229 });
230 230
231 test("uses the given color if it's passed", () { 231 test("uses the given color if it's passed", () {
232 expect(span.message("oh no", color: colors.YELLOW), equals(""" 232 expect(span.message("oh no", color: colors.YELLOW), equals("""
233 line 1, column 6 of foo.dart: oh no 233 line 1, column 6 of foo.dart: oh no
234 ${colors.YELLOW}foo bar${colors.NONE} 234 ${colors.YELLOW}foo bar${colors.NONE}
235 ${colors.YELLOW}^^^^^^^${colors.NONE}""")); 235 ${colors.YELLOW}^^^^^^^${colors.NONE}"""));
236 }); 236 });
237 });
238 237
239 group("message() with context", () { 238 test("with context, underlines the right column", () {
240 var spanWithContext; 239 var spanWithContext = new SourceSpanWithContext(
241 setUp(() {
242 spanWithContext = new SourceSpanWithContext(
243 new SourceLocation(5, sourceUrl: "foo.dart"), 240 new SourceLocation(5, sourceUrl: "foo.dart"),
244 new SourceLocation(12, sourceUrl: "foo.dart"), 241 new SourceLocation(12, sourceUrl: "foo.dart"),
245 "foo bar", 242 "foo bar",
246 "-----foo bar-----"); 243 "-----foo bar-----");
247 });
248 244
249 test("underlines under the right column", () {
250 expect(spanWithContext.message("oh no", color: colors.YELLOW), equals(""" 245 expect(spanWithContext.message("oh no", color: colors.YELLOW), equals("""
251 line 1, column 6 of foo.dart: oh no 246 line 1, column 6 of foo.dart: oh no
252 -----${colors.YELLOW}foo bar${colors.NONE}----- 247 -----${colors.YELLOW}foo bar${colors.NONE}-----
253 ${colors.YELLOW}^^^^^^^${colors.NONE}""")); 248 ${colors.YELLOW}^^^^^^^${colors.NONE}"""));
254 }); 249 });
255
256 test("underlines correctly when text appears twice", () {
257 var span = new SourceSpanWithContext(
258 new SourceLocation(9, column: 9, sourceUrl: "foo.dart"),
259 new SourceLocation(12, column: 12, sourceUrl: "foo.dart"),
260 "foo",
261 "-----foo foo-----");
262 expect(span.message("oh no", color: colors.YELLOW), equals("""
263 line 1, column 10 of foo.dart: oh no
264 -----foo ${colors.YELLOW}foo${colors.NONE}-----
265 ${colors.YELLOW}^^^${colors.NONE}"""));
266 });
267
268 test("supports lines of preceeding context", () {
269 var span = new SourceSpanWithContext(
270 new SourceLocation(5, line: 3, column: 5, sourceUrl: "foo.dart"),
271 new SourceLocation(12, line: 3, column: 12, sourceUrl: "foo.dart"),
272 "foo bar",
273 "previous\nlines\n-----foo bar-----\nfollowing line\n");
274
275 expect(span.message("oh no", color: colors.YELLOW), equals("""
276 line 4, column 6 of foo.dart: oh no
277 previous
278 lines
279 -----${colors.YELLOW}foo bar${colors.NONE}-----
280 ${colors.YELLOW}^^^^^^^${colors.NONE}"""));
281 });
282 }); 250 });
283 251
284 group("compareTo()", () { 252 group("compareTo()", () {
285 test("sorts by start location first", () { 253 test("sorts by start location first", () {
286 var other = new SourceSpan( 254 var other = new SourceSpan(
287 new SourceLocation(6, sourceUrl: "foo.dart"), 255 new SourceLocation(6, sourceUrl: "foo.dart"),
288 new SourceLocation(14, sourceUrl: "foo.dart"), 256 new SourceLocation(14, sourceUrl: "foo.dart"),
289 "oo bar b"); 257 "oo bar b");
290 258
291 expect(span.compareTo(other), lessThan(0)); 259 expect(span.compareTo(other), lessThan(0));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 test("a different source URL isn't equal", () { 306 test("a different source URL isn't equal", () {
339 var other = new SourceSpan( 307 var other = new SourceSpan(
340 new SourceLocation(5, sourceUrl: "bar.dart"), 308 new SourceLocation(5, sourceUrl: "bar.dart"),
341 new SourceLocation(12, sourceUrl: "bar.dart"), 309 new SourceLocation(12, sourceUrl: "bar.dart"),
342 "foo bar"); 310 "foo bar");
343 311
344 expect(span, isNot(equals(other))); 312 expect(span, isNot(equals(other)));
345 }); 313 });
346 }); 314 });
347 } 315 }
OLDNEW
« no previous file with comments | « packages/source_span/test/highlight_test.dart ('k') | packages/source_span/test/utils_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698