OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |