| 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:args/args.dart'; |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 | 10 |
| 11 import 'reflective_tests.dart'; | 11 import 'reflective_tests.dart'; |
| 12 | 12 |
| 13 main() { | 13 main() { |
| 14 group('AnalyzerOptions.parse()', () { | 14 group('AnalyzerOptions.parse()', () { |
| 15 test('defaults', () { | 15 test('defaults', () { |
| 16 CommandLineOptions options = | 16 CommandLineOptions options = |
| 17 CommandLineOptions.parse(['--dart-sdk', '.', 'foo.dart']); | 17 CommandLineOptions.parse(['--dart-sdk', '.', 'foo.dart']); |
| 18 expect(options, isNotNull); | 18 expect(options, isNotNull); |
| 19 expect(options.dartSdkPath, isNotNull); | 19 expect(options.dartSdkPath, isNotNull); |
| 20 expect(options.disableHints, isFalse); | 20 expect(options.disableHints, isFalse); |
| 21 expect(options.displayVersion, isFalse); | 21 expect(options.displayVersion, isFalse); |
| 22 expect(options.enableStrictCallChecks, isFalse); |
| 22 expect(options.enableTypeChecks, isFalse); | 23 expect(options.enableTypeChecks, isFalse); |
| 23 expect(options.ignoreUnrecognizedFlags, isFalse); | 24 expect(options.ignoreUnrecognizedFlags, isFalse); |
| 24 expect(options.log, isFalse); | 25 expect(options.log, isFalse); |
| 25 expect(options.machineFormat, isFalse); | 26 expect(options.machineFormat, isFalse); |
| 26 expect(options.packageRootPath, isNull); | 27 expect(options.packageRootPath, isNull); |
| 27 expect(options.perf, isFalse); | 28 expect(options.perf, isFalse); |
| 28 expect(options.shouldBatch, isFalse); | 29 expect(options.shouldBatch, isFalse); |
| 29 expect(options.showPackageWarnings, isFalse); | 30 expect(options.showPackageWarnings, isFalse); |
| 30 expect(options.showSdkWarnings, isFalse); | 31 expect(options.showSdkWarnings, isFalse); |
| 31 expect(options.sourceFiles, equals(['foo.dart'])); | 32 expect(options.sourceFiles, equals(['foo.dart'])); |
| 32 expect(options.warmPerf, isFalse); | 33 expect(options.warmPerf, isFalse); |
| 33 expect(options.warningsAreFatal, isFalse); | 34 expect(options.warningsAreFatal, isFalse); |
| 34 expect(options.customUrlMappings, isNotNull); | 35 expect(options.customUrlMappings, isNotNull); |
| 35 expect(options.customUrlMappings.isEmpty, isTrue); | 36 expect(options.customUrlMappings.isEmpty, isTrue); |
| 36 }); | 37 }); |
| 37 | 38 |
| 38 test('batch', () { | 39 test('batch', () { |
| 39 CommandLineOptions options = | 40 CommandLineOptions options = |
| 40 CommandLineOptions.parse(['--dart-sdk', '.', '--batch']); | 41 CommandLineOptions.parse(['--dart-sdk', '.', '--batch']); |
| 41 expect(options.shouldBatch, isTrue); | 42 expect(options.shouldBatch, isTrue); |
| 42 }); | 43 }); |
| 43 | 44 |
| 44 test('defined variables', () { | 45 test('defined variables', () { |
| 45 CommandLineOptions options = CommandLineOptions | 46 CommandLineOptions options = CommandLineOptions |
| 46 .parse(['--dart-sdk', '.', '-Dfoo=bar', 'foo.dart']); | 47 .parse(['--dart-sdk', '.', '-Dfoo=bar', 'foo.dart']); |
| 47 expect(options.definedVariables['foo'], equals('bar')); | 48 expect(options.definedVariables['foo'], equals('bar')); |
| 48 expect(options.definedVariables['bar'], isNull); | 49 expect(options.definedVariables['bar'], isNull); |
| 49 }); | 50 }); |
| 50 | 51 |
| 52 test('enable strict call checks', () { |
| 53 CommandLineOptions options = CommandLineOptions.parse( |
| 54 ['--dart-sdk', '.', '--enable-strict-call-checks', 'foo.dart']); |
| 55 expect(options.enableStrictCallChecks, isTrue); |
| 56 }); |
| 57 |
| 51 test('enable type checks', () { | 58 test('enable type checks', () { |
| 52 CommandLineOptions options = CommandLineOptions | 59 CommandLineOptions options = CommandLineOptions |
| 53 .parse(['--dart-sdk', '.', '--enable_type_checks', 'foo.dart']); | 60 .parse(['--dart-sdk', '.', '--enable_type_checks', 'foo.dart']); |
| 54 expect(options.enableTypeChecks, isTrue); | 61 expect(options.enableTypeChecks, isTrue); |
| 55 }); | 62 }); |
| 56 | 63 |
| 57 test('log', () { | 64 test('log', () { |
| 58 CommandLineOptions options = | 65 CommandLineOptions options = |
| 59 CommandLineOptions.parse(['--dart-sdk', '.', '--log', 'foo.dart']); | 66 CommandLineOptions.parse(['--dart-sdk', '.', '--log', 'foo.dart']); |
| 60 expect(options.log, isTrue); | 67 expect(options.log, isTrue); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 CommandLineParser parser = | 159 CommandLineParser parser = |
| 153 new CommandLineParser(alwaysIgnoreUnrecognized: true); | 160 new CommandLineParser(alwaysIgnoreUnrecognized: true); |
| 154 parser.addOption('optionA'); | 161 parser.addOption('optionA'); |
| 155 parser.addFlag('flagA'); | 162 parser.addFlag('flagA'); |
| 156 ArgResults argResults = | 163 ArgResults argResults = |
| 157 parser.parse(['--optionA=1', '--optionB=2', '--flagA'], {}); | 164 parser.parse(['--optionA=1', '--optionB=2', '--flagA'], {}); |
| 158 expect(argResults['optionA'], '1'); | 165 expect(argResults['optionA'], '1'); |
| 159 expect(argResults['flagA'], isTrue); | 166 expect(argResults['flagA'], isTrue); |
| 160 } | 167 } |
| 161 } | 168 } |
| OLD | NEW |