| 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 37314f9ae7ec73095c6c4b29c9363f6b3dc80e85..b08b11ce0cc3a4a63daa8fd4c41057f696f74a28 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
|
| @@ -240,14 +240,47 @@ public class StaticTypeAnalyzerTest extends EngineTestCase {
|
| listener.assertNoErrors();
|
| }
|
|
|
| - public void test_visitBinaryExpression_plus() throws Exception {
|
| - // 2 + 2
|
| - BinaryExpression node = binaryExpression(resolvedInteger(2), TokenType.PLUS, resolvedInteger(2));
|
| - node.setElement(getMethod(typeProvider.getNumType(), "+"));
|
| + public void test_visitBinaryExpression_plusID() throws Exception {
|
| + // 1 + 2.0
|
| + BinaryExpression node = binaryExpression(
|
| + resolvedInteger(1),
|
| + TokenType.PLUS,
|
| + resolvedDouble(2.0));
|
| + setStaticElement(node, getMethod(typeProvider.getNumType(), "+"));
|
| + assertSame(typeProvider.getDoubleType(), analyze(node));
|
| + listener.assertNoErrors();
|
| + }
|
| +
|
| + public void test_visitBinaryExpression_plusII() throws Exception {
|
| + // 1 + 2
|
| + BinaryExpression node = binaryExpression(resolvedInteger(1), TokenType.PLUS, resolvedInteger(2));
|
| + setStaticElement(node, getMethod(typeProvider.getNumType(), "+"));
|
| assertSame(typeProvider.getIntType(), analyze(node));
|
| listener.assertNoErrors();
|
| }
|
|
|
| + public void test_visitBinaryExpression_slash() throws Exception {
|
| + // 2 / 2
|
| + BinaryExpression node = binaryExpression(
|
| + resolvedInteger(2),
|
| + TokenType.SLASH,
|
| + resolvedInteger(2));
|
| + setStaticElement(node, getMethod(typeProvider.getNumType(), "/"));
|
| + assertSame(typeProvider.getDoubleType(), analyze(node));
|
| + listener.assertNoErrors();
|
| + }
|
| +
|
| + public void test_visitBinaryExpression_starID() throws Exception {
|
| + // 1 * 2.0
|
| + BinaryExpression node = binaryExpression(
|
| + resolvedInteger(1),
|
| + TokenType.PLUS,
|
| + resolvedDouble(2.0));
|
| + setStaticElement(node, getMethod(typeProvider.getNumType(), "*"));
|
| + assertSame(typeProvider.getDoubleType(), analyze(node));
|
| + listener.assertNoErrors();
|
| + }
|
| +
|
| public void test_visitBooleanLiteral_false() throws Exception {
|
| // false
|
| Expression node = booleanLiteral(false);
|
| @@ -1079,6 +1112,14 @@ public class StaticTypeAnalyzerTest extends EngineTestCase {
|
| }
|
|
|
| /**
|
| + * Sets the element for the node and remembers it as the static resolution.
|
| + */
|
| + private void setStaticElement(BinaryExpression node, MethodElement element) {
|
| + node.setElement(element);
|
| + analyzer.getStaticElementMap().put(node, element);
|
| + }
|
| +
|
| + /**
|
| * Set the type of the given parameter to the given type.
|
| *
|
| * @param parameter the parameter whose type is to be set
|
|
|