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

Unified Diff: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/resolver/StaticTypeAnalyzerTest.java

Issue 913623002: Partial backport of analyzer async/await fixes to Java. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix status files Created 5 years, 10 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: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/resolver/StaticTypeAnalyzerTest.java
diff --git a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/resolver/StaticTypeAnalyzerTest.java b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/resolver/StaticTypeAnalyzerTest.java
index e6b055530cc0e0f445796f9f95bf2553ea748df6..427d93e42892b0159d0dc61fd169c16eea1ac602 100644
--- a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/resolver/StaticTypeAnalyzerTest.java
+++ b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/resolver/StaticTypeAnalyzerTest.java
@@ -15,9 +15,12 @@ package com.google.dart.engine.internal.resolver;
import com.google.dart.engine.EngineTestCase;
import com.google.dart.engine.ast.AssignmentExpression;
+import com.google.dart.engine.ast.AstFactory;
import com.google.dart.engine.ast.BinaryExpression;
+import com.google.dart.engine.ast.BlockFunctionBody;
import com.google.dart.engine.ast.DoubleLiteral;
import com.google.dart.engine.ast.Expression;
+import com.google.dart.engine.ast.ExpressionFunctionBody;
import com.google.dart.engine.ast.FormalParameter;
import com.google.dart.engine.ast.FormalParameterList;
import com.google.dart.engine.ast.FunctionBody;
@@ -53,6 +56,7 @@ import com.google.dart.engine.internal.element.VariableElementImpl;
import com.google.dart.engine.internal.element.member.MethodMember;
import com.google.dart.engine.internal.type.FunctionTypeImpl;
import com.google.dart.engine.internal.type.InterfaceTypeImpl;
+import com.google.dart.engine.scanner.TokenFactory;
import com.google.dart.engine.scanner.TokenType;
import com.google.dart.engine.sdk.DirectoryBasedDartSdk;
import com.google.dart.engine.source.DartUriResolver;
@@ -134,6 +138,34 @@ public class StaticTypeAnalyzerTest extends EngineTestCase {
*/
private TestTypeProvider typeProvider;
+ public void fail_visitAwaitExpression_flattened() throws Exception {
+ // TODO(paulberry): Some async/await type checking has not been fully backported from dart. In
+ // particular, this test can't be implemented until Future is available in the type provider.
+ // See dartbug.com/22252.
+ fail("Test not implemented yet");
+ }
+
+ public void fail_visitAwaitExpression_simple() throws Exception {
+ // TODO(paulberry): Some async/await type checking has not been fully backported from dart. In
+ // particular, this test can't be implemented until Future is available in the type provider.
+ // See dartbug.com/22252.
+ fail("Test not implemented yet");
+ }
+
+ public void fail_visitFunctionExpression_async_expression_flatten() throws Exception {
+ // TODO(paulberry): Some async/await type checking has not been fully backported from dart. In
+ // particular, this test can't be implemented until Future is available in the type provider.
+ // See dartbug.com/22252.
+ fail("Test not implemented yet");
+ }
+
+ public void fail_visitFunctionExpression_async_expression_flatten_twice() throws Exception {
+ // TODO(paulberry): Some async/await type checking has not been fully backported from dart. In
+ // particular, this test can't be implemented until Future is available in the type provider.
+ // See dartbug.com/22252.
+ fail("Test not implemented yet");
+ }
+
public void fail_visitFunctionExpressionInvocation() throws Exception {
fail("Not yet tested");
listener.assertNoErrors();
@@ -340,6 +372,56 @@ public class StaticTypeAnalyzerTest extends EngineTestCase {
listener.assertNoErrors();
}
+ public void test_visitFunctionExpression_async_block() throws Exception {
+ // () async {}
+ BlockFunctionBody body = AstFactory.blockFunctionBody();
+ body.setKeyword(TokenFactory.tokenFromString("async"));
+ FunctionExpression node = resolvedFunctionExpression(AstFactory.formalParameterList(), body);
+ @SuppressWarnings("unused")
+ Type resultType = analyze(node);
+ // TODO(paulberry): We should check that resultType is Future<dynamic>. But we can't because
+ // the Future type isn't available in the type provider.
+ listener.assertNoErrors();
+ }
+
+ public void test_visitFunctionExpression_async_expression() throws Exception {
+ // () async => e, where e has type int
+ InterfaceType intType = typeProvider.getIntType();
+ Expression expression = resolvedVariable(intType, "e");
+ ExpressionFunctionBody body = AstFactory.expressionFunctionBody(expression);
+ body.setKeyword(TokenFactory.tokenFromString("async"));
+ FunctionExpression node = resolvedFunctionExpression(AstFactory.formalParameterList(), body);
+ @SuppressWarnings("unused")
+ Type resultType = analyze(node);
+ // TODO(paulberry): We should check that resultType is Future<int>. But we can't because the
+ // Future type isn't available in the type provider.
+ listener.assertNoErrors();
+ }
+
+ public void test_visitFunctionExpression_generator_async() throws Exception {
+ // () async* {}
+ BlockFunctionBody body = AstFactory.blockFunctionBody();
+ body.setKeyword(TokenFactory.tokenFromString("async"));
+ body.setStar(TokenFactory.tokenFromType(TokenType.STAR));
+ FunctionExpression node = resolvedFunctionExpression(AstFactory.formalParameterList(), body);
+ @SuppressWarnings("unused")
+ Type resultType = analyze(node);
+ // TODO(paulberry): we should check that resultType is Stream<dynamic>. But we can't because
+ // the Stream type isn't available in the type provider.
+ listener.assertNoErrors();
+ }
+
+ public void test_visitFunctionExpression_generator_sync() throws Exception {
+ // () sync* {}
+ BlockFunctionBody body = AstFactory.blockFunctionBody();
+ body.setKeyword(TokenFactory.tokenFromString("sync"));
+ body.setStar(TokenFactory.tokenFromType(TokenType.STAR));
+ FunctionExpression node = resolvedFunctionExpression(AstFactory.formalParameterList(), body);
+ Type resultType = analyze(node);
+ assertFunctionType(typeProvider.getIterableDynamicType(), null, null, null, resultType);
+ listener.assertNoErrors();
+ }
+
public void test_visitFunctionExpression_named_block() throws Exception {
// ({p1 : 0, p2 : 0}) {}
Type dynamicType = typeProvider.getDynamicType();
@@ -1035,7 +1117,7 @@ public class StaticTypeAnalyzerTest extends EngineTestCase {
}
}
- assertSame(expectedReturnType, functionType.getReturnType());
+ assertEquals(expectedReturnType, functionType.getReturnType());
}
private void assertType(InterfaceTypeImpl expectedType, InterfaceTypeImpl actualType) {

Powered by Google App Engine
This is Rietveld 408576698