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

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

Issue 12545013: Added the continueParsing option to ArgParser. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 12 changes. Created 7 years, 6 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
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");

Powered by Google App Engine
This is Rietveld 408576698