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

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

Issue 2586363004: Support + concatenation in constant expressions with strings (Closed)
Patch Set: More tests for constant string concatenation error states Created 4 years 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/dart/ast/utilities.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 368c30700e55876299c1f7c669e4f566cfc9aa2b..8ccaa8a4e79340639d01eb2d5112a52076ca37d2 100644
--- a/pkg/analyzer/test/src/dart/ast/utilities_test.dart
+++ b/pkg/analyzer/test/src/dart/ast/utilities_test.dart
@@ -196,6 +196,11 @@ class ConstantEvaluatorTest extends ParserTestCase {
expect(value, true);
}
+ void test_binary_plus_string() {
+ Object value = _getConstantValue("'hello ' + 'world'");
+ expect(value, 'hello world');
+ }
+
void test_binary_plus_double() {
Object value = _getConstantValue("2.3 + 3.2");
expect(value, 2.3 + 3.2);
@@ -206,6 +211,26 @@ class ConstantEvaluatorTest extends ParserTestCase {
expect(value, 5);
}
+ void test_binary_plus_string_int() {
+ Object value = _getConstantValue("5 + 'world'");
+ expect(value, ConstantEvaluator.NOT_A_CONSTANT);
+ }
+
+ void test_binary_plus_int_string() {
+ Object value = _getConstantValue("'world' + 5");
+ expect(value, ConstantEvaluator.NOT_A_CONSTANT);
+ }
+
+ void test_binary_plus_double_string() {
+ Object value = _getConstantValue("'world' + 5.5");
+ expect(value, ConstantEvaluator.NOT_A_CONSTANT);
+ }
+
+ void test_binary_plus_string_double() {
+ Object value = _getConstantValue("5.5 + 'world'");
+ expect(value, ConstantEvaluator.NOT_A_CONSTANT);
+ }
+
void test_binary_remainder_double() {
Object value = _getConstantValue("3.2 % 2.3");
expect(value, 3.2 % 2.3);
« no previous file with comments | « pkg/analyzer/lib/src/dart/ast/utilities.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698