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

Unified Diff: pkg/analyzer/test/src/dart/ast/utilities_test.dart

Issue 2752853002: Improve printing of generic function types and add tests (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/dart/ast/utilities_test.dart
diff --git a/pkg/analyzer/test/src/dart/ast/utilities_test.dart b/pkg/analyzer/test/src/dart/ast/utilities_test.dart
index 2f077750c10d63f4c097ca6c25376b38278579fb..83a8b976b0c2ceae3db3b8991be557c38307d166 100644
--- a/pkg/analyzer/test/src/dart/ast/utilities_test.dart
+++ b/pkg/analyzer/test/src/dart/ast/utilities_test.dart
@@ -2509,6 +2509,33 @@ class ToSourceVisitor2Test extends EngineTestCase {
parameters: AstTestFactory.formalParameterList([])));
}
+ void test_visitGenericFunctionType() {
+ _assertSource(
+ "int Function<T>(T)",
+ AstTestFactory.genericFunctionType(
+ AstTestFactory.typeName4("int"),
+ AstTestFactory.typeParameterList(['T']),
+ AstTestFactory.formalParameterList([
+ AstTestFactory.simpleFormalParameter4(
+ AstTestFactory.typeName4("T"), null)
+ ])));
+ }
+
+ void test_visitGenericTypeAlias() {
+ _assertSource(
+ "typedef X<S> = S Function<T>(T)",
+ AstTestFactory.genericTypeAlias(
+ 'X',
+ AstTestFactory.typeParameterList(['S']),
+ AstTestFactory.genericFunctionType(
+ AstTestFactory.typeName4("S"),
+ AstTestFactory.typeParameterList(['T']),
+ AstTestFactory.formalParameterList([
+ AstTestFactory.simpleFormalParameter4(
+ AstTestFactory.typeName4("T"), null)
+ ]))));
+ }
+
void test_visitIfStatement_withElse() {
_assertSource(
"if (c) {} else {}",
@@ -4858,6 +4885,33 @@ class ToSourceVisitorTest extends EngineTestCase {
parameters: AstTestFactory.formalParameterList([])));
}
+ void test_visitGenericFunctionType() {
+ _assertSource(
+ "int Function<T>(T)",
+ AstTestFactory.genericFunctionType(
+ AstTestFactory.typeName4("int"),
+ AstTestFactory.typeParameterList(['T']),
+ AstTestFactory.formalParameterList([
+ AstTestFactory.simpleFormalParameter4(
+ AstTestFactory.typeName4("T"), null)
+ ])));
+ }
+
+ void test_visitGenericTypeAlias() {
+ _assertSource(
+ "typedef X<S> = S Function<T>(T)",
+ AstTestFactory.genericTypeAlias(
+ 'X',
+ AstTestFactory.typeParameterList(['S']),
+ AstTestFactory.genericFunctionType(
+ AstTestFactory.typeName4("S"),
+ AstTestFactory.typeParameterList(['T']),
+ AstTestFactory.formalParameterList([
+ AstTestFactory.simpleFormalParameter4(
+ AstTestFactory.typeName4("T"), null)
+ ]))));
+ }
+
void test_visitIfStatement_withElse() {
_assertSource(
"if (c) {} else {}",
« no previous file with comments | « pkg/analyzer/lib/src/generated/testing/ast_test_factory.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698