| 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 options_test; | 5 library options_test; |
| 6 | 6 |
| 7 import 'package:analyzer/options.dart'; | 7 import 'package:analyzer/options.dart'; |
| 8 import 'package:args/args.dart'; |
| 8 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 9 import 'package:args/args.dart'; | 10 |
| 11 import 'reflective_tests.dart'; |
| 10 | 12 |
| 11 main() { | 13 main() { |
| 12 | 14 |
| 13 group('AnalyzerOptions.parse()', () { | 15 group('AnalyzerOptions.parse()', () { |
| 14 | 16 |
| 15 test('defaults', () { | 17 test('defaults', () { |
| 16 CommandLineOptions options = | 18 CommandLineOptions options = |
| 17 CommandLineOptions.parse(['--dart-sdk', '.', 'foo.dart']); | 19 CommandLineOptions.parse(['--dart-sdk', '.', 'foo.dart']); |
| 18 expect(options, isNotNull); | 20 expect(options, isNotNull); |
| 19 expect(options.dartSdkPath, isNotNull); | 21 expect(options.dartSdkPath, isNotNull); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 '--baz', | 141 '--baz', |
| 140 '--dart-sdk', | 142 '--dart-sdk', |
| 141 '.', | 143 '.', |
| 142 'foo.dart']); | 144 'foo.dart']); |
| 143 expect(options, isNotNull); | 145 expect(options, isNotNull); |
| 144 expect(options.sourceFiles, equals(['foo.dart'])); | 146 expect(options.sourceFiles, equals(['foo.dart'])); |
| 145 }); | 147 }); |
| 146 | 148 |
| 147 }); | 149 }); |
| 148 | 150 |
| 151 runReflectiveTests(CommandLineParserTest); |
| 149 } | 152 } |
| 153 |
| 154 |
| 155 @reflectiveTest |
| 156 class CommandLineParserTest { |
| 157 test_ignoreUnrecognizedOptions() { |
| 158 CommandLineParser parser = |
| 159 new CommandLineParser(alwaysIgnoreUnrecognized: true); |
| 160 parser.addOption('optionA'); |
| 161 parser.addFlag('flagA'); |
| 162 ArgResults argResults = |
| 163 parser.parse(['--optionA=1', '--optionB=2', '--flagA'], {}); |
| 164 expect(argResults['optionA'], '1'); |
| 165 expect(argResults['flagA'], isTrue); |
| 166 } |
| 167 } |
| OLD | NEW |