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

Side by Side Diff: test/error_test.dart

Issue 1045533002: pkg/string_scanner: code format, expanded dependency constraint on unittest (Closed) Base URL: https://github.com/dart-lang/string_scanner.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
« no previous file with comments | « pubspec.yaml ('k') | test/string_scanner_test.dart » ('j') | 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 library string_scanner.error_test; 5 library string_scanner.error_test;
6 6
7 import 'package:string_scanner/string_scanner.dart'; 7 import 'package:string_scanner/string_scanner.dart';
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 9
10 import 'utils.dart'; 10 import 'utils.dart';
(...skipping 10 matching lines...) Expand all
21 test('supports an earlier match', () { 21 test('supports an earlier match', () {
22 var scanner = new StringScanner('foo bar baz'); 22 var scanner = new StringScanner('foo bar baz');
23 scanner.expect('foo '); 23 scanner.expect('foo ');
24 var match = scanner.lastMatch; 24 var match = scanner.lastMatch;
25 scanner.expect('bar'); 25 scanner.expect('bar');
26 expect(() => scanner.error('oh no!', match: match), 26 expect(() => scanner.error('oh no!', match: match),
27 throwsStringScannerException('foo ')); 27 throwsStringScannerException('foo '));
28 }); 28 });
29 29
30 test('supports a match on a previous line', () { 30 test('supports a match on a previous line', () {
31 var scanner = new StringScanner('foo bar baz\ndo re mi\nearth fire water') ; 31 var scanner =
32 new StringScanner('foo bar baz\ndo re mi\nearth fire water');
32 scanner.expect('foo bar baz\ndo '); 33 scanner.expect('foo bar baz\ndo ');
33 scanner.expect('re'); 34 scanner.expect('re');
34 var match = scanner.lastMatch; 35 var match = scanner.lastMatch;
35 scanner.expect(' mi\nearth '); 36 scanner.expect(' mi\nearth ');
36 expect(() => scanner.error('oh no!', match: match), 37 expect(() => scanner.error('oh no!', match: match),
37 throwsStringScannerException('re')); 38 throwsStringScannerException('re'));
38 }); 39 });
39 40
40 test('supports a multiline match', () { 41 test('supports a multiline match', () {
41 var scanner = new StringScanner('foo bar baz\ndo re mi\nearth fire water') ; 42 var scanner =
43 new StringScanner('foo bar baz\ndo re mi\nearth fire water');
42 scanner.expect('foo bar '); 44 scanner.expect('foo bar ');
43 scanner.expect('baz\ndo'); 45 scanner.expect('baz\ndo');
44 var match = scanner.lastMatch; 46 var match = scanner.lastMatch;
45 scanner.expect(' re mi'); 47 scanner.expect(' re mi');
46 expect(() => scanner.error('oh no!', match: match), 48 expect(() => scanner.error('oh no!', match: match),
47 throwsStringScannerException('baz\ndo')); 49 throwsStringScannerException('baz\ndo'));
48 }); 50 });
49 51
50 test('supports a match after position', () { 52 test('supports a match after position', () {
51 var scanner = new StringScanner('foo bar baz'); 53 var scanner = new StringScanner('foo bar baz');
(...skipping 22 matching lines...) Expand all
74 }); 76 });
75 77
76 test('supports an earlier position', () { 78 test('supports an earlier position', () {
77 var scanner = new StringScanner('foo bar baz'); 79 var scanner = new StringScanner('foo bar baz');
78 scanner.expect('foo '); 80 scanner.expect('foo ');
79 expect(() => scanner.error('oh no!', position: 1, length: 2), 81 expect(() => scanner.error('oh no!', position: 1, length: 2),
80 throwsStringScannerException('oo')); 82 throwsStringScannerException('oo'));
81 }); 83 });
82 84
83 test('supports a position on a previous line', () { 85 test('supports a position on a previous line', () {
84 var scanner = new StringScanner('foo bar baz\ndo re mi\nearth fire water') ; 86 var scanner =
87 new StringScanner('foo bar baz\ndo re mi\nearth fire water');
85 scanner.expect('foo bar baz\ndo re mi\nearth'); 88 scanner.expect('foo bar baz\ndo re mi\nearth');
86 expect(() => scanner.error('oh no!', position: 15, length: 2), 89 expect(() => scanner.error('oh no!', position: 15, length: 2),
87 throwsStringScannerException('re')); 90 throwsStringScannerException('re'));
88 }); 91 });
89 92
90 test('supports a multiline length', () { 93 test('supports a multiline length', () {
91 var scanner = new StringScanner('foo bar baz\ndo re mi\nearth fire water') ; 94 var scanner =
95 new StringScanner('foo bar baz\ndo re mi\nearth fire water');
92 scanner.expect('foo bar baz\ndo re mi\nearth'); 96 scanner.expect('foo bar baz\ndo re mi\nearth');
93 expect(() => scanner.error('oh no!', position: 8, length: 8), 97 expect(() => scanner.error('oh no!', position: 8, length: 8),
94 throwsStringScannerException('baz\ndo r')); 98 throwsStringScannerException('baz\ndo r'));
95 }); 99 });
96 100
97 test('supports a position after the current one', () { 101 test('supports a position after the current one', () {
98 var scanner = new StringScanner('foo bar baz'); 102 var scanner = new StringScanner('foo bar baz');
99 expect(() => scanner.error('oh no!', position: 4, length: 3), 103 expect(() => scanner.error('oh no!', position: 4, length: 3),
100 throwsStringScannerException('bar')); 104 throwsStringScannerException('bar'));
101 }); 105 });
(...skipping 12 matching lines...) Expand all
114 scanner.scan('foo'); 118 scanner.scan('foo');
115 }); 119 });
116 120
117 test("if match is passed with position", () { 121 test("if match is passed with position", () {
118 expect( 122 expect(
119 () => scanner.error("oh no!", match: scanner.lastMatch, position: 1), 123 () => scanner.error("oh no!", match: scanner.lastMatch, position: 1),
120 throwsArgumentError); 124 throwsArgumentError);
121 }); 125 });
122 126
123 test("if match is passed with length", () { 127 test("if match is passed with length", () {
124 expect( 128 expect(() => scanner.error("oh no!", match: scanner.lastMatch, length: 1),
125 () => scanner.error("oh no!", match: scanner.lastMatch, length: 1),
126 throwsArgumentError); 129 throwsArgumentError);
127 }); 130 });
128 131
129 test("if position is negative", () { 132 test("if position is negative", () {
130 expect(() => scanner.error("oh no!", position: -1), throwsArgumentError); 133 expect(() => scanner.error("oh no!", position: -1), throwsArgumentError);
131 }); 134 });
132 135
133 test("if position is outside the string", () { 136 test("if position is outside the string", () {
134 expect(() => scanner.error("oh no!", position: 100), throwsArgumentError); 137 expect(() => scanner.error("oh no!", position: 100), throwsArgumentError);
135 }); 138 });
136 139
137 test("if position + length is outside the string", () { 140 test("if position + length is outside the string", () {
138 expect(() => scanner.error("oh no!", position: 7, length: 7), 141 expect(() => scanner.error("oh no!", position: 7, length: 7),
139 throwsArgumentError); 142 throwsArgumentError);
140 }); 143 });
141 144
142 test("if length is negative", () { 145 test("if length is negative", () {
143 expect(() => scanner.error("oh no!", length: -1), throwsArgumentError); 146 expect(() => scanner.error("oh no!", length: -1), throwsArgumentError);
144 }); 147 });
145 }); 148 });
146 } 149 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | test/string_scanner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698