| 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 import 'utils.dart'; | 9 import 'utils.dart'; |
| 10 | 10 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 test('[] throws if the name is not an option', () { | 221 test('[] throws if the name is not an option', () { |
| 222 var results = new ArgParser().parse([]); | 222 var results = new ArgParser().parse([]); |
| 223 throwsIllegalArg(() => results['unknown']); | 223 throwsIllegalArg(() => results['unknown']); |
| 224 }); | 224 }); |
| 225 | 225 |
| 226 test('rest cannot be modified', () { | 226 test('rest cannot be modified', () { |
| 227 var results = new ArgParser().parse([]); | 227 var results = new ArgParser().parse([]); |
| 228 expect(() => results.rest.add('oops'), throwsUnsupportedError); | 228 expect(() => results.rest.add('oops'), throwsUnsupportedError); |
| 229 }); | 229 }); |
| 230 | 230 |
| 231 test('.original returns the original argument list', () { |
| 232 var parser = new ArgParser(); |
| 233 parser.addFlag('foo'); |
| 234 |
| 235 var results = parser.parse(['--foo']); |
| 236 expect(results.original, equals(['--foo'])); |
| 237 }); |
| 238 |
| 231 group('.wasParsed()', () { | 239 group('.wasParsed()', () { |
| 232 test('throws if the name is not an option', () { | 240 test('throws if the name is not an option', () { |
| 233 var results = new ArgParser().parse([]); | 241 var results = new ArgParser().parse([]); |
| 234 throwsIllegalArg(() => results.wasParsed('unknown')); | 242 throwsIllegalArg(() => results.wasParsed('unknown')); |
| 235 }); | 243 }); |
| 236 | 244 |
| 237 test('returns true for parsed options', () { | 245 test('returns true for parsed options', () { |
| 238 var parser = new ArgParser(); | 246 var parser = new ArgParser(); |
| 239 parser.addFlag('fast'); | 247 parser.addFlag('fast'); |
| 240 parser.addFlag('verbose'); | 248 parser.addFlag('verbose'); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 const _VALID_OPTIONS = const [ | 300 const _VALID_OPTIONS = const [ |
| 293 'a' // One character. | 301 'a' // One character. |
| 294 'contains-dash', | 302 'contains-dash', |
| 295 'contains_underscore', | 303 'contains_underscore', |
| 296 'ends-with-dash-', | 304 'ends-with-dash-', |
| 297 'contains--doubledash--', | 305 'contains--doubledash--', |
| 298 '1starts-with-number', | 306 '1starts-with-number', |
| 299 'contains-a-1number', | 307 'contains-a-1number', |
| 300 'ends-with-a-number8' | 308 'ends-with-a-number8' |
| 301 ]; | 309 ]; |
| OLD | NEW |