| 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.enableEnum, isFalse); | |
| 22 expect(options.enableTypeChecks, isFalse); | 21 expect(options.enableTypeChecks, isFalse); |
| 23 expect(options.ignoreUnrecognizedFlags, isFalse); | 22 expect(options.ignoreUnrecognizedFlags, isFalse); |
| 24 expect(options.log, isFalse); | 23 expect(options.log, isFalse); |
| 25 expect(options.machineFormat, isFalse); | 24 expect(options.machineFormat, isFalse); |
| 26 expect(options.packageRootPath, isNull); | 25 expect(options.packageRootPath, isNull); |
| 27 expect(options.perf, isFalse); | 26 expect(options.perf, isFalse); |
| 28 expect(options.shouldBatch, isFalse); | 27 expect(options.shouldBatch, isFalse); |
| 29 expect(options.showPackageWarnings, isFalse); | 28 expect(options.showPackageWarnings, isFalse); |
| 30 expect(options.showSdkWarnings, isFalse); | 29 expect(options.showSdkWarnings, isFalse); |
| 31 expect(options.sourceFiles, equals(['foo.dart'])); | 30 expect(options.sourceFiles, equals(['foo.dart'])); |
| 32 expect(options.warmPerf, isFalse); | 31 expect(options.warmPerf, isFalse); |
| 33 expect(options.warningsAreFatal, isFalse); | 32 expect(options.warningsAreFatal, isFalse); |
| 34 }); | 33 }); |
| 35 | 34 |
| 36 test('batch', () { | 35 test('batch', () { |
| 37 CommandLineOptions options = | 36 CommandLineOptions options = |
| 38 CommandLineOptions.parse(['--dart-sdk', '.', '--batch']); | 37 CommandLineOptions.parse(['--dart-sdk', '.', '--batch']); |
| 39 expect(options.shouldBatch, isTrue); | 38 expect(options.shouldBatch, isTrue); |
| 40 }); | 39 }); |
| 41 | 40 |
| 42 test('defined variables', () { | 41 test('defined variables', () { |
| 43 CommandLineOptions options = | 42 CommandLineOptions options = |
| 44 CommandLineOptions.parse(['--dart-sdk', '.', '-Dfoo=bar', 'foo.dart'])
; | 43 CommandLineOptions.parse(['--dart-sdk', '.', '-Dfoo=bar', 'foo.dart'])
; |
| 45 expect(options.definedVariables['foo'], equals('bar')); | 44 expect(options.definedVariables['foo'], equals('bar')); |
| 46 expect(options.definedVariables['bar'], isNull); | 45 expect(options.definedVariables['bar'], isNull); |
| 47 }); | 46 }); |
| 48 | 47 |
| 49 test('enable enum', () { | |
| 50 CommandLineOptions options = | |
| 51 CommandLineOptions.parse(['--dart-sdk', '.', '--enable-enum', 'foo.dar
t']); | |
| 52 expect(options.enableEnum, isTrue); | |
| 53 }); | |
| 54 | |
| 55 test('enable type checks', () { | 48 test('enable type checks', () { |
| 56 CommandLineOptions options = CommandLineOptions.parse( | 49 CommandLineOptions options = CommandLineOptions.parse( |
| 57 ['--dart-sdk', '.', '--enable_type_checks', 'foo.dart']); | 50 ['--dart-sdk', '.', '--enable_type_checks', 'foo.dart']); |
| 58 expect(options.enableTypeChecks, isTrue); | 51 expect(options.enableTypeChecks, isTrue); |
| 59 }); | 52 }); |
| 60 | 53 |
| 61 test('log', () { | 54 test('log', () { |
| 62 CommandLineOptions options = | 55 CommandLineOptions options = |
| 63 CommandLineOptions.parse(['--dart-sdk', '.', '--log', 'foo.dart']); | 56 CommandLineOptions.parse(['--dart-sdk', '.', '--log', 'foo.dart']); |
| 64 expect(options.log, isTrue); | 57 expect(options.log, isTrue); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // test('ignore unrecognized flags', () { | 116 // test('ignore unrecognized flags', () { |
| 124 // CommandLineOptions options = new CommandLineOptions.parse([ | 117 // CommandLineOptions options = new CommandLineOptions.parse([ |
| 125 // '--ignore_unrecognized_flags', '--bar', '--baz', 'foo.dart']); | 118 // '--ignore_unrecognized_flags', '--bar', '--baz', 'foo.dart']); |
| 126 // expect(options, isNotNull); | 119 // expect(options, isNotNull); |
| 127 // expect(options.sourceFiles, equals(['foo.dart'])); | 120 // expect(options.sourceFiles, equals(['foo.dart'])); |
| 128 // }); | 121 // }); |
| 129 | 122 |
| 130 }); | 123 }); |
| 131 | 124 |
| 132 } | 125 } |
| OLD | NEW |