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

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

Issue 15901004: Issue 1015. Make 'double' type contagious in some binary expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/StaticTypeAnalyzer.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/StaticTypeAnalyzer.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698