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

Side by Side 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, 8 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 span; 10 var span;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 start, end, "abc", "\n--abc--"), throwsArgumentError); 58 start, end, "abc", "\n--abc--"), throwsArgumentError);
59 expect(() => new SourceSpanWithContext( 59 expect(() => new SourceSpanWithContext(
60 start, end, "abc", "\n----abc--"), throwsArgumentError); 60 start, end, "abc", "\n----abc--"), throwsArgumentError);
61 expect(() => new SourceSpanWithContext( 61 expect(() => new SourceSpanWithContext(
62 start, end, "abc", "\n\n--abc--"), throwsArgumentError); 62 start, end, "abc", "\n\n--abc--"), throwsArgumentError);
63 63
64 // However, these are valid: 64 // However, these are valid:
65 new SourceSpanWithContext(start, end, "abc", "\n---abc--"); 65 new SourceSpanWithContext(start, end, "abc", "\n---abc--");
66 new SourceSpanWithContext(start, end, "abc", "\n\n---abc--"); 66 new SourceSpanWithContext(start, end, "abc", "\n\n---abc--");
67 }); 67 });
68
69 test('text can occur multiple times in context', () {
70 var start1 = new SourceLocation(4, line: 55, column: 2);
71 var end1 = new SourceLocation(7, line: 55, column: 5);
72 var start2 = new SourceLocation(4, line: 55, column: 8);
73 var end2 = new SourceLocation(7, line: 55, column: 11);
74 new SourceSpanWithContext(start1, end1, "abc", "--abc---abc--\n");
75 new SourceSpanWithContext(start1, end1, "abc", "--abc--abc--\n");
76 new SourceSpanWithContext(start2, end2, "abc", "--abc---abc--\n");
77 new SourceSpanWithContext(start2, end2, "abc", "---abc--abc--\n");
78 expect(() => new SourceSpanWithContext(
79 start1, end1, "abc", "---abc--abc--\n"), throwsArgumentError);
80 expect(() => new SourceSpanWithContext(
81 start2, end2, "abc", "--abc--abc--\n"), throwsArgumentError);
82 });
68 }); 83 });
69 84
70 group('for union()', () { 85 group('for union()', () {
71 test('source URLs must match', () { 86 test('source URLs must match', () {
72 var other = new SourceSpan( 87 var other = new SourceSpan(
73 new SourceLocation(12, sourceUrl: "bar.dart"), 88 new SourceLocation(12, sourceUrl: "bar.dart"),
74 new SourceLocation(13, sourceUrl: "bar.dart"), 89 new SourceLocation(13, sourceUrl: "bar.dart"),
75 "_"); 90 "_");
76 91
77 expect(() => span.union(other), throwsArgumentError); 92 expect(() => span.union(other), throwsArgumentError);
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 test("a different source URL isn't equal", () { 326 test("a different source URL isn't equal", () {
312 var other = new SourceSpan( 327 var other = new SourceSpan(
313 new SourceLocation(5, sourceUrl: "bar.dart"), 328 new SourceLocation(5, sourceUrl: "bar.dart"),
314 new SourceLocation(12, sourceUrl: "bar.dart"), 329 new SourceLocation(12, sourceUrl: "bar.dart"),
315 "foo bar"); 330 "foo bar");
316 331
317 expect(span, isNot(equals(other))); 332 expect(span, isNot(equals(other)));
318 }); 333 });
319 }); 334 });
320 } 335 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698