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

Unified Diff: tests/lib/args/args_test.dart

Issue 10828351: Added the ability to get the names of the options in a set of parsed arguments, and the default val… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 | « lib/args/args.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/args/args_test.dart
===================================================================
--- tests/lib/args/args_test.dart (revision 10607)
+++ tests/lib/args/args_test.dart (working copy)
@@ -377,12 +377,40 @@
test('returns the default value for multi-valued arguments '
'if not explicitly set', () {
var parser = new ArgParser();
- parser.addOption('define', defaultsTo:'0', allowMultiple: true);
+ parser.addOption('define', defaultsTo: '0', allowMultiple: true);
var args = parser.parse(['']);
expect(args['define'], equals(['0']));
});
});
+ group('query default values', () {
+ test('queries the default value', () {
+ var parser = new ArgParser();
+ parser.addOption('define', defaultsTo: '0');
+ expect(()=>parser.getDefault('undefine'),
+ throwsIllegalArgumentException);
+ });
+
+ test('queries the default value for an unknown option', () {
+ var parser = new ArgParser();
+ parser.addOption('define', defaultsTo: '0');
+ expect(()=>parser.getDefault('undefine'),
+ throwsIllegalArgumentException);
+ });
+ });
+
+ group('gets the option names from an ArgsResult', () {
+ test('queries the set options', () {
+ var parser = new ArgParser();
+ parser.addFlag('woof', defaultsTo: false);
+ parser.addOption('meow', defaultsTo: 'kitty');
+ var args = parser.parse([]);
+ expect(args.options, hasLength(2));
+ expect(args.options.some((o) => o == 'woof'), isTrue);
+ expect(args.options.some((o) => o == 'meow'), isTrue);
+ });
+ });
+
group('remaining args', () {
test('stops parsing args when a non-option-like arg is encountered', () {
var parser = new ArgParser();
« no previous file with comments | « lib/args/args.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698