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

Unified Diff: pkg/analyzer/test/generated/ast_test.dart

Issue 1212683002: AST changes necessary for generic method support (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/test/generated/ast_test.dart
diff --git a/pkg/analyzer/test/generated/ast_test.dart b/pkg/analyzer/test/generated/ast_test.dart
index e28505842f7761ba42e9b246b02a5b8975d75dc0..115a514af05b46599e8f05abd39e0bfade5354f1 100644
--- a/pkg/analyzer/test/generated/ast_test.dart
+++ b/pkg/analyzer/test/generated/ast_test.dart
@@ -2132,6 +2132,16 @@ class ToSourceVisitorTest extends EngineTestCase {
.formalParameterList([AstFactory.simpleFormalParameter3("b")])));
}
+ void test_visitFieldFormalParameter_functionTyped_typeParameters() {
+ _assertSource("A this.a<E, F>(b)", new FieldFormalParameter(null, null,
+ null, AstFactory.typeName4('A'),
+ TokenFactory.tokenFromKeyword(Keyword.THIS),
+ TokenFactory.tokenFromType(TokenType.PERIOD),
+ AstFactory.identifier3('a'), AstFactory.typeParameterList(['E', 'F']),
+ AstFactory
+ .formalParameterList([AstFactory.simpleFormalParameter3("b")])));
+ }
+
void test_visitFieldFormalParameter_keyword() {
_assertSource(
"var this.a", AstFactory.fieldFormalParameter(Keyword.VAR, null, "a"));
@@ -2406,6 +2416,13 @@ class ToSourceVisitorTest extends EngineTestCase {
null, Keyword.SET, "f", AstFactory.functionExpression()));
}
+ void test_visitFunctionDeclaration_typeParameters() {
+ _assertSource("f<E>() {}", AstFactory.functionDeclaration(null, null, "f",
+ AstFactory.functionExpression3(AstFactory.typeParameterList(['E']),
+ AstFactory.formalParameterList(),
+ AstFactory.blockFunctionBody2())));
+ }
+
void test_visitFunctionDeclaration_withMetadata() {
FunctionDeclaration declaration = AstFactory.functionDeclaration(
null, null, "f", AstFactory.functionExpression());
@@ -2423,11 +2440,23 @@ class ToSourceVisitorTest extends EngineTestCase {
_assertSource("() {}", AstFactory.functionExpression());
}
- void test_visitFunctionExpressionInvocation() {
+ void test_visitFunctionExpression_typeParameters() {
+ _assertSource("<E>() {}", AstFactory.functionExpression3(
+ AstFactory.typeParameterList(['E']), AstFactory.formalParameterList(),
+ AstFactory.blockFunctionBody2()));
+ }
+
+ void test_visitFunctionExpressionInvocation_minimal() {
_assertSource("f()",
AstFactory.functionExpressionInvocation(AstFactory.identifier3("f")));
}
+ void test_visitFunctionExpressionInvocation_typeArguments() {
+ _assertSource("f<A>()", AstFactory.functionExpressionInvocation2(
+ AstFactory.identifier3("f"),
+ AstFactory.typeArgumentList([AstFactory.typeName4('A')])));
+ }
+
void test_visitFunctionTypeAlias_generic() {
_assertSource("typedef A F<B>();", AstFactory.typeAlias(
AstFactory.typeName4("A"), "F", AstFactory.typeParameterList(["B"]),
@@ -2457,6 +2486,13 @@ class ToSourceVisitorTest extends EngineTestCase {
AstFactory.typeName4("T"), "f"));
}
+ void test_visitFunctionTypedFormalParameter_typeParameters() {
+ _assertSource("T f<E>()", new FunctionTypedFormalParameter(null, null,
+ AstFactory.typeName4("T"), AstFactory.identifier3('f'),
+ AstFactory.typeParameterList(['E']),
+ AstFactory.formalParameterList([])));
+ }
+
void test_visitIfStatement_withElse() {
_assertSource("if (c) {} else {}", AstFactory.ifStatement2(
AstFactory.identifier3("c"), AstFactory.block(), AstFactory.block()));
@@ -2758,6 +2794,12 @@ class ToSourceVisitorTest extends EngineTestCase {
AstFactory.blockFunctionBody2()));
}
+ void test_visitMethodDeclaration_typeParameters() {
+ _assertSource("m<E>() {}", AstFactory.methodDeclaration3(null, null, null,
+ null, AstFactory.identifier3("m"), AstFactory.typeParameterList(['E']),
+ AstFactory.formalParameterList(), AstFactory.blockFunctionBody2()));
+ }
+
void test_visitMethodDeclaration_withMetadata() {
MethodDeclaration declaration = AstFactory.methodDeclaration2(null, null,
null, null, AstFactory.identifier3("m"),
@@ -2781,6 +2823,11 @@ class ToSourceVisitorTest extends EngineTestCase {
"t.m()", AstFactory.methodInvocation(AstFactory.identifier3("t"), "m"));
}
+ void test_visitMethodInvocation_typeArguments() {
+ _assertSource("m<A>()", AstFactory.methodInvocation3(
+ null, "m", AstFactory.typeArgumentList([AstFactory.typeName4('A')])));
+ }
+
void test_visitNamedExpression() {
_assertSource(
"a: b", AstFactory.namedExpression2("a", AstFactory.identifier3("b")));
« pkg/analyzer/lib/src/generated/ast.dart ('K') | « pkg/analyzer/lib/src/task/dart.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698