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

Unified Diff: pkg/args/test/args_test.dart

Issue 11819068: Add command support to args. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix a couple of type annotations. Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/args/lib/src/utils.dart ('k') | pkg/args/test/command_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/args/test/args_test.dart
diff --git a/pkg/args/test/args_test.dart b/pkg/args/test/args_test.dart
index 9784bd271a9ba49b3263cf0652e8e42e7b60abf8..d807291e04d840e5e3f36f85463462deba04e1b9 100644
--- a/pkg/args/test/args_test.dart
+++ b/pkg/args/test/args_test.dart
@@ -70,8 +70,57 @@ main() {
test('throws if the option is unknown', () {
var parser = new ArgParser();
parser.addOption('mode', defaultsTo: 'debug');
- expect(()=>parser.getDefault('undefined'),
- throwsArgumentError);
+ throwsIllegalArg(() => parser.getDefault('undefined'));
+ });
+ });
+
+ group('ArgParser.commands', () {
+ test('returns an empty map if there are no commands', () {
+ var parser = new ArgParser();
+ expect(parser.commands, isEmpty);
+ });
+
+ test('returns the commands that were added', () {
+ var parser = new ArgParser();
+ parser.addCommand('hide');
+ parser.addCommand('seek');
+ expect(parser.commands, hasLength(2));
+ expect(parser.commands['hide'], isNotNull);
+ expect(parser.commands['seek'], isNotNull);
+ });
+
+ test('iterates over the commands in the order they were added', () {
+ var parser = new ArgParser();
+ parser.addCommand('a');
+ parser.addCommand('d');
+ parser.addCommand('b');
+ parser.addCommand('c');
+ expect(parser.commands.keys, equals(['a', 'd', 'b', 'c']));
+ });
+ });
+
+ group('ArgParser.options', () {
+ test('returns an empty map if there are no options', () {
+ var parser = new ArgParser();
+ expect(parser.options, isEmpty);
+ });
+
+ test('returns the options that were added', () {
+ var parser = new ArgParser();
+ parser.addFlag('hide');
+ parser.addOption('seek');
+ expect(parser.options, hasLength(2));
+ expect(parser.options['hide'], isNotNull);
+ expect(parser.options['seek'], isNotNull);
+ });
+
+ test('iterates over the options in the order they were added', () {
+ var parser = new ArgParser();
+ parser.addFlag('a');
+ parser.addOption('d');
+ parser.addFlag('b');
+ parser.addOption('c');
+ expect(parser.options.keys, equals(['a', 'd', 'b', 'c']));
});
});
« no previous file with comments | « pkg/args/lib/src/utils.dart ('k') | pkg/args/test/command_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698