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 |
new file mode 100644 |
index 0000000000000000000000000000000000000000..dd182d31a59b2fcb67b9e5991eebe13a5af102ad |
--- /dev/null |
+++ b/pkg/args/test/parse_all_test.dart |
@@ -0,0 +1,70 @@ |
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+library parse_all_test; |
+ |
+import 'package:unittest/unittest.dart'; |
+import 'package:args/args.dart'; |
+ |
+main() { |
+ group('ArgParser.parse()', () { |
+ var parser; |
+ var args; |
Bob Nystrom
2013/06/19 22:22:21
How about removing these and just making them loca
Andrei Mouravski
2013/06/19 23:16:20
Done.
|
+ |
+ setUp(() { |
+ parser = new ArgParser(); |
+ args = <String>[]; |
+ }); |
+ |
+ group('starting with a non-option', () { |
+ test('followed by flag', () { |
+ parser.addFlag('flag'); |
+ args = ['A', '--flag']; |
+ |
+ var results = parser.parse(args); |
+ expect(results['flag'], isFalse); |
+ expect(results.rest, orderedEquals(args)); |
+ }); |
+ |
+ test('followed by option', () { |
+ parser.addOption('opt'); |
+ args = ['A', '--opt']; |
+ |
+ var results = parser.parse(args); |
+ expect(results['opt'], isNull); |
+ expect(results.rest, orderedEquals(args)); |
+ }); |
+ |
+ test('followed by option and value', () { |
+ parser.addOption('opt'); |
+ args = ['A', '--opt', 'V']; |
+ |
+ var results = parser.parse(args); |
+ expect(results['opt'], isNull); |
+ expect(results.rest, orderedEquals(args)); |
+ }); |
+ |
+ test('followed by unknown flag', () { |
+ args = ['A', '--xflag']; |
+ var results = parser.parse(args); |
+ expect(results.rest, orderedEquals(args)); |
+ }); |
+ |
+ test('followed by unknown option and value', () { |
+ args = ['A', '--xopt', 'V']; |
+ var results = parser.parse(args); |
+ expect(results.rest, orderedEquals(args)); |
+ }); |
+ |
+ test('followed by command', () { |
+ parser.addCommand('com'); |
+ args = ['A', 'com']; |
+ |
+ var results = parser.parse(args); |
+ expect(results.command, isNull); |
+ expect(results.rest, orderedEquals(args)); |
+ }); |
+ }); |
+ }); |
+} |