| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_all_test; | 5 library parse_all_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 void main() { |
| 11 group('ArgParser.parse(allowTrailingOptions: true) ' | 11 group('ArgParser.parse(allowTrailingOptions: true) ' |
| 12 'starting with a non-option', () { | 12 'starting with a non-option', () { |
| 13 test('followed by flag', () { | 13 test('followed by flag', () { |
| 14 var parser = new ArgParser()..addFlag('flag'); | 14 var parser = new ArgParser()..addFlag('flag'); |
| 15 var args = ['A', '--flag']; | 15 var args = ['A', '--flag']; |
| 16 | 16 |
| 17 var resultsAll = parser.parse(args, allowTrailingOptions: true); | 17 var resultsAll = parser.parse(args, allowTrailingOptions: true); |
| 18 expect(resultsAll['flag'], isTrue); | 18 expect(resultsAll['flag'], isTrue); |
| 19 expect(resultsAll.rest, equals(['A'])); | 19 expect(resultsAll.rest, equals(['A'])); |
| 20 }); | 20 }); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 50 }); | 50 }); |
| 51 | 51 |
| 52 test('followed by command', () { | 52 test('followed by command', () { |
| 53 var parser = new ArgParser()..addCommand('com'); | 53 var parser = new ArgParser()..addCommand('com'); |
| 54 var args = ['A', 'com']; | 54 var args = ['A', 'com']; |
| 55 | 55 |
| 56 expectThrows(parser, args); | 56 expectThrows(parser, args); |
| 57 }); | 57 }); |
| 58 }); | 58 }); |
| 59 } | 59 } |
| 60 expectThrows(ArgParser parser, List<String> args) => | 60 |
| 61 void expectThrows(ArgParser parser, List<String> args) => |
| 61 expect(() => parser.parse(args, allowTrailingOptions: true), | 62 expect(() => parser.parse(args, allowTrailingOptions: true), |
| 62 throwsFormatException, | 63 throwsFormatException, |
| 63 reason: "with allowTrailingOptions: true"); | 64 reason: "with allowTrailingOptions: true"); |
| OLD | NEW |