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

Side by Side Diff: packages/args/test/parse_test.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 4 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
« no previous file with comments | « packages/args/test/command_test.dart ('k') | packages/args/test/trailing_options_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 parse_test;
6
7 import 'package:test/test.dart'; 5 import 'package:test/test.dart';
8 import 'package:args/args.dart'; 6 import 'package:args/args.dart';
9 import 'utils.dart'; 7 import 'utils.dart';
10 8
11 void main() { 9 void main() {
12 group('ArgParser.parse()', () { 10 group('ArgParser.parse()', () {
13 test('does not destructively modify the argument list', () { 11 test('does not destructively modify the argument list', () {
14 var parser = new ArgParser(); 12 var parser = new ArgParser();
15 parser.addFlag('verbose'); 13 parser.addFlag('verbose');
16 14
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 test('for absent flags are invoked with the default value', () { 110 test('for absent flags are invoked with the default value', () {
113 var a; 111 var a;
114 var parser = new ArgParser(); 112 var parser = new ArgParser();
115 parser.addFlag('a', defaultsTo: false, callback: (value) => a = value); 113 parser.addFlag('a', defaultsTo: false, callback: (value) => a = value);
116 114
117 parser.parse([]); 115 parser.parse([]);
118 expect(a, isFalse); 116 expect(a, isFalse);
119 }); 117 });
120 118
121 test('are invoked even if the flag is not present', () { 119 test('are invoked even if the flag is not present', () {
122 var a = 'not called'; 120 var a = true;
123 var parser = new ArgParser(); 121 var parser = new ArgParser();
124 parser.addFlag('a', callback: (value) => a = value); 122 parser.addFlag('a', callback: (value) => a = value);
125 123
126 parser.parse([]); 124 parser.parse([]);
127 expect(a, isFalse); 125 expect(a, isFalse);
128 }); 126 });
129 127
130 test('for present options are invoked with the value', () { 128 test('for present options are invoked with the value', () {
131 var a; 129 var a;
132 var parser = new ArgParser(); 130 var parser = new ArgParser();
(...skipping 23 matching lines...) Expand all
156 154
157 test('for multiple present, allowMultiple, options are invoked with ' 155 test('for multiple present, allowMultiple, options are invoked with '
158 'value as a list', () { 156 'value as a list', () {
159 var a; 157 var a;
160 var parser = new ArgParser(); 158 var parser = new ArgParser();
161 parser.addOption('a', 159 parser.addOption('a',
162 allowMultiple: true, callback: (value) => a = value); 160 allowMultiple: true, callback: (value) => a = value);
163 161
164 parser.parse(['--a=v', '--a=x']); 162 parser.parse(['--a=v', '--a=x']);
165 expect(a, equals(['v', 'x'])); 163 expect(a, equals(['v', 'x']));
164
165 // This reified type is important in strong mode so that people can
166 // safely write "as List<String>".
167 expect(a, new isInstanceOf<List<String>>());
166 }); 168 });
167 169
168 test('for single present, allowMultiple, options are invoked with ' 170 test('for single present, allowMultiple, options are invoked with '
169 ' value as a single element list', () { 171 ' value as a single element list', () {
170 var a; 172 var a;
171 var parser = new ArgParser(); 173 var parser = new ArgParser();
172 parser.addOption('a', 174 parser.addOption('a',
173 allowMultiple: true, callback: (value) => a = value); 175 allowMultiple: true, callback: (value) => a = value);
174 176
175 parser.parse(['--a=v']); 177 parser.parse(['--a=v']);
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 var parser = new ArgParser(); 500 var parser = new ArgParser();
499 parser.addFlag('woof'); 501 parser.addFlag('woof');
500 502
501 var results = parser.parse(['--woof', 'stop', '--', 'arg']); 503 var results = parser.parse(['--woof', 'stop', '--', 'arg']);
502 expect(results['woof'], isTrue); 504 expect(results['woof'], isTrue);
503 expect(results.rest, equals(['stop', '--', 'arg'])); 505 expect(results.rest, equals(['stop', '--', 'arg']));
504 }); 506 });
505 }); 507 });
506 }); 508 });
507 } 509 }
OLDNEW
« no previous file with comments | « packages/args/test/command_test.dart ('k') | packages/args/test/trailing_options_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698