| 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:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 | 9 |
| 10 main() { | 10 main() { |
| 11 | 11 |
| 12 group('AnalyzerOptions.parse()', () { | 12 group('AnalyzerOptions.parse()', () { |
| 13 | 13 |
| 14 test('defaults', () { | 14 test('defaults', () { |
| 15 CommandLineOptions options = | 15 CommandLineOptions options = |
| 16 CommandLineOptions.parse(['--dart-sdk', '.', 'foo.dart']); | 16 CommandLineOptions.parse(['--dart-sdk', '.', 'foo.dart']); |
| 17 expect(options, isNotNull); | 17 expect(options, isNotNull); |
| 18 expect(options.dartSdkPath, isNotNull); | 18 expect(options.dartSdkPath, isNotNull); |
| 19 expect(options.disableHints, isFalse); | 19 expect(options.disableHints, isFalse); |
| 20 expect(options.displayVersion, isFalse); | 20 expect(options.displayVersion, isFalse); |
| 21 expect(options.enableAsync, isFalse); | |
| 22 expect(options.enableEnum, isFalse); | 21 expect(options.enableEnum, isFalse); |
| 23 expect(options.enableTypeChecks, isFalse); | 22 expect(options.enableTypeChecks, isFalse); |
| 24 expect(options.ignoreUnrecognizedFlags, isFalse); | 23 expect(options.ignoreUnrecognizedFlags, isFalse); |
| 25 expect(options.log, isFalse); | 24 expect(options.log, isFalse); |
| 26 expect(options.machineFormat, isFalse); | 25 expect(options.machineFormat, isFalse); |
| 27 expect(options.packageRootPath, isNull); | 26 expect(options.packageRootPath, isNull); |
| 28 expect(options.perf, isFalse); | 27 expect(options.perf, isFalse); |
| 29 expect(options.shouldBatch, isFalse); | 28 expect(options.shouldBatch, isFalse); |
| 30 expect(options.showPackageWarnings, isFalse); | 29 expect(options.showPackageWarnings, isFalse); |
| 31 expect(options.showSdkWarnings, isFalse); | 30 expect(options.showSdkWarnings, isFalse); |
| 32 expect(options.sourceFiles, equals(['foo.dart'])); | 31 expect(options.sourceFiles, equals(['foo.dart'])); |
| 33 expect(options.warmPerf, isFalse); | 32 expect(options.warmPerf, isFalse); |
| 34 expect(options.warningsAreFatal, isFalse); | 33 expect(options.warningsAreFatal, isFalse); |
| 35 }); | 34 }); |
| 36 | 35 |
| 37 test('batch', () { | 36 test('batch', () { |
| 38 CommandLineOptions options = | 37 CommandLineOptions options = |
| 39 CommandLineOptions.parse(['--dart-sdk', '.', '--batch']); | 38 CommandLineOptions.parse(['--dart-sdk', '.', '--batch']); |
| 40 expect(options.shouldBatch, isTrue); | 39 expect(options.shouldBatch, isTrue); |
| 41 }); | 40 }); |
| 42 | 41 |
| 43 test('defined variables', () { | 42 test('defined variables', () { |
| 44 CommandLineOptions options = | 43 CommandLineOptions options = |
| 45 CommandLineOptions.parse(['--dart-sdk', '.', '-Dfoo=bar', 'foo.dart'])
; | 44 CommandLineOptions.parse(['--dart-sdk', '.', '-Dfoo=bar', 'foo.dart'])
; |
| 46 expect(options.definedVariables['foo'], equals('bar')); | 45 expect(options.definedVariables['foo'], equals('bar')); |
| 47 expect(options.definedVariables['bar'], isNull); | 46 expect(options.definedVariables['bar'], isNull); |
| 48 }); | 47 }); |
| 49 | 48 |
| 50 test('enable async', () { | |
| 51 CommandLineOptions options = | |
| 52 CommandLineOptions.parse(['--dart-sdk', '.', '--enable-async', 'foo.da
rt']); | |
| 53 expect(options.enableAsync, isTrue); | |
| 54 }); | |
| 55 | |
| 56 test('enable enum', () { | 49 test('enable enum', () { |
| 57 CommandLineOptions options = | 50 CommandLineOptions options = |
| 58 CommandLineOptions.parse(['--dart-sdk', '.', '--enable-enum', 'foo.dar
t']); | 51 CommandLineOptions.parse(['--dart-sdk', '.', '--enable-enum', 'foo.dar
t']); |
| 59 expect(options.enableEnum, isTrue); | 52 expect(options.enableEnum, isTrue); |
| 60 }); | 53 }); |
| 61 | 54 |
| 62 test('enable type checks', () { | 55 test('enable type checks', () { |
| 63 CommandLineOptions options = CommandLineOptions.parse( | 56 CommandLineOptions options = CommandLineOptions.parse( |
| 64 ['--dart-sdk', '.', '--enable_type_checks', 'foo.dart']); | 57 ['--dart-sdk', '.', '--enable_type_checks', 'foo.dart']); |
| 65 expect(options.enableTypeChecks, isTrue); | 58 expect(options.enableTypeChecks, isTrue); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // test('ignore unrecognized flags', () { | 123 // test('ignore unrecognized flags', () { |
| 131 // CommandLineOptions options = new CommandLineOptions.parse([ | 124 // CommandLineOptions options = new CommandLineOptions.parse([ |
| 132 // '--ignore_unrecognized_flags', '--bar', '--baz', 'foo.dart']); | 125 // '--ignore_unrecognized_flags', '--bar', '--baz', 'foo.dart']); |
| 133 // expect(options, isNotNull); | 126 // expect(options, isNotNull); |
| 134 // expect(options.sourceFiles, equals(['foo.dart'])); | 127 // expect(options.sourceFiles, equals(['foo.dart'])); |
| 135 // }); | 128 // }); |
| 136 | 129 |
| 137 }); | 130 }); |
| 138 | 131 |
| 139 } | 132 } |
| OLD | NEW |