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

Side by Side Diff: packages/dart_style/test/source_code_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library dart_style.test.source_code_test;
6
7 import 'package:test/test.dart';
8
9 import 'package:dart_style/dart_style.dart';
10
11 void main() {
12 var selection =
13 new SourceCode("123456;", selectionStart: 3, selectionLength: 2);
14 var noSelection = new SourceCode("123456;");
15
16 group('constructor', () {
17 test('throws on negative start', () {
18 expect(() {
19 new SourceCode("12345;", selectionStart: -1, selectionLength: 0);
20 }, throwsArgumentError);
21 });
22
23 test('throws on out of bounds start', () {
24 expect(() {
25 new SourceCode("12345;", selectionStart: 7, selectionLength: 0);
26 }, throwsArgumentError);
27 });
28
29 test('throws on negative length', () {
30 expect(() {
31 new SourceCode("12345;", selectionStart: 1, selectionLength: -1);
32 }, throwsArgumentError);
33 });
34
35 test('throws on out of bounds length', () {
36 expect(() {
37 new SourceCode("12345;", selectionStart: 2, selectionLength: 5);
38 }, throwsArgumentError);
39 });
40
41 test('throws is start is null and length is not', () {
42 expect(() {
43 new SourceCode("12345;", selectionStart: 0);
44 }, throwsArgumentError);
45 });
46
47 test('throws is length is null and start is not', () {
48 expect(() {
49 new SourceCode("12345;", selectionLength: 1);
50 }, throwsArgumentError);
51 });
52 });
53
54 group('textBeforeSelection', () {
55 test('gets substring before selection', () {
56 expect(selection.textBeforeSelection, equals("123"));
57 });
58
59 test('gets entire string if no selection', () {
60 expect(noSelection.textBeforeSelection, equals("123456;"));
61 });
62 });
63
64 group('selectedText', () {
65 test('gets selection substring', () {
66 expect(selection.selectedText, equals("45"));
67 });
68
69 test('gets empty string if no selection', () {
70 expect(noSelection.selectedText, equals(""));
71 });
72 });
73
74 group('textAfterSelection', () {
75 test('gets substring after selection', () {
76 expect(selection.textAfterSelection, equals("6;"));
77 });
78
79 test('gets empty string if no selection', () {
80 expect(noSelection.textAfterSelection, equals(""));
81 });
82 });
83 }
OLDNEW
« no previous file with comments | « packages/dart_style/test/selections/selections.unit ('k') | packages/dart_style/test/splitting/._arrows.unit » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698