| 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 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 | 9 |
| 10 main() { | 10 main() { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 group('ArgParser.getDefault()', () { | 63 group('ArgParser.getDefault()', () { |
| 64 test('returns the default value for an option', () { | 64 test('returns the default value for an option', () { |
| 65 var parser = new ArgParser(); | 65 var parser = new ArgParser(); |
| 66 parser.addOption('mode', defaultsTo: 'debug'); | 66 parser.addOption('mode', defaultsTo: 'debug'); |
| 67 expect(parser.getDefault('mode'), 'debug'); | 67 expect(parser.getDefault('mode'), 'debug'); |
| 68 }); | 68 }); |
| 69 | 69 |
| 70 test('throws if the option is unknown', () { | 70 test('throws if the option is unknown', () { |
| 71 var parser = new ArgParser(); | 71 var parser = new ArgParser(); |
| 72 parser.addOption('mode', defaultsTo: 'debug'); | 72 parser.addOption('mode', defaultsTo: 'debug'); |
| 73 expect(()=>parser.getDefault('undefined'), | 73 throwsIllegalArg(() => parser.getDefault('undefined')); |
| 74 throwsArgumentError); | |
| 75 }); | 74 }); |
| 76 }); | 75 }); |
| 77 | 76 |
| 78 group('ArgResults.options', () { | 77 group('ArgResults.options', () { |
| 79 test('returns the provided options', () { | 78 test('returns the provided options', () { |
| 80 var parser = new ArgParser(); | 79 var parser = new ArgParser(); |
| 81 parser.addFlag('woof'); | 80 parser.addFlag('woof'); |
| 82 parser.addOption('meow'); | 81 parser.addOption('meow'); |
| 83 var args = parser.parse(['--woof', '--meow', 'kitty']); | 82 var args = parser.parse(['--woof', '--meow', 'kitty']); |
| 84 expect(args.options, hasLength(2)); | 83 expect(args.options, hasLength(2)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 106 }); | 105 }); |
| 107 } | 106 } |
| 108 | 107 |
| 109 throwsIllegalArg(function) { | 108 throwsIllegalArg(function) { |
| 110 expect(function, throwsArgumentError); | 109 expect(function, throwsArgumentError); |
| 111 } | 110 } |
| 112 | 111 |
| 113 throwsFormat(ArgParser parser, List<String> args) { | 112 throwsFormat(ArgParser parser, List<String> args) { |
| 114 expect(() => parser.parse(args), throwsFormatException); | 113 expect(() => parser.parse(args), throwsFormatException); |
| 115 } | 114 } |
| OLD | NEW |