| 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 import 'package:test/test.dart'; | 5 import 'package:test/test.dart'; |
| 6 import 'package:args/args.dart'; | 6 import 'package:args/args.dart'; |
| 7 import 'utils.dart'; | 7 import 'utils.dart'; |
| 8 | 8 |
| 9 void main() { | 9 void main() { |
| 10 group('ArgParser.parse()', () { | 10 group('ArgParser.parse()', () { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 test('for multiple present, allowMultiple, options are invoked with ' | 155 test('for multiple present, allowMultiple, options are invoked with ' |
| 156 'value as a list', () { | 156 'value as a list', () { |
| 157 var a; | 157 var a; |
| 158 var parser = new ArgParser(); | 158 var parser = new ArgParser(); |
| 159 parser.addOption('a', | 159 parser.addOption('a', |
| 160 allowMultiple: true, callback: (value) => a = value); | 160 allowMultiple: true, callback: (value) => a = value); |
| 161 | 161 |
| 162 parser.parse(['--a=v', '--a=x']); | 162 parser.parse(['--a=v', '--a=x']); |
| 163 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>>()); |
| 164 }); | 168 }); |
| 165 | 169 |
| 166 test('for single present, allowMultiple, options are invoked with ' | 170 test('for single present, allowMultiple, options are invoked with ' |
| 167 ' value as a single element list', () { | 171 ' value as a single element list', () { |
| 168 var a; | 172 var a; |
| 169 var parser = new ArgParser(); | 173 var parser = new ArgParser(); |
| 170 parser.addOption('a', | 174 parser.addOption('a', |
| 171 allowMultiple: true, callback: (value) => a = value); | 175 allowMultiple: true, callback: (value) => a = value); |
| 172 | 176 |
| 173 parser.parse(['--a=v']); | 177 parser.parse(['--a=v']); |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 var parser = new ArgParser(); | 500 var parser = new ArgParser(); |
| 497 parser.addFlag('woof'); | 501 parser.addFlag('woof'); |
| 498 | 502 |
| 499 var results = parser.parse(['--woof', 'stop', '--', 'arg']); | 503 var results = parser.parse(['--woof', 'stop', '--', 'arg']); |
| 500 expect(results['woof'], isTrue); | 504 expect(results['woof'], isTrue); |
| 501 expect(results.rest, equals(['stop', '--', 'arg'])); | 505 expect(results.rest, equals(['stop', '--', 'arg'])); |
| 502 }); | 506 }); |
| 503 }); | 507 }); |
| 504 }); | 508 }); |
| 505 } | 509 } |
| OLD | NEW |