Index: pkg/args/test/parse_all_test.dart |
diff --git a/pkg/args/test/parse_all_test.dart b/pkg/args/test/parse_all_test.dart |
index a921046465786147256074fb58c14bd3cc17ec4e..2df05189630c707daf75931c295704832706038d 100644 |
--- a/pkg/args/test/parse_all_test.dart |
+++ b/pkg/args/test/parse_all_test.dart |
@@ -8,7 +8,8 @@ import 'package:unittest/unittest.dart'; |
import 'package:args/args.dart'; |
main() { |
- group('ArgParser.parse() starting with a non-option', () { |
+ group('ArgParser.parse(allowTrailingOptions: true) ' |
+ 'starting with a non-option', () { |
test('followed by flag', () { |
var parser = new ArgParser()..addFlag('flag'); |
var args = ['A', '--flag']; |
@@ -16,6 +17,9 @@ main() { |
var results = parser.parse(args); |
expect(results['flag'], isFalse); |
expect(results.rest, orderedEquals(args)); |
+ var resultsAll = parser.parse(args, allowTrailingOptions: true); |
+ expect(resultsAll['flag'], isTrue); |
+ expect(resultsAll.rest, equals(['A'])); |
}); |
test('followed by option', () { |
@@ -25,6 +29,8 @@ main() { |
var results = parser.parse(args); |
expect(results['opt'], isNull); |
expect(results.rest, orderedEquals(args)); |
+ |
+ expectThrows(parser, args); |
}); |
test('followed by option and value', () { |
@@ -34,6 +40,10 @@ main() { |
var results = parser.parse(args); |
expect(results['opt'], isNull); |
expect(results.rest, orderedEquals(args)); |
+ |
+ var resultsAll = parser.parse(args, allowTrailingOptions: true); |
+ expect(resultsAll['opt'], equals('V')); |
+ expect(resultsAll.rest, equals(['A'])); |
}); |
test('followed by unknown flag', () { |
@@ -41,6 +51,8 @@ main() { |
var args = ['A', '--xflag']; |
var results = parser.parse(args); |
expect(results.rest, orderedEquals(args)); |
+ |
+ expectThrows(parser, args); |
}); |
test('followed by unknown option and value', () { |
@@ -48,6 +60,8 @@ main() { |
var args = ['A', '--xopt', 'V']; |
var results = parser.parse(args); |
expect(results.rest, orderedEquals(args)); |
+ |
+ expectThrows(parser, args); |
}); |
test('followed by command', () { |
@@ -57,6 +71,12 @@ main() { |
var results = parser.parse(args); |
expect(results.command, isNull); |
expect(results.rest, orderedEquals(args)); |
+ |
+ expectThrows(parser, args); |
}); |
}); |
} |
+expectThrows(ArgParser parser, List<String> args) => |
+ expect(() => parser.parse(args, allowTrailingOptions: true), |
+ throwsFormatException, |
+ reason: "with allowTrailingOptions: true"); |