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

Unified Diff: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/constant/ConstantEvaluatorTest.java

Issue 581773002: Implement new constant expressions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments Created 6 years, 3 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/constant/ConstantEvaluatorTest.java
diff --git a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/constant/ConstantEvaluatorTest.java b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/constant/ConstantEvaluatorTest.java
index 3aaf9246e62eeaffebc04550f314a240998a07b1..8b1ba91ed8516f83ee9afce3549c974988bc265f 100644
--- a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/constant/ConstantEvaluatorTest.java
+++ b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/constant/ConstantEvaluatorTest.java
@@ -19,7 +19,7 @@ import com.google.dart.engine.ast.NodeList;
import com.google.dart.engine.ast.TopLevelVariableDeclaration;
import com.google.dart.engine.ast.VariableDeclaration;
import com.google.dart.engine.element.LibraryElement;
-import com.google.dart.engine.internal.resolver.TestTypeProvider;
+import com.google.dart.engine.internal.context.AnalysisContextImpl;
import com.google.dart.engine.resolver.ResolverTestCase;
import com.google.dart.engine.source.Source;
@@ -313,6 +313,10 @@ public class ConstantEvaluatorTest extends ResolverTestCase {
assertValue(5L, "2 + 3");
}
+ public void test_plus_string_string() throws Exception {
+ assertValue("ab", "'a' + 'b'");
+ }
+
public void test_remainder_double_double() throws Exception {
assertValue(3.2 % 2.3, "3.2 % 2.3");
}
@@ -325,6 +329,14 @@ public class ConstantEvaluatorTest extends ResolverTestCase {
assertValue(16L, "64 >> 2");
}
+ public void test_stringLength_complex() throws Exception {
+ assertValue(6L, "('qwe' + 'rty').length");
+ }
+
+ public void test_stringLength_simple() throws Exception {
+ assertValue(6L, "'Dvorak'.length");
+ }
+
public void test_times_double_double() throws Exception {
assertValue(2.3 * 3.2, "2.3 * 3.2");
}
@@ -382,7 +394,9 @@ public class ConstantEvaluatorTest extends ResolverTestCase {
assertInstanceOf(TopLevelVariableDeclaration.class, declaration);
NodeList<VariableDeclaration> variables = ((TopLevelVariableDeclaration) declaration).getVariables().getVariables();
assertSizeOfList(1, variables);
- ConstantEvaluator evaluator = new ConstantEvaluator(source, new TestTypeProvider());
+ ConstantEvaluator evaluator = new ConstantEvaluator(
+ source,
+ ((AnalysisContextImpl) getAnalysisContext()).getTypeProvider());
return evaluator.evaluate(variables.get(0).getInitializer());
}
}

Powered by Google App Engine
This is Rietveld 408576698