| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 analyzer.test.src.context.context_builder_test; | 5 library analyzer.test.src.context.context_builder_test; |
| 6 | 6 |
| 7 import 'package:analyzer/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
| 8 import 'package:analyzer/file_system/memory_file_system.dart'; | 8 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 9 import 'package:analyzer/plugin/options.dart'; | 9 import 'package:analyzer/plugin/options.dart'; |
| 10 import 'package:analyzer/src/context/builder.dart'; | 10 import 'package:analyzer/src/context/builder.dart'; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 expect(result[barName], hasLength(1)); | 138 expect(result[barName], hasLength(1)); |
| 139 expect(result[barName][0].path, barPath); | 139 expect(result[barName][0].path, barPath); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void test_createDefaultOptions_default() { | 142 void test_createDefaultOptions_default() { |
| 143 // Invert a subset of the options to ensure that the default options are | 143 // Invert a subset of the options to ensure that the default options are |
| 144 // being returned. | 144 // being returned. |
| 145 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); | 145 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); |
| 146 defaultOptions.dart2jsHint = !defaultOptions.dart2jsHint; | 146 defaultOptions.dart2jsHint = !defaultOptions.dart2jsHint; |
| 147 defaultOptions.enableAssertMessage = !defaultOptions.enableAssertMessage; | 147 defaultOptions.enableAssertMessage = !defaultOptions.enableAssertMessage; |
| 148 defaultOptions.enableGenericMethods = !defaultOptions.enableGenericMethods; | 148 defaultOptions.enableLazyAssignmentOperators = |
| 149 !defaultOptions.enableLazyAssignmentOperators; |
| 149 defaultOptions.enableStrictCallChecks = | 150 defaultOptions.enableStrictCallChecks = |
| 150 !defaultOptions.enableStrictCallChecks; | 151 !defaultOptions.enableStrictCallChecks; |
| 151 defaultOptions.enableSuperMixins = !defaultOptions.enableSuperMixins; | 152 defaultOptions.enableSuperMixins = !defaultOptions.enableSuperMixins; |
| 152 builderOptions.defaultOptions = defaultOptions; | 153 builderOptions.defaultOptions = defaultOptions; |
| 153 AnalysisOptions options = builder.createDefaultOptions(); | 154 AnalysisOptions options = builder.createDefaultOptions(); |
| 154 _expectEqualOptions(options, defaultOptions); | 155 _expectEqualOptions(options, defaultOptions); |
| 155 } | 156 } |
| 156 | 157 |
| 157 void test_createDefaultOptions_noDefault() { | 158 void test_createDefaultOptions_noDefault() { |
| 158 AnalysisOptions options = builder.createDefaultOptions(); | 159 AnalysisOptions options = builder.createDefaultOptions(); |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 Source htmlSource = sdk.mapDartUri('dart:html'); | 491 Source htmlSource = sdk.mapDartUri('dart:html'); |
| 491 expect( | 492 expect( |
| 492 htmlSource.fullName, | 493 htmlSource.fullName, |
| 493 resourceProvider | 494 resourceProvider |
| 494 .convertPath('/sdk/lib/html/dart2js/html_dart2js.dart')); | 495 .convertPath('/sdk/lib/html/dart2js/html_dart2js.dart')); |
| 495 expect(htmlSource.exists(), isTrue); | 496 expect(htmlSource.exists(), isTrue); |
| 496 } | 497 } |
| 497 | 498 |
| 498 void test_getAnalysisOptions_default_noOverrides() { | 499 void test_getAnalysisOptions_default_noOverrides() { |
| 499 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); | 500 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); |
| 500 defaultOptions.enableGenericMethods = true; | 501 defaultOptions.enableLazyAssignmentOperators = true; |
| 501 builderOptions.defaultOptions = defaultOptions; | 502 builderOptions.defaultOptions = defaultOptions; |
| 502 AnalysisOptionsImpl expected = new AnalysisOptionsImpl(); | 503 AnalysisOptionsImpl expected = new AnalysisOptionsImpl(); |
| 503 expected.enableGenericMethods = true; | 504 expected.enableLazyAssignmentOperators = true; |
| 504 String path = resourceProvider.convertPath('/some/directory/path'); | 505 String path = resourceProvider.convertPath('/some/directory/path'); |
| 505 String filePath = | 506 String filePath = |
| 506 pathContext.join(path, AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); | 507 pathContext.join(path, AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); |
| 507 resourceProvider.newFile( | 508 resourceProvider.newFile( |
| 508 filePath, | 509 filePath, |
| 509 ''' | 510 ''' |
| 510 linter: | 511 linter: |
| 511 rules: | 512 rules: |
| 512 - empty_constructor_bodies | 513 - empty_constructor_bodies |
| 513 '''); | 514 '''); |
| 514 | 515 |
| 515 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext(); | 516 AnalysisContext context = AnalysisEngine.instance.createAnalysisContext(); |
| 516 AnalysisOptions options = builder.getAnalysisOptions(context, path); | 517 AnalysisOptions options = builder.getAnalysisOptions(context, path); |
| 517 _expectEqualOptions(options, expected); | 518 _expectEqualOptions(options, expected); |
| 518 } | 519 } |
| 519 | 520 |
| 520 void test_getAnalysisOptions_default_overrides() { | 521 void test_getAnalysisOptions_default_overrides() { |
| 521 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); | 522 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); |
| 522 defaultOptions.enableGenericMethods = true; | 523 defaultOptions.enableLazyAssignmentOperators = true; |
| 523 builderOptions.defaultOptions = defaultOptions; | 524 builderOptions.defaultOptions = defaultOptions; |
| 524 AnalysisOptionsImpl expected = new AnalysisOptionsImpl(); | 525 AnalysisOptionsImpl expected = new AnalysisOptionsImpl(); |
| 525 expected.enableSuperMixins = true; | 526 expected.enableSuperMixins = true; |
| 526 expected.enableGenericMethods = true; | 527 expected.enableLazyAssignmentOperators = true; |
| 527 String path = resourceProvider.convertPath('/some/directory/path'); | 528 String path = resourceProvider.convertPath('/some/directory/path'); |
| 528 String filePath = | 529 String filePath = |
| 529 pathContext.join(path, AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); | 530 pathContext.join(path, AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); |
| 530 resourceProvider.newFile( | 531 resourceProvider.newFile( |
| 531 filePath, | 532 filePath, |
| 532 ''' | 533 ''' |
| 533 analyzer: | 534 analyzer: |
| 534 language: | 535 language: |
| 535 enableSuperMixins : true | 536 enableSuperMixins : true |
| 536 '''); | 537 '''); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 expect(result.path, filePath); | 671 expect(result.path, filePath); |
| 671 } | 672 } |
| 672 | 673 |
| 673 void _expectEqualOptions( | 674 void _expectEqualOptions( |
| 674 AnalysisOptionsImpl actual, AnalysisOptionsImpl expected) { | 675 AnalysisOptionsImpl actual, AnalysisOptionsImpl expected) { |
| 675 // TODO(brianwilkerson) Consider moving this to AnalysisOptionsImpl.==. | 676 // TODO(brianwilkerson) Consider moving this to AnalysisOptionsImpl.==. |
| 676 expect(actual.analyzeFunctionBodiesPredicate, | 677 expect(actual.analyzeFunctionBodiesPredicate, |
| 677 same(expected.analyzeFunctionBodiesPredicate)); | 678 same(expected.analyzeFunctionBodiesPredicate)); |
| 678 expect(actual.dart2jsHint, expected.dart2jsHint); | 679 expect(actual.dart2jsHint, expected.dart2jsHint); |
| 679 expect(actual.enableAssertMessage, expected.enableAssertMessage); | 680 expect(actual.enableAssertMessage, expected.enableAssertMessage); |
| 681 expect(actual.enableLazyAssignmentOperators, |
| 682 expected.enableLazyAssignmentOperators); |
| 680 expect(actual.enableStrictCallChecks, expected.enableStrictCallChecks); | 683 expect(actual.enableStrictCallChecks, expected.enableStrictCallChecks); |
| 681 expect(actual.enableGenericMethods, expected.enableGenericMethods); | |
| 682 expect(actual.enableSuperMixins, expected.enableSuperMixins); | 684 expect(actual.enableSuperMixins, expected.enableSuperMixins); |
| 683 expect(actual.enableTiming, expected.enableTiming); | 685 expect(actual.enableTiming, expected.enableTiming); |
| 684 expect(actual.generateImplicitErrors, expected.generateImplicitErrors); | 686 expect(actual.generateImplicitErrors, expected.generateImplicitErrors); |
| 685 expect(actual.generateSdkErrors, expected.generateSdkErrors); | 687 expect(actual.generateSdkErrors, expected.generateSdkErrors); |
| 686 expect(actual.hint, expected.hint); | 688 expect(actual.hint, expected.hint); |
| 687 expect(actual.incremental, expected.incremental); | 689 expect(actual.incremental, expected.incremental); |
| 688 expect(actual.incrementalApi, expected.incrementalApi); | 690 expect(actual.incrementalApi, expected.incrementalApi); |
| 689 expect(actual.incrementalValidation, expected.incrementalValidation); | 691 expect(actual.incrementalValidation, expected.incrementalValidation); |
| 690 expect(actual.lint, expected.lint); | 692 expect(actual.lint, expected.lint); |
| 691 expect(actual.preserveComments, expected.preserveComments); | 693 expect(actual.preserveComments, expected.preserveComments); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 fail('Unexpected invocation of optionsProcessed'); | 745 fail('Unexpected invocation of optionsProcessed'); |
| 744 } | 746 } |
| 745 expect(options, hasLength(expectedOptions.length)); | 747 expect(options, hasLength(expectedOptions.length)); |
| 746 for (String key in expectedOptions.keys) { | 748 for (String key in expectedOptions.keys) { |
| 747 expect(options.containsKey(key), isTrue, reason: 'missing key $key'); | 749 expect(options.containsKey(key), isTrue, reason: 'missing key $key'); |
| 748 expect(options[key], expectedOptions[key], | 750 expect(options[key], expectedOptions[key], |
| 749 reason: 'values for key $key do not match'); | 751 reason: 'values for key $key do not match'); |
| 750 } | 752 } |
| 751 } | 753 } |
| 752 } | 754 } |
| OLD | NEW |