| 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:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 import 'package:analyzer/options.dart'; | 8 import 'package:analyzer/options.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 = CommandLineOptions | 15 CommandLineOptions options = CommandLineOptions |
| 16 .parse(['--dart-sdk', '.', 'foo.dart']); | 16 .parse(['--dart-sdk', '.', 'foo.dart']); |
| 17 expect(options, isNotNull); | 17 expect(options, isNotNull); |
| 18 expect(options.dartSdkPath, isNotNull); |
| 19 expect(options.disableHints, isFalse); |
| 20 expect(options.displayVersion, isFalse); |
| 21 expect(options.enableAsync, isFalse); |
| 22 expect(options.enableEnum, isFalse); |
| 23 expect(options.ignoreUnrecognizedFlags, isFalse); |
| 24 expect(options.log, isFalse); |
| 25 expect(options.machineFormat, isFalse); |
| 26 expect(options.packageRootPath, isNull); |
| 27 expect(options.perf, isFalse); |
| 18 expect(options.shouldBatch, isFalse); | 28 expect(options.shouldBatch, isFalse); |
| 19 expect(options.machineFormat, isFalse); | |
| 20 expect(options.displayVersion, isFalse); | |
| 21 expect(options.disableHints, isFalse); | |
| 22 expect(options.ignoreUnrecognizedFlags, isFalse); | |
| 23 expect(options.perf, isFalse); | |
| 24 expect(options.showPackageWarnings, isFalse); | 29 expect(options.showPackageWarnings, isFalse); |
| 25 expect(options.showSdkWarnings, isFalse); | 30 expect(options.showSdkWarnings, isFalse); |
| 31 expect(options.sourceFiles, equals(['foo.dart'])); |
| 32 expect(options.warmPerf, isFalse); |
| 26 expect(options.warningsAreFatal, isFalse); | 33 expect(options.warningsAreFatal, isFalse); |
| 27 expect(options.dartSdkPath, isNotNull); | |
| 28 expect(options.log, isFalse); | |
| 29 expect(options.sourceFiles, equals(['foo.dart'])); | |
| 30 }); | 34 }); |
| 31 | 35 |
| 32 test('batch', () { | 36 test('batch', () { |
| 33 CommandLineOptions options = CommandLineOptions | 37 CommandLineOptions options = CommandLineOptions |
| 34 .parse(['--dart-sdk', '.', '--batch']); | 38 .parse(['--dart-sdk', '.', '--batch']); |
| 35 expect(options.shouldBatch, isTrue); | 39 expect(options.shouldBatch, isTrue); |
| 36 }); | 40 }); |
| 37 | 41 |
| 38 test('defined variables', () { | 42 test('defined variables', () { |
| 39 CommandLineOptions options = CommandLineOptions | 43 CommandLineOptions options = CommandLineOptions |
| 40 .parse(['--dart-sdk', '.', '-Dfoo=bar', 'foo.dart']); | 44 .parse(['--dart-sdk', '.', '-Dfoo=bar', 'foo.dart']); |
| 41 expect(options.definedVariables['foo'], equals('bar')); | 45 expect(options.definedVariables['foo'], equals('bar')); |
| 42 expect(options.definedVariables['bar'], isNull); | 46 expect(options.definedVariables['bar'], isNull); |
| 43 }); | 47 }); |
| 44 | 48 |
| 49 test('enable async', () { |
| 50 CommandLineOptions options = CommandLineOptions |
| 51 .parse(['--dart-sdk', '.', '--enable-async', 'foo.dart']); |
| 52 expect(options.enableAsync, isTrue); |
| 53 }); |
| 54 |
| 55 test('enable enum', () { |
| 56 CommandLineOptions options = CommandLineOptions |
| 57 .parse(['--dart-sdk', '.', '--enable-enum', 'foo.dart']); |
| 58 expect(options.enableEnum, isTrue); |
| 59 }); |
| 60 |
| 45 test('log', () { | 61 test('log', () { |
| 46 CommandLineOptions options = CommandLineOptions | 62 CommandLineOptions options = CommandLineOptions |
| 47 .parse(['--dart-sdk', '.', '--log', 'foo.dart']); | 63 .parse(['--dart-sdk', '.', '--log', 'foo.dart']); |
| 48 expect(options.log, isTrue); | 64 expect(options.log, isTrue); |
| 49 }); | 65 }); |
| 50 | 66 |
| 51 test('machine format', () { | 67 test('machine format', () { |
| 52 CommandLineOptions options = CommandLineOptions | 68 CommandLineOptions options = CommandLineOptions |
| 53 .parse(['--dart-sdk', '.', '--format=machine', 'foo.dart']); | 69 .parse(['--dart-sdk', '.', '--format=machine', 'foo.dart']); |
| 54 expect(options.machineFormat, isTrue); | 70 expect(options.machineFormat, isTrue); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // test('ignore unrecognized flags', () { | 121 // test('ignore unrecognized flags', () { |
| 106 // CommandLineOptions options = new CommandLineOptions.parse([ | 122 // CommandLineOptions options = new CommandLineOptions.parse([ |
| 107 // '--ignore_unrecognized_flags', '--bar', '--baz', 'foo.dart']); | 123 // '--ignore_unrecognized_flags', '--bar', '--baz', 'foo.dart']); |
| 108 // expect(options, isNotNull); | 124 // expect(options, isNotNull); |
| 109 // expect(options.sourceFiles, equals(['foo.dart'])); | 125 // expect(options.sourceFiles, equals(['foo.dart'])); |
| 110 // }); | 126 // }); |
| 111 | 127 |
| 112 }); | 128 }); |
| 113 | 129 |
| 114 } | 130 } |
| OLD | NEW |