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

Side by Side Diff: pkg/args/test/usage_test.dart

Issue 631123002: Swap getUsage() for get usage in args package (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Bump args version, add to args CHANGELOG Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « pkg/args/pubspec.yaml ('k') | no next file » | 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 usage_test; 5 library usage_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 9
10 void main() { 10 void main() {
11 group('ArgParser.getUsage()', () { 11 group('ArgParser.usage', () {
12 test('negatable flags show "no-" in title', () { 12 test('negatable flags show "no-" in title', () {
13 var parser = new ArgParser(); 13 var parser = new ArgParser();
14 parser.addFlag('mode', help: 'The mode'); 14 parser.addFlag('mode', help: 'The mode');
15 15
16 validateUsage(parser, 16 validateUsage(parser,
17 ''' 17 '''
18 --[no-]mode The mode 18 --[no-]mode The mode
19 '''); 19 ''');
20 }); 20 });
21 21
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 ''' 218 '''
219 --[no-]first The first flag 219 --[no-]first The first flag
220 --[no-]third The third flag 220 --[no-]third The third flag
221 '''); 221 ''');
222 }); 222 });
223 }); 223 });
224 } 224 }
225 225
226 void validateUsage(ArgParser parser, String expected) { 226 void validateUsage(ArgParser parser, String expected) {
227 expected = unindentString(expected); 227 expected = unindentString(expected);
228 expect(parser.getUsage(), equals(expected)); 228 expect(parser.usage, equals(expected));
229 } 229 }
230 230
231 // TODO(rnystrom): Replace one in test_utils. 231 // TODO(rnystrom): Replace one in test_utils.
232 String unindentString(String text) { 232 String unindentString(String text) {
233 var lines = text.split('\n'); 233 var lines = text.split('\n');
234 234
235 // Count the indentation of the last line. 235 // Count the indentation of the last line.
236 var whitespace = new RegExp('^ *'); 236 var whitespace = new RegExp('^ *');
237 var indent = whitespace.firstMatch(lines[lines.length - 1])[0].length; 237 var indent = whitespace.firstMatch(lines[lines.length - 1])[0].length;
238 238
(...skipping 16 matching lines...) Expand all
255 throw new ArgumentError( 255 throw new ArgumentError(
256 'Line "$line" does not have enough indentation.'); 256 'Line "$line" does not have enough indentation.');
257 } 257 }
258 258
259 lines[i] = line.substring(indent); 259 lines[i] = line.substring(indent);
260 } 260 }
261 } 261 }
262 262
263 return lines.join('\n'); 263 return lines.join('\n');
264 } 264 }
OLDNEW
« no previous file with comments | « pkg/args/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698