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

Unified Diff: test/parse_test.dart

Issue 1165263003: Follow getopt in parsing option-like values. (Closed) Base URL: git@github.com:dart-lang/args@master
Patch Set: Code review changes Created 5 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
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/parse_test.dart
diff --git a/test/parse_test.dart b/test/parse_test.dart
index ba7453cb778dbab088ee399d1ded232785d3e800..39027c2c93fd53bc6cf5af03f95b1cd447361d24 100644
--- a/test/parse_test.dart
+++ b/test/parse_test.dart
@@ -315,14 +315,15 @@ void main() {
throwsFormat(parser, ['-f']);
});
- test('throw if the value looks like an option', () {
+ test('does not throw if the value looks like an option', () {
var parser = new ArgParser();
parser.addOption('file', abbr: 'f');
parser.addOption('other');
- throwsFormat(parser, ['-f', '--other']);
- throwsFormat(parser, ['-f', '--unknown']);
- throwsFormat(parser, ['-f', '-abbr']);
+ expect(parser.parse(['-f', '--other'])['file'], equals('--other'));
+ expect(parser.parse(['-f', '--unknown'])['file'], equals('--unknown'));
+ expect(parser.parse(['-f', '-abbr'])['file'], equals('-abbr'));
+ expect(parser.parse(['-f', '--'])['file'], equals('--'));
});
test('throw if the value is not allowed', () {
@@ -409,14 +410,16 @@ void main() {
throwsFormat(parser, ['--mode']);
});
- test('throw if the value looks like an option', () {
+ test('do not throw if the value looks like an option', () {
var parser = new ArgParser();
parser.addOption('mode');
parser.addOption('other');
- throwsFormat(parser, ['--mode', '--other']);
- throwsFormat(parser, ['--mode', '--unknown']);
- throwsFormat(parser, ['--mode', '-abbr']);
+ expect(parser.parse(['--mode', '--other'])['mode'], equals('--other'));
+ expect(parser.parse(['--mode', '--unknown'])['mode'],
+ equals('--unknown'));
+ expect(parser.parse(['--mode', '-abbr'])['mode'], equals('-abbr'));
+ expect(parser.parse(['--mode', '--'])['mode'], equals('--'));
});
test('do not throw if the value is in the allowed set', () {
« no previous file with comments | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698