Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Side by Side Diff: pkg/analyzer/test/src/dart/ast/utilities_test.dart

Issue 1970053002: Update ResolutionCopier to copy TypeArgumentList of invocations. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/dart/ast/utilities.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.dart.ast.utilities_test; 5 library analyzer.test.src.dart.ast.utilities_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/token.dart'; 8 import 'package:analyzer/dart/ast/token.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/dart/element/type.dart'; 10 import 'package:analyzer/dart/element/type.dart';
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 FunctionExpressionInvocation fromNode = 657 FunctionExpressionInvocation fromNode =
658 AstFactory.functionExpressionInvocation(AstFactory.identifier3("f")); 658 AstFactory.functionExpressionInvocation(AstFactory.identifier3("f"));
659 MethodElement propagatedElement = ElementFactory.methodElement( 659 MethodElement propagatedElement = ElementFactory.methodElement(
660 "m", ElementFactory.classElement2("C").type); 660 "m", ElementFactory.classElement2("C").type);
661 fromNode.propagatedElement = propagatedElement; 661 fromNode.propagatedElement = propagatedElement;
662 MethodElement staticElement = ElementFactory.methodElement( 662 MethodElement staticElement = ElementFactory.methodElement(
663 "m", ElementFactory.classElement2("C").type); 663 "m", ElementFactory.classElement2("C").type);
664 fromNode.staticElement = staticElement; 664 fromNode.staticElement = staticElement;
665 FunctionExpressionInvocation toNode = 665 FunctionExpressionInvocation toNode =
666 AstFactory.functionExpressionInvocation(AstFactory.identifier3("f")); 666 AstFactory.functionExpressionInvocation(AstFactory.identifier3("f"));
667 ClassElement elementT = ElementFactory.classElement2('T');
668 fromNode.typeArguments =
669 AstFactory.typeArgumentList(<TypeName>[AstFactory.typeName(elementT)]);
670 toNode.typeArguments =
671 AstFactory.typeArgumentList(<TypeName>[AstFactory.typeName4('T')]);
667 672
668 _copyAndVerifyInvocation(fromNode, toNode); 673 _copyAndVerifyInvocation(fromNode, toNode);
669 674
670 expect(toNode.propagatedElement, same(propagatedElement)); 675 expect(toNode.propagatedElement, same(propagatedElement));
671 expect(toNode.staticElement, same(staticElement)); 676 expect(toNode.staticElement, same(staticElement));
672 } 677 }
673 678
674 void test_visitImportDirective() { 679 void test_visitImportDirective() {
675 ImportDirective fromNode = AstFactory.importDirective3("dart:uri", null); 680 ImportDirective fromNode = AstFactory.importDirective3("dart:uri", null);
676 ImportElement element = new ImportElementImpl(0); 681 ImportElement element = new ImportElementImpl(0);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 fromNode.staticType = staticType; 789 fromNode.staticType = staticType;
785 MapLiteral toNode = AstFactory.mapLiteral2(); 790 MapLiteral toNode = AstFactory.mapLiteral2();
786 ResolutionCopier.copyResolutionData(fromNode, toNode); 791 ResolutionCopier.copyResolutionData(fromNode, toNode);
787 expect(toNode.propagatedType, same(propagatedType)); 792 expect(toNode.propagatedType, same(propagatedType));
788 expect(toNode.staticType, same(staticType)); 793 expect(toNode.staticType, same(staticType));
789 } 794 }
790 795
791 void test_visitMethodInvocation() { 796 void test_visitMethodInvocation() {
792 MethodInvocation fromNode = AstFactory.methodInvocation2("m"); 797 MethodInvocation fromNode = AstFactory.methodInvocation2("m");
793 MethodInvocation toNode = AstFactory.methodInvocation2("m"); 798 MethodInvocation toNode = AstFactory.methodInvocation2("m");
799 ClassElement elementT = ElementFactory.classElement2('T');
800 fromNode.typeArguments =
801 AstFactory.typeArgumentList(<TypeName>[AstFactory.typeName(elementT)]);
802 toNode.typeArguments =
803 AstFactory.typeArgumentList(<TypeName>[AstFactory.typeName4('T')]);
794 _copyAndVerifyInvocation(fromNode, toNode); 804 _copyAndVerifyInvocation(fromNode, toNode);
795 } 805 }
796 806
797 void test_visitNamedExpression() { 807 void test_visitNamedExpression() {
798 NamedExpression fromNode = 808 NamedExpression fromNode =
799 AstFactory.namedExpression2("n", AstFactory.integer(0)); 809 AstFactory.namedExpression2("n", AstFactory.integer(0));
800 DartType propagatedType = ElementFactory.classElement2("C").type; 810 DartType propagatedType = ElementFactory.classElement2("C").type;
801 fromNode.propagatedType = propagatedType; 811 fromNode.propagatedType = propagatedType;
802 DartType staticType = ElementFactory.classElement2("C").type; 812 DartType staticType = ElementFactory.classElement2("C").type;
803 fromNode.staticType = staticType; 813 fromNode.staticType = staticType;
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1079 DartType propagatedInvokeType = ElementFactory.classElement2("C").type; 1089 DartType propagatedInvokeType = ElementFactory.classElement2("C").type;
1080 fromNode.propagatedInvokeType = propagatedInvokeType; 1090 fromNode.propagatedInvokeType = propagatedInvokeType;
1081 DartType staticInvokeType = ElementFactory.classElement2("C").type; 1091 DartType staticInvokeType = ElementFactory.classElement2("C").type;
1082 fromNode.staticInvokeType = staticInvokeType; 1092 fromNode.staticInvokeType = staticInvokeType;
1083 1093
1084 ResolutionCopier.copyResolutionData(fromNode, toNode); 1094 ResolutionCopier.copyResolutionData(fromNode, toNode);
1085 expect(toNode.propagatedType, same(propagatedType)); 1095 expect(toNode.propagatedType, same(propagatedType));
1086 expect(toNode.staticType, same(staticType)); 1096 expect(toNode.staticType, same(staticType));
1087 expect(toNode.propagatedInvokeType, same(propagatedInvokeType)); 1097 expect(toNode.propagatedInvokeType, same(propagatedInvokeType));
1088 expect(toNode.staticInvokeType, same(staticInvokeType)); 1098 expect(toNode.staticInvokeType, same(staticInvokeType));
1099 List<TypeName> fromTypeArguments = toNode.typeArguments.arguments;
1100 List<TypeName> toTypeArguments = fromNode.typeArguments.arguments;
1101 if (fromTypeArguments != null) {
1102 for (int i = 0; i < fromTypeArguments.length; i++) {
1103 TypeName toArgument = fromTypeArguments[i];
1104 TypeName fromArgument = toTypeArguments[i];
1105 expect(toArgument.type, same(fromArgument.type));
1106 }
1107 }
1089 } 1108 }
1090 } 1109 }
1091 1110
1092 @reflectiveTest 1111 @reflectiveTest
1093 class ToSourceVisitorTest extends EngineTestCase { 1112 class ToSourceVisitorTest extends EngineTestCase {
1094 void test_visitAdjacentStrings() { 1113 void test_visitAdjacentStrings() {
1095 _assertSource( 1114 _assertSource(
1096 "'a' 'b'", 1115 "'a' 'b'",
1097 AstFactory.adjacentStrings( 1116 AstFactory.adjacentStrings(
1098 [AstFactory.string2("a"), AstFactory.string2("b")])); 1117 [AstFactory.string2("a"), AstFactory.string2("b")]));
(...skipping 2221 matching lines...) Expand 10 before | Expand all | Expand 10 after
3320 * @param expectedSource the source string that the visitor is expected to pro duce 3339 * @param expectedSource the source string that the visitor is expected to pro duce
3321 * @param node the AST node being visited to produce the actual source 3340 * @param node the AST node being visited to produce the actual source
3322 * @throws AFE if the visitor does not produce the expected source for the giv en node 3341 * @throws AFE if the visitor does not produce the expected source for the giv en node
3323 */ 3342 */
3324 void _assertSource(String expectedSource, AstNode node) { 3343 void _assertSource(String expectedSource, AstNode node) {
3325 PrintStringWriter writer = new PrintStringWriter(); 3344 PrintStringWriter writer = new PrintStringWriter();
3326 node.accept(new ToSourceVisitor(writer)); 3345 node.accept(new ToSourceVisitor(writer));
3327 expect(writer.toString(), expectedSource); 3346 expect(writer.toString(), expectedSource);
3328 } 3347 }
3329 } 3348 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/ast/utilities.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698