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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 test('for absent flags are invoked with the default value', () { | 110 test('for absent flags are invoked with the default value', () { |
111 var a; | 111 var a; |
112 var parser = new ArgParser(); | 112 var parser = new ArgParser(); |
113 parser.addFlag('a', defaultsTo: false, callback: (value) => a = value); | 113 parser.addFlag('a', defaultsTo: false, callback: (value) => a = value); |
114 | 114 |
115 parser.parse([]); | 115 parser.parse([]); |
116 expect(a, isFalse); | 116 expect(a, isFalse); |
117 }); | 117 }); |
118 | 118 |
119 test('are invoked even if the flag is not present', () { | 119 test('are invoked even if the flag is not present', () { |
120 var a = 'not called'; | 120 var a = true; |
121 var parser = new ArgParser(); | 121 var parser = new ArgParser(); |
122 parser.addFlag('a', callback: (value) => a = value); | 122 parser.addFlag('a', callback: (value) => a = value); |
123 | 123 |
124 parser.parse([]); | 124 parser.parse([]); |
125 expect(a, isFalse); | 125 expect(a, isFalse); |
126 }); | 126 }); |
127 | 127 |
128 test('for present options are invoked with the value', () { | 128 test('for present options are invoked with the value', () { |
129 var a; | 129 var a; |
130 var parser = new ArgParser(); | 130 var parser = new ArgParser(); |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 var parser = new ArgParser(); | 496 var parser = new ArgParser(); |
497 parser.addFlag('woof'); | 497 parser.addFlag('woof'); |
498 | 498 |
499 var results = parser.parse(['--woof', 'stop', '--', 'arg']); | 499 var results = parser.parse(['--woof', 'stop', '--', 'arg']); |
500 expect(results['woof'], isTrue); | 500 expect(results['woof'], isTrue); |
501 expect(results.rest, equals(['stop', '--', 'arg'])); | 501 expect(results.rest, equals(['stop', '--', 'arg'])); |
502 }); | 502 }); |
503 }); | 503 }); |
504 }); | 504 }); |
505 } | 505 } |
OLD | NEW |