| 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.summary.resynthesize_ast_test; | 5 library analyzer.test.src.summary.resynthesize_ast_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/element/element.dart'; | 8 import 'package:analyzer/dart/element/element.dart'; |
| 9 import 'package:analyzer/src/dart/element/element.dart'; | 9 import 'package:analyzer/src/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart' | 10 import 'package:analyzer/src/generated/engine.dart' |
| 11 show AnalysisContext, AnalysisOptionsImpl; | 11 show AnalysisContext, AnalysisOptionsImpl; |
| 12 import 'package:analyzer/src/generated/sdk.dart'; | 12 import 'package:analyzer/src/generated/sdk.dart'; |
| 13 import 'package:analyzer/src/generated/source.dart'; | 13 import 'package:analyzer/src/generated/source.dart'; |
| 14 import 'package:analyzer/src/summary/format.dart'; | 14 import 'package:analyzer/src/summary/format.dart'; |
| 15 import 'package:analyzer/src/summary/idl.dart'; | 15 import 'package:analyzer/src/summary/idl.dart'; |
| 16 import 'package:analyzer/src/summary/link.dart'; | 16 import 'package:analyzer/src/summary/link.dart'; |
| 17 import 'package:analyzer/src/summary/prelink.dart'; | 17 import 'package:analyzer/src/summary/prelink.dart'; |
| 18 import 'package:analyzer/src/summary/resynthesize.dart'; | 18 import 'package:analyzer/src/summary/resynthesize.dart'; |
| 19 import 'package:analyzer/src/summary/summarize_ast.dart'; | 19 import 'package:analyzer/src/summary/summarize_ast.dart'; |
| 20 import 'package:analyzer/src/summary/summarize_elements.dart' | 20 import 'package:analyzer/src/summary/summarize_elements.dart' |
| 21 show PackageBundleAssembler; | 21 show PackageBundleAssembler; |
| 22 import 'package:analyzer/task/dart.dart' show PARSED_UNIT; | 22 import 'package:analyzer/task/dart.dart' show PARSED_UNIT; |
| 23 import 'package:analyzer/task/general.dart'; | 23 import 'package:analyzer/task/general.dart'; |
| 24 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 24 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 25 import 'package:unittest/unittest.dart'; | 25 import 'package:unittest/unittest.dart'; |
| 26 | 26 |
| 27 import '../context/abstract_context.dart'; | 27 import '../context/abstract_context.dart'; |
| 28 import '../task/strong/inferred_type_test.dart'; | 28 import '../task/strong/inferred_type_test.dart'; |
| 29 import 'resynthesize_test.dart'; | 29 import 'resynthesize_common.dart'; |
| 30 import 'summary_common.dart'; | 30 import 'summary_common.dart'; |
| 31 | 31 |
| 32 main() { | 32 main() { |
| 33 groupSep = ' | '; | 33 groupSep = ' | '; |
| 34 defineReflectiveTests(ResynthesizeAstTest); | 34 defineReflectiveTests(ResynthesizeAstSpecTest); |
| 35 defineReflectiveTests(ResynthesizeAstStrongTest); |
| 35 defineReflectiveTests(AstInferredTypeTest); | 36 defineReflectiveTests(AstInferredTypeTest); |
| 36 } | 37 } |
| 37 | 38 |
| 38 @reflectiveTest | 39 @reflectiveTest |
| 39 class AstInferredTypeTest extends AbstractResynthesizeTest | 40 class AstInferredTypeTest extends AbstractResynthesizeTest |
| 40 with _AstResynthesizeTestMixin, InferredTypeMixin { | 41 with _AstResynthesizeTestMixin, InferredTypeMixin { |
| 41 bool get checkPropagatedTypes { | 42 bool get checkPropagatedTypes { |
| 42 // AST-based summaries do not yet handle propagated types. | 43 // AST-based summaries do not yet handle propagated types. |
| 43 // TODO(paulberry): fix this. | 44 // TODO(paulberry): fix this. |
| 44 return false; | 45 return false; |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 SummaryResynthesizer resynthesizer, Source source) { | 677 SummaryResynthesizer resynthesizer, Source source) { |
| 677 LibraryElementImpl resynthesized = | 678 LibraryElementImpl resynthesized = |
| 678 resynthesizer.getLibraryElement(source.uri.toString()); | 679 resynthesizer.getLibraryElement(source.uri.toString()); |
| 679 LibraryElementImpl original = context.computeLibraryElement(source); | 680 LibraryElementImpl original = context.computeLibraryElement(source); |
| 680 checkLibraryElements(original, resynthesized); | 681 checkLibraryElements(original, resynthesized); |
| 681 return resynthesized; | 682 return resynthesized; |
| 682 } | 683 } |
| 683 } | 684 } |
| 684 | 685 |
| 685 @reflectiveTest | 686 @reflectiveTest |
| 686 class ResynthesizeAstTest extends ResynthesizeTest | 687 class ResynthesizeAstSpecTest extends _ResynthesizeAstTest { |
| 687 with _AstResynthesizeTestMixin { | |
| 688 @override | 688 @override |
| 689 bool get checkPropagatedTypes => false; | 689 AnalysisOptionsImpl createOptions() => |
| 690 super.createOptions()..strongMode = false; |
| 691 } |
| 692 |
| 693 @reflectiveTest |
| 694 class ResynthesizeAstStrongTest extends _ResynthesizeAstTest { |
| 695 @override |
| 696 AnalysisOptionsImpl createOptions() => |
| 697 super.createOptions()..strongMode = true; |
| 690 | 698 |
| 691 @override | 699 @override |
| 692 LibraryElementImpl checkLibrary(String text, | 700 @failingTest |
| 693 {bool allowErrors: false, bool dumpSummaries: false}) { | 701 test_const_invokeConstructor_named_unresolved() { |
| 694 Source source = addTestSource(text); | 702 super.test_const_invokeConstructor_named_unresolved(); |
| 695 LibraryElementImpl resynthesized = _encodeDecodeLibraryElement(source); | |
| 696 LibraryElementImpl original = context.computeLibraryElement(source); | |
| 697 checkLibraryElements(original, resynthesized); | |
| 698 return resynthesized; | |
| 699 } | 703 } |
| 700 | 704 |
| 701 @override | 705 @override |
| 702 DartSdk createDartSdk() => AbstractContextTest.SHARED_MOCK_SDK; | 706 @failingTest |
| 707 test_const_invokeConstructor_named_unresolved3() { |
| 708 super.test_const_invokeConstructor_named_unresolved3(); |
| 709 } |
| 703 | 710 |
| 704 @override | 711 @override |
| 705 TestSummaryResynthesizer encodeDecodeLibrarySource(Source source) { | 712 @failingTest |
| 706 return _encodeLibrary(source); | 713 test_instantiateToBounds_boundRefersToLaterTypeArgument() { |
| 714 // TODO(paulberry): this is failing due to dartbug.com/27072. |
| 715 super.test_instantiateToBounds_boundRefersToLaterTypeArgument(); |
| 716 } |
| 717 |
| 718 @override |
| 719 @failingTest |
| 720 test_syntheticFunctionType_genericClosure() { |
| 721 super.test_syntheticFunctionType_genericClosure(); |
| 722 } |
| 723 |
| 724 @override |
| 725 @failingTest |
| 726 test_syntheticFunctionType_inGenericClass() { |
| 727 super.test_syntheticFunctionType_inGenericClass(); |
| 728 } |
| 729 |
| 730 @override |
| 731 @failingTest |
| 732 test_syntheticFunctionType_noArguments() { |
| 733 super.test_syntheticFunctionType_noArguments(); |
| 734 } |
| 735 |
| 736 @override |
| 737 @failingTest |
| 738 test_syntheticFunctionType_withArguments() { |
| 739 super.test_syntheticFunctionType_withArguments(); |
| 740 } |
| 741 |
| 742 @override |
| 743 @failingTest |
| 744 test_unused_type_parameter() { |
| 745 super.test_unused_type_parameter(); |
| 707 } | 746 } |
| 708 } | 747 } |
| 709 | 748 |
| 710 /** | 749 /** |
| 711 * Abstract mixin for serializing ASTs and resynthesizing elements from it. | 750 * Abstract mixin for serializing ASTs and resynthesizing elements from it. |
| 712 */ | 751 */ |
| 713 abstract class _AstResynthesizeTestMixin | 752 abstract class _AstResynthesizeTestMixin |
| 714 implements _AstResynthesizeTestMixinInterface { | 753 implements _AstResynthesizeTestMixinInterface { |
| 715 final Set<Source> serializedSources = new Set<Source>(); | 754 final Set<Source> serializedSources = new Set<Source>(); |
| 716 PackageBundleAssembler bundleAssembler = new PackageBundleAssembler(); | 755 PackageBundleAssembler bundleAssembler = new PackageBundleAssembler(); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 * directly, because then it would be overriding a field at the site where the | 895 * directly, because then it would be overriding a field at the site where the |
| 857 * mixin is instantiated. | 896 * mixin is instantiated. |
| 858 */ | 897 */ |
| 859 abstract class _AstResynthesizeTestMixinInterface { | 898 abstract class _AstResynthesizeTestMixinInterface { |
| 860 /** | 899 /** |
| 861 * A test should return `true` to indicate that a missing file at the time of | 900 * A test should return `true` to indicate that a missing file at the time of |
| 862 * summary resynthesis shouldn't trigger an error. | 901 * summary resynthesis shouldn't trigger an error. |
| 863 */ | 902 */ |
| 864 bool get allowMissingFiles; | 903 bool get allowMissingFiles; |
| 865 } | 904 } |
| 905 |
| 906 abstract class _ResynthesizeAstTest extends ResynthesizeTest |
| 907 with _AstResynthesizeTestMixin { |
| 908 @override |
| 909 bool get checkPropagatedTypes => false; |
| 910 |
| 911 @override |
| 912 LibraryElementImpl checkLibrary(String text, |
| 913 {bool allowErrors: false, bool dumpSummaries: false}) { |
| 914 Source source = addTestSource(text); |
| 915 LibraryElementImpl resynthesized = _encodeDecodeLibraryElement(source); |
| 916 LibraryElementImpl original = context.computeLibraryElement(source); |
| 917 checkLibraryElements(original, resynthesized); |
| 918 return resynthesized; |
| 919 } |
| 920 |
| 921 @override |
| 922 void compareLocalElementsOfExecutable(ExecutableElement resynthesized, |
| 923 ExecutableElement original, String desc) { |
| 924 // We don't resynthesize local elements during link. |
| 925 // So, we should not compare them. |
| 926 } |
| 927 |
| 928 @override |
| 929 DartSdk createDartSdk() => AbstractContextTest.SHARED_MOCK_SDK; |
| 930 |
| 931 @override |
| 932 TestSummaryResynthesizer encodeDecodeLibrarySource(Source source) { |
| 933 return _encodeLibrary(source); |
| 934 } |
| 935 } |
| OLD | NEW |