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

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

Issue 15621002: Allow passing in an existing ArgParser for a command. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« pkg/args/lib/args.dart ('K') | « pkg/args/lib/args.dart ('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) 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 command_test; 5 library command_test;
6 6
7 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 import 'package:args/args.dart'; 8 import 'package:args/args.dart';
9 9
10 main() { 10 main() {
11 group('ArgParser.addCommand()', () { 11 group('ArgParser.addCommand()', () {
12 test('creates a new ArgParser if none is given', () {
13 var parser = new ArgParser();
14 var command = parser.addCommand('install');
15 expect(parser.commands['install'], equals(command));
16 expect(command is ArgParser, isTrue);
17 });
18
19 test('uses the command parser if given one', () {
20 var parser = new ArgParser();
21 var command = new ArgParser();
22 var result = parser.addCommand('install', command);
23 expect(parser.commands['install'], equals(command));
24 expect(result, equals(command));
25 });
26
12 test('throws on a duplicate command name', () { 27 test('throws on a duplicate command name', () {
13 var parser = new ArgParser(); 28 var parser = new ArgParser();
14 parser.addCommand('install'); 29 parser.addCommand('install');
15 throwsIllegalArg(() => parser.addCommand('install')); 30 throwsIllegalArg(() => parser.addCommand('install'));
16 }); 31 });
17 }); 32 });
18 33
19 group('ArgParser.parse()', () { 34 group('ArgParser.parse()', () {
20 test('parses a command', () { 35 test('parses a command', () {
21 var parser = new ArgParser(); 36 var parser = new ArgParser();
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 }); 205 });
191 } 206 }
192 207
193 throwsIllegalArg(function) { 208 throwsIllegalArg(function) {
194 expect(function, throwsArgumentError); 209 expect(function, throwsArgumentError);
195 } 210 }
196 211
197 throwsFormat(ArgParser parser, List<String> args) { 212 throwsFormat(ArgParser parser, List<String> args) {
198 expect(() => parser.parse(args), throwsFormatException); 213 expect(() => parser.parse(args), throwsFormatException);
199 } 214 }
OLDNEW
« pkg/args/lib/args.dart ('K') | « pkg/args/lib/args.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698