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

Side by Side Diff: test/args_test.dart

Issue 975463004: Parse comma-separated multiple values. (Closed) Base URL: git@github.com:dart-lang/args@master
Patch Set: Code review changes Created 5 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library args_test; 5 library args_test;
6 6
7 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 import 'package:args/args.dart'; 8 import 'package:args/args.dart';
9 import 'utils.dart'; 9 import 'utils.dart';
10 10
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 test('throws ArgumentError if an option name is invalid', () { 103 test('throws ArgumentError if an option name is invalid', () {
104 var parser = new ArgParser(); 104 var parser = new ArgParser();
105 105
106 for (var name in _INVALID_OPTIONS) { 106 for (var name in _INVALID_OPTIONS) {
107 var reason = '${Error.safeToString(name)} is not valid'; 107 var reason = '${Error.safeToString(name)} is not valid';
108 throwsIllegalArg(() => parser.addOption(name), reason: reason); 108 throwsIllegalArg(() => parser.addOption(name), reason: reason);
109 } 109 }
110 }); 110 });
111 111
112 test('throws ArgumentError if splitCommas is passed with allowMultiple: '
113 'false', () {
114 var parser = new ArgParser();
115 throwsIllegalArg(() => parser.addOption('flummox', splitCommas: true));
116 throwsIllegalArg(() => parser.addOption('flummox', splitCommas: false));
117 });
118
112 test('accepts valid option names', () { 119 test('accepts valid option names', () {
113 var parser = new ArgParser(); 120 var parser = new ArgParser();
114 121
115 for (var name in _VALID_OPTIONS) { 122 for (var name in _VALID_OPTIONS) {
116 var reason = '${Error.safeToString(name)} is valid'; 123 var reason = '${Error.safeToString(name)} is valid';
117 expect(() => parser.addOption(name), returnsNormally, reason: reason); 124 expect(() => parser.addOption(name), returnsNormally, reason: reason);
118 } 125 }
119 }); 126 });
120 }); 127 });
121 128
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 const _VALID_OPTIONS = const [ 311 const _VALID_OPTIONS = const [
305 'a', // One character. 312 'a', // One character.
306 'contains-dash', 313 'contains-dash',
307 'contains_underscore', 314 'contains_underscore',
308 'ends-with-dash-', 315 'ends-with-dash-',
309 'contains--doubledash--', 316 'contains--doubledash--',
310 '1starts-with-number', 317 '1starts-with-number',
311 'contains-a-1number', 318 'contains-a-1number',
312 'ends-with-a-number8' 319 'ends-with-a-number8'
313 ]; 320 ];
OLDNEW
« lib/src/arg_parser.dart ('K') | « pubspec.yaml ('k') | test/parse_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698