| 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() { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 expect(options.log, isFalse); | 28 expect(options.log, isFalse); |
| 29 expect(options.sourceFiles, equals(['foo.dart'])); | 29 expect(options.sourceFiles, equals(['foo.dart'])); |
| 30 }); | 30 }); |
| 31 | 31 |
| 32 test('batch', () { | 32 test('batch', () { |
| 33 CommandLineOptions options = CommandLineOptions | 33 CommandLineOptions options = CommandLineOptions |
| 34 .parse(['--dart-sdk', '.', '--batch']); | 34 .parse(['--dart-sdk', '.', '--batch']); |
| 35 expect(options.shouldBatch, isTrue); | 35 expect(options.shouldBatch, isTrue); |
| 36 }); | 36 }); |
| 37 | 37 |
| 38 test('defined variables', () { |
| 39 CommandLineOptions options = CommandLineOptions |
| 40 .parse(['--dart-sdk', '.', '-Dfoo=bar', 'foo.dart']); |
| 41 expect(options.definedVariables['foo'], equals('bar')); |
| 42 expect(options.definedVariables['bar'], isNull); |
| 43 }); |
| 44 |
| 45 test('log', () { |
| 46 CommandLineOptions options = CommandLineOptions |
| 47 .parse(['--dart-sdk', '.', '--log', 'foo.dart']); |
| 48 expect(options.log, isTrue); |
| 49 }); |
| 50 |
| 38 test('machine format', () { | 51 test('machine format', () { |
| 39 CommandLineOptions options = CommandLineOptions | 52 CommandLineOptions options = CommandLineOptions |
| 40 .parse(['--dart-sdk', '.', '--format=machine', 'foo.dart']); | 53 .parse(['--dart-sdk', '.', '--format=machine', 'foo.dart']); |
| 41 expect(options.machineFormat, isTrue); | 54 expect(options.machineFormat, isTrue); |
| 42 }); | 55 }); |
| 43 | 56 |
| 44 test('no-hints', () { | 57 test('no-hints', () { |
| 45 CommandLineOptions options = CommandLineOptions | 58 CommandLineOptions options = CommandLineOptions |
| 46 .parse(['--dart-sdk', '.', '--no-hints', 'foo.dart']); | 59 .parse(['--dart-sdk', '.', '--no-hints', 'foo.dart']); |
| 47 expect(options.disableHints, isTrue); | 60 expect(options.disableHints, isTrue); |
| 48 }); | 61 }); |
| 49 | 62 |
| 50 test('perf', () { | 63 test('package root', () { |
| 51 CommandLineOptions options = CommandLineOptions | 64 CommandLineOptions options = CommandLineOptions |
| 52 .parse(['--dart-sdk', '.', '--perf', 'foo.dart']); | 65 .parse(['--dart-sdk', '.', '-p', 'bar', 'foo.dart']); |
| 53 expect(options.perf, isTrue); | 66 expect(options.packageRootPath, equals('bar')); |
| 54 }); | 67 }); |
| 55 | 68 |
| 56 test('package warnings', () { | 69 test('package warnings', () { |
| 57 CommandLineOptions options = CommandLineOptions | 70 CommandLineOptions options = CommandLineOptions |
| 58 .parse(['--dart-sdk', '.', '--package-warnings', 'foo.dart']); | 71 .parse(['--dart-sdk', '.', '--package-warnings', 'foo.dart']); |
| 59 expect(options.showPackageWarnings, isTrue); | 72 expect(options.showPackageWarnings, isTrue); |
| 60 }); | 73 }); |
| 61 | 74 |
| 75 test('perf', () { |
| 76 CommandLineOptions options = CommandLineOptions |
| 77 .parse(['--dart-sdk', '.', '--perf', 'foo.dart']); |
| 78 expect(options.perf, isTrue); |
| 79 }); |
| 80 |
| 62 test('sdk warnings', () { | 81 test('sdk warnings', () { |
| 63 CommandLineOptions options = CommandLineOptions | 82 CommandLineOptions options = CommandLineOptions |
| 64 .parse(['--dart-sdk', '.', '--warnings', 'foo.dart']); | 83 .parse(['--dart-sdk', '.', '--warnings', 'foo.dart']); |
| 65 expect(options.showSdkWarnings, isTrue); | 84 expect(options.showSdkWarnings, isTrue); |
| 66 }); | 85 }); |
| 67 | 86 |
| 68 test('warningsAreFatal', () { | |
| 69 CommandLineOptions options = CommandLineOptions | |
| 70 .parse(['--dart-sdk', '.', '--fatal-warnings', 'foo.dart']); | |
| 71 expect(options.warningsAreFatal, isTrue); | |
| 72 }); | |
| 73 | |
| 74 test('package root', () { | |
| 75 CommandLineOptions options = CommandLineOptions | |
| 76 .parse(['--dart-sdk', '.', '-p', 'bar', 'foo.dart']); | |
| 77 expect(options.packageRootPath, equals('bar')); | |
| 78 }); | |
| 79 | |
| 80 test('log', () { | |
| 81 CommandLineOptions options = CommandLineOptions | |
| 82 .parse(['--dart-sdk', '.', '--log', 'foo.dart']); | |
| 83 expect(options.log, isTrue); | |
| 84 }); | |
| 85 | |
| 86 test('sourceFiles', () { | 87 test('sourceFiles', () { |
| 87 CommandLineOptions options = CommandLineOptions | 88 CommandLineOptions options = CommandLineOptions |
| 88 .parse(['--dart-sdk', '.', '--log', 'foo.dart', 'foo2.dart', 'foo3.dar
t']); | 89 .parse(['--dart-sdk', '.', '--log', 'foo.dart', 'foo2.dart', 'foo3.dar
t']); |
| 89 expect(options.sourceFiles, equals(['foo.dart', 'foo2.dart', 'foo3.dart'])
); | 90 expect(options.sourceFiles, equals(['foo.dart', 'foo2.dart', 'foo3.dart'])
); |
| 90 }); | 91 }); |
| 91 | 92 |
| 93 test('warningsAreFatal', () { |
| 94 CommandLineOptions options = CommandLineOptions |
| 95 .parse(['--dart-sdk', '.', '--fatal-warnings', 'foo.dart']); |
| 96 expect(options.warningsAreFatal, isTrue); |
| 97 }); |
| 98 |
| 92 // test('notice unrecognized flags', () { | 99 // test('notice unrecognized flags', () { |
| 93 // CommandLineOptions options = new CommandLineOptions.parse(['--bar', '--b
az', | 100 // CommandLineOptions options = new CommandLineOptions.parse(['--bar', '--b
az', |
| 94 // 'foo.dart']); | 101 // 'foo.dart']); |
| 95 // expect(options, isNull); | 102 // expect(options, isNull); |
| 96 // }); | 103 // }); |
| 97 // | 104 // |
| 98 // test('ignore unrecognized flags', () { | 105 // test('ignore unrecognized flags', () { |
| 99 // CommandLineOptions options = new CommandLineOptions.parse([ | 106 // CommandLineOptions options = new CommandLineOptions.parse([ |
| 100 // '--ignore_unrecognized_flags', '--bar', '--baz', 'foo.dart']); | 107 // '--ignore_unrecognized_flags', '--bar', '--baz', 'foo.dart']); |
| 101 // expect(options, isNotNull); | 108 // expect(options, isNotNull); |
| 102 // expect(options.sourceFiles, equals(['foo.dart'])); | 109 // expect(options.sourceFiles, equals(['foo.dart'])); |
| 103 // }); | 110 // }); |
| 104 | 111 |
| 105 }); | 112 }); |
| 106 | 113 |
| 107 } | 114 } |
| OLD | NEW |