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

Side by Side Diff: pkg/args/test/args_test.dart

Issue 11575043: Convert the small packages in pkg to use "package:". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/fixnum/test/int_32_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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 args_test; 5 library args_test;
6 6
7 import '../../../pkg/unittest/lib/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8
9 import 'package:args/args.dart'; 8 import 'package:args/args.dart';
10 9
11 main() { 10 main() {
12 group('ArgParser.addFlag()', () { 11 group('ArgParser.addFlag()', () {
13 test('throws ArgumentError if the flag already exists', () { 12 test('throws ArgumentError if the flag already exists', () {
14 var parser = new ArgParser(); 13 var parser = new ArgParser();
15 parser.addFlag('foo'); 14 parser.addFlag('foo');
16 throwsIllegalArg(() => parser.addFlag('foo')); 15 throwsIllegalArg(() => parser.addFlag('foo'));
17 }); 16 });
18 17
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 }); 180 });
182 181
183 test('are invoked even if the option is not present', () { 182 test('are invoked even if the option is not present', () {
184 var a = 'not called'; 183 var a = 'not called';
185 var parser = new ArgParser(); 184 var parser = new ArgParser();
186 parser.addOption('a', callback: (value) => a = value); 185 parser.addOption('a', callback: (value) => a = value);
187 186
188 var args = parser.parse([]); 187 var args = parser.parse([]);
189 expect(a, isNull); 188 expect(a, isNull);
190 }); 189 });
191 190
192 test('for multiple present, allowMultiple, options are invoked with ' 191 test('for multiple present, allowMultiple, options are invoked with '
193 'value as a list', () { 192 'value as a list', () {
194 var a; 193 var a;
195 var parser = new ArgParser(); 194 var parser = new ArgParser();
196 parser.addOption('a', allowMultiple: true, 195 parser.addOption('a', allowMultiple: true,
197 callback: (value) => a = value); 196 callback: (value) => a = value);
198 197
199 var args = parser.parse(['--a=v', '--a=x']); 198 var args = parser.parse(['--a=v', '--a=x']);
200 expect(a, equals(['v', 'x'])); 199 expect(a, equals(['v', 'x']));
201 }); 200 });
202 201
203 test('for single present, allowMultiple, options are invoked with ' 202 test('for single present, allowMultiple, options are invoked with '
204 ' value as a single element list', () { 203 ' value as a single element list', () {
205 var a; 204 var a;
206 var parser = new ArgParser(); 205 var parser = new ArgParser();
207 parser.addOption('a', allowMultiple: true, 206 parser.addOption('a', allowMultiple: true,
208 callback: (value) => a = value); 207 callback: (value) => a = value);
209 208
210 var args = parser.parse(['--a=v']); 209 var args = parser.parse(['--a=v']);
211 expect(a, equals(['v'])); 210 expect(a, equals(['v']));
212 }); 211 });
213 212
214 test('for absent, allowMultiple, options are invoked with default ' 213 test('for absent, allowMultiple, options are invoked with default '
215 'value as a list.', () { 214 'value as a list.', () {
216 var a; 215 var a;
217 var parser = new ArgParser(); 216 var parser = new ArgParser();
218 parser.addOption('a', allowMultiple: true, defaultsTo: 'v', 217 parser.addOption('a', allowMultiple: true, defaultsTo: 'v',
219 callback: (value) => a = value); 218 callback: (value) => a = value);
220 219
221 var args = parser.parse([]); 220 var args = parser.parse([]);
222 expect(a, equals(['v'])); 221 expect(a, equals(['v']));
223 }); 222 });
224 223
225 test('for absent, allowMultiple, options are invoked with value ' 224 test('for absent, allowMultiple, options are invoked with value '
226 'as an empty list.', () { 225 'as an empty list.', () {
227 var a; 226 var a;
228 var parser = new ArgParser(); 227 var parser = new ArgParser();
229 parser.addOption('a', allowMultiple: true, 228 parser.addOption('a', allowMultiple: true,
230 callback: (value) => a = value); 229 callback: (value) => a = value);
231 230
232 var args = parser.parse([]); 231 var args = parser.parse([]);
233 expect(a, isEmpty); 232 expect(a, isEmpty);
234 }); 233 });
235 }); 234 });
236 235
237 group('abbreviations', () { 236 group('abbreviations', () {
238 test('are parsed with a preceding "-"', () { 237 test('are parsed with a preceding "-"', () {
239 var parser = new ArgParser(); 238 var parser = new ArgParser();
240 parser.addFlag('arg', abbr: 'a'); 239 parser.addFlag('arg', abbr: 'a');
241 240
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 throw new ArgumentError( 701 throw new ArgumentError(
703 'Line "$line" does not have enough indentation.'); 702 'Line "$line" does not have enough indentation.');
704 } 703 }
705 704
706 lines[i] = line.substring(indent); 705 lines[i] = line.substring(indent);
707 } 706 }
708 } 707 }
709 708
710 return Strings.join(lines, '\n'); 709 return Strings.join(lines, '\n');
711 } 710 }
OLDNEW
« no previous file with comments | « no previous file | pkg/fixnum/test/int_32_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698