| OLD | NEW |
| 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; | 5 library parse_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 'shared.dart'; |
| 9 | 10 |
| 10 main() { | 11 void main() { |
| 11 group('ArgParser.parse()', () { | 12 group('ArgParser.parse()', () { |
| 12 test('does not destructively modify the argument list', () { | 13 test('does not destructively modify the argument list', () { |
| 13 var parser = new ArgParser(); | 14 var parser = new ArgParser(); |
| 14 parser.addFlag('verbose'); | 15 parser.addFlag('verbose'); |
| 15 | 16 |
| 16 var args = ['--verbose']; | 17 var args = ['--verbose']; |
| 17 var results = parser.parse(args); | 18 var results = parser.parse(args); |
| 18 expect(args, equals(['--verbose'])); | 19 expect(args, equals(['--verbose'])); |
| 19 expect(results['verbose'], isTrue); | 20 expect(results['verbose'], isTrue); |
| 20 }); | 21 }); |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 var parser = new ArgParser(); | 415 var parser = new ArgParser(); |
| 415 parser.addFlag('recurse', defaultsTo: false, abbr:'R'); | 416 parser.addFlag('recurse', defaultsTo: false, abbr:'R'); |
| 416 var results = parser.parse(['-R']); | 417 var results = parser.parse(['-R']); |
| 417 expect(results['recurse'], isTrue); | 418 expect(results['recurse'], isTrue); |
| 418 expect(results.rest, [ ]); | 419 expect(results.rest, [ ]); |
| 419 throwsFormat(parser, ['-r']); | 420 throwsFormat(parser, ['-r']); |
| 420 }); | 421 }); |
| 421 }); | 422 }); |
| 422 }); | 423 }); |
| 423 } | 424 } |
| 424 | |
| 425 throwsIllegalArg(function) { | |
| 426 expect(function, throwsArgumentError); | |
| 427 } | |
| 428 | |
| 429 throwsFormat(ArgParser parser, List<String> args) { | |
| 430 expect(() => parser.parse(args), throwsFormatException); | |
| 431 } | |
| OLD | NEW |