Chromium Code Reviews| Index: pkg/args/test/parse_test.dart |
| diff --git a/pkg/args/test/parse_test.dart b/pkg/args/test/parse_test.dart |
| index 715c2269218537157fff9a758ef37005905de3cc..82f25c9db9c69f035f0af94e13833428a960d481 100644 |
| --- a/pkg/args/test/parse_test.dart |
| +++ b/pkg/args/test/parse_test.dart |
| @@ -389,14 +389,62 @@ main() { |
| test('stops parsing args when a non-option-like arg is encountered', () { |
| var parser = new ArgParser(); |
| parser.addFlag('woof'); |
| + parser.addFlag('neigh'); |
|
Bob Nystrom
2013/04/22 22:59:03
Why add neigh to this test?
|
| parser.addOption('meow'); |
| parser.addOption('tweet', defaultsTo: 'bird'); |
| - var results = parser.parse(['--woof', '--meow', 'v', 'not', 'option']); |
| + var results = parser.parse(['--woof', '--meow', 'v', 'not', 'option', |
| + '--tweet', 'devrel', '--neigh', 'end' ]); |
| expect(results['woof'], isTrue); |
| + expect(results['neigh'], isFalse); |
| expect(results['meow'], equals('v')); |
| expect(results['tweet'], equals('bird')); |
| - expect(results.rest, orderedEquals(['not', 'option'])); |
| + expect(results.rest, orderedEquals(['not', 'option', '--tweet', |
| + 'devrel', '--neigh', 'end'])); |
| + }); |
| + |
| + test('with continueParsing, continues parsing when non-option-like' |
| + ' arg is encountered', () { |
| + var parser = new ArgParser(); |
| + parser.addFlag('woof'); |
| + parser.addFlag('neigh'); |
| + parser.addOption('meow'); |
| + parser.addOption('tweet', defaultsTo: 'bird'); |
| + |
| + var results = parser.parse(['--woof', '--meow', 'v', 'not', 'option', |
| + '--tweet', 'devrel', '--neigh', 'end' ], |
|
Bob Nystrom
2013/04/22 22:59:03
This test is pretty complicated. How about simplif
|
| + continueParsing: true); |
| + expect(results['woof'], isTrue); |
| + expect(results['neigh'], isTrue); |
| + expect(results['meow'], equals('v')); |
| + expect(results['tweet'], equals('devrel')); |
| + expect(results.rest, orderedEquals(['not', 'option', 'end'])); |
| + }); |
| + |
|
Bob Nystrom
2013/04/22 22:59:03
Add a test for what happens if continueParsing is
|
| + test('with continueParsing, gathers all seen arguments to leaf command', |
| + () { |
| + var parser = new ArgParser(); |
| + parser.addFlag('woof'); |
| + parser.addFlag('neigh'); |
| + parser.addOption('tweet', defaultsTo: 'bird'); |
| + |
| + var command = parser.addCommand('v'); |
| + command.addCommand('option') |
| + ..addOption('tweet', defaultsTo: 'foo') |
| + ..addFlag('neigh'); |
|
Bob Nystrom
2013/04/22 22:59:03
We should use a consistent style here. How about j
|
| + command.addCommand('end'); |
| + |
| + var results = parser.parse(['--woof', 'meow', 'v', 'not', 'option', |
| + '--tweet', 'devrel', '--neigh', 'end' ], |
| + continueParsing: true); |
| + expect(results['woof'], isTrue); |
| + expect(results['tweet'], equals('bird')); |
| + expect(results.rest, equals([])); |
| + expect(results.command.name, equals('v')); |
| + expect(results.command.rest, equals([])); |
| + expect(results.command.command['neigh'], isTrue); |
| + expect(results.command.command.name, equals('option')); |
| + expect(results.command.command.rest, orderedEquals(['meow', 'not', 'end'])); |
|
Bob Nystrom
2013/04/22 22:59:03
This test is big and hard to read. Split it into a
|
| }); |
| test('stops parsing at "--"', () { |