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

Side by Side Diff: test/file_test.dart

Issue 1039603004: Fix FileSpan.context to include FileSpan.text. (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
« pubspec.yaml ('K') | « 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: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 7
8 main() { 8 main() {
9 var file; 9 var file;
10 setUp(() { 10 setUp(() {
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 expect(span.end, equals(location)); 246 expect(span.end, equals(location));
247 expect(span.text, isEmpty); 247 expect(span.text, isEmpty);
248 }); 248 });
249 }); 249 });
250 250
251 group("FileSpan", () { 251 group("FileSpan", () {
252 test("text returns a substring of the source", () { 252 test("text returns a substring of the source", () {
253 expect(file.span(8, 15).text, equals("baz\nwhi")); 253 expect(file.span(8, 15).text, equals("baz\nwhi"));
254 }); 254 });
255 255
256 test("context contains the span's text", () {
257 var span = file.span(8, 15);
258 expect(span.context.contains(span.text), isTrue);
259 expect(span.context, equals('foo bar baz\nwhiz bang boom\n'));
260 });
261
256 group("union()", () { 262 group("union()", () {
257 var span; 263 var span;
258 setUp(() { 264 setUp(() {
259 span = file.span(5, 12); 265 span = file.span(5, 12);
260 }); 266 });
261 267
262 test("works with a preceding adjacent span", () { 268 test("works with a preceding adjacent span", () {
263 var other = file.span(0, 5); 269 var other = file.span(0, 5);
264 var result = span.union(other); 270 var result = span.union(other);
265 expect(result.start, equals(other.start)); 271 expect(result.start, equals(other.start));
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 var other = file.span(7, 10); 366 var other = file.span(7, 10);
361 expect(span.expand(other), equals(span)); 367 expect(span.expand(other), equals(span));
362 }); 368 });
363 369
364 test("works with an external overlapping span", () { 370 test("works with an external overlapping span", () {
365 var other = file.span(0, 16); 371 var other = file.span(0, 16);
366 expect(span.expand(other), equals(other)); 372 expect(span.expand(other), equals(other));
367 }); 373 });
368 }); 374 });
369 }); 375 });
370 } 376 }
OLDNEW
« pubspec.yaml ('K') | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698