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

Unified Diff: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/object/DartObjectImplTest.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/internal/object/DartObjectImplTest.java
diff --git a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/object/DartObjectImplTest.java b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/object/DartObjectImplTest.java
index 367fa8da8faebc4f2a6e6cd96c6b41105899f85f..1af074f2f4bd8961cd4373ea3ba2d400cf39df13 100644
--- a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/object/DartObjectImplTest.java
+++ b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/object/DartObjectImplTest.java
@@ -25,10 +25,6 @@ import java.util.Map;
public class DartObjectImplTest extends EngineTestCase {
TypeProvider typeProvider = new TestTypeProvider();
- public void test_add_invalid_knownInt() throws EvaluationException {
- assertAdd(null, stringValue("1"), intValue(2));
- }
-
public void test_add_knownDouble_knownDouble() throws EvaluationException {
assertAdd(doubleValue(3.0), doubleValue(1.0), doubleValue(2.0));
}
@@ -45,14 +41,14 @@ public class DartObjectImplTest extends EngineTestCase {
assertAdd(doubleValue(null), doubleValue(1.0), intValue(null));
}
- public void test_add_knownInt_invalid() throws EvaluationException {
- assertAdd(null, intValue(1), stringValue("2"));
- }
-
public void test_add_knownInt_knownInt() throws EvaluationException {
assertAdd(intValue(3), intValue(1), intValue(2));
}
+ public void test_add_knownInt_knownString() throws EvaluationException {
+ assertAdd(null, intValue(1), stringValue("2"));
+ }
+
public void test_add_knownInt_unknownDouble() throws EvaluationException {
assertAdd(doubleValue(null), intValue(1), doubleValue(null));
}
@@ -61,6 +57,18 @@ public class DartObjectImplTest extends EngineTestCase {
assertAdd(intValue(null), intValue(1), intValue(null));
}
+ public void test_add_knownString_knownInt() throws EvaluationException {
+ assertAdd(null, stringValue("1"), intValue(2));
+ }
+
+ public void test_add_knownString_knownString() throws EvaluationException {
+ assertAdd(stringValue("ab"), stringValue("a"), stringValue("b"));
+ }
+
+ public void test_add_knownString_unknownString() throws EvaluationException {
+ assertAdd(stringValue(null), stringValue("a"), stringValue(null));
+ }
+
public void test_add_unknownDouble_knownDouble() throws EvaluationException {
assertAdd(doubleValue(null), doubleValue(null), doubleValue(2.0));
}
@@ -77,22 +85,30 @@ public class DartObjectImplTest extends EngineTestCase {
assertAdd(intValue(null), intValue(null), intValue(2));
}
- public void test_bitAnd_invalid_knownInt() throws EvaluationException {
- assertBitAnd(null, stringValue("6"), intValue(3));
+ public void test_add_unknownString_knownString() throws EvaluationException {
+ assertAdd(stringValue(null), stringValue(null), stringValue("b"));
}
- public void test_bitAnd_knownInt_invalid() throws EvaluationException {
- assertBitAnd(null, intValue(6), stringValue("3"));
+ public void test_add_unknownString_unknownString() throws EvaluationException {
+ assertAdd(stringValue(null), stringValue(null), stringValue(null));
}
public void test_bitAnd_knownInt_knownInt() throws EvaluationException {
assertBitAnd(intValue(2), intValue(6), intValue(3));
}
+ public void test_bitAnd_knownInt_knownString() throws EvaluationException {
+ assertBitAnd(null, intValue(6), stringValue("3"));
+ }
+
public void test_bitAnd_knownInt_unknownInt() throws EvaluationException {
assertBitAnd(intValue(null), intValue(6), intValue(null));
}
+ public void test_bitAnd_knownString_knownInt() throws EvaluationException {
+ assertBitAnd(null, stringValue("6"), intValue(3));
+ }
+
public void test_bitAnd_unknownInt_knownInt() throws EvaluationException {
assertBitAnd(intValue(null), intValue(null), intValue(3));
}
@@ -101,34 +117,34 @@ public class DartObjectImplTest extends EngineTestCase {
assertBitAnd(intValue(null), intValue(null), intValue(null));
}
- public void test_bitNot_invalid() throws EvaluationException {
- assertBitNot(null, stringValue("6"));
- }
-
public void test_bitNot_knownInt() throws EvaluationException {
assertBitNot(intValue(-4), intValue(3));
}
+ public void test_bitNot_knownString() throws EvaluationException {
+ assertBitNot(null, stringValue("6"));
+ }
+
public void test_bitNot_unknownInt() throws EvaluationException {
assertBitNot(intValue(null), intValue(null));
}
- public void test_bitOr_invalid_knownInt() throws EvaluationException {
- assertBitOr(null, stringValue("6"), intValue(3));
+ public void test_bitOr_knownInt_knownInt() throws EvaluationException {
+ assertBitOr(intValue(7), intValue(6), intValue(3));
}
- public void test_bitOr_knownInt_invalid() throws EvaluationException {
+ public void test_bitOr_knownInt_knownString() throws EvaluationException {
assertBitOr(null, intValue(6), stringValue("3"));
}
- public void test_bitOr_knownInt_knownInt() throws EvaluationException {
- assertBitOr(intValue(7), intValue(6), intValue(3));
- }
-
public void test_bitOr_knownInt_unknownInt() throws EvaluationException {
assertBitOr(intValue(null), intValue(6), intValue(null));
}
+ public void test_bitOr_knownString_knownInt() throws EvaluationException {
+ assertBitOr(null, stringValue("6"), intValue(3));
+ }
+
public void test_bitOr_unknownInt_knownInt() throws EvaluationException {
assertBitOr(intValue(null), intValue(null), intValue(3));
}
@@ -137,22 +153,22 @@ public class DartObjectImplTest extends EngineTestCase {
assertBitOr(intValue(null), intValue(null), intValue(null));
}
- public void test_bitXor_invalid_knownInt() throws EvaluationException {
- assertBitXor(null, stringValue("6"), intValue(3));
+ public void test_bitXor_knownInt_knownInt() throws EvaluationException {
+ assertBitXor(intValue(5), intValue(6), intValue(3));
}
- public void test_bitXor_knownInt_invalid() throws EvaluationException {
+ public void test_bitXor_knownInt_knownString() throws EvaluationException {
assertBitXor(null, intValue(6), stringValue("3"));
}
- public void test_bitXor_knownInt_knownInt() throws EvaluationException {
- assertBitXor(intValue(5), intValue(6), intValue(3));
- }
-
public void test_bitXor_knownInt_unknownInt() throws EvaluationException {
assertBitXor(intValue(null), intValue(6), intValue(null));
}
+ public void test_bitXor_knownString_knownInt() throws EvaluationException {
+ assertBitXor(null, stringValue("6"), intValue(3));
+ }
+
public void test_bitXor_unknownInt_knownInt() throws EvaluationException {
assertBitXor(intValue(null), intValue(null), intValue(3));
}
@@ -161,11 +177,11 @@ public class DartObjectImplTest extends EngineTestCase {
assertBitXor(intValue(null), intValue(null), intValue(null));
}
- public void test_concatenate_invalid_knownString() throws EvaluationException {
+ public void test_concatenate_knownInt_knownString() throws EvaluationException {
assertConcatenate(null, intValue(2), stringValue("def"));
}
- public void test_concatenate_knownString_invalid() throws EvaluationException {
+ public void test_concatenate_knownString_knownInt() throws EvaluationException {
assertConcatenate(null, stringValue("abc"), intValue(3));
}
@@ -181,10 +197,6 @@ public class DartObjectImplTest extends EngineTestCase {
assertConcatenate(stringValue(null), stringValue(null), stringValue("def"));
}
- public void test_divide_invalid_knownInt() throws EvaluationException {
- assertDivide(null, stringValue("6"), intValue(2));
- }
-
public void test_divide_knownDouble_knownDouble() throws EvaluationException {
assertDivide(doubleValue(3.0), doubleValue(6.0), doubleValue(2.0));
}
@@ -201,14 +213,14 @@ public class DartObjectImplTest extends EngineTestCase {
assertDivide(doubleValue(null), doubleValue(6.0), intValue(null));
}
- public void test_divide_knownInt_invalid() throws EvaluationException {
- assertDivide(null, intValue(6), stringValue("2"));
- }
-
public void test_divide_knownInt_knownInt() throws EvaluationException {
assertDivide(intValue(3), intValue(6), intValue(2));
}
+ public void test_divide_knownInt_knownString() throws EvaluationException {
+ assertDivide(null, intValue(6), stringValue("2"));
+ }
+
public void test_divide_knownInt_unknownDouble() throws EvaluationException {
assertDivide(doubleValue(null), intValue(6), doubleValue(null));
}
@@ -217,6 +229,10 @@ public class DartObjectImplTest extends EngineTestCase {
assertDivide(intValue(null), intValue(6), intValue(null));
}
+ public void test_divide_knownString_knownInt() throws EvaluationException {
+ assertDivide(null, stringValue("6"), intValue(2));
+ }
+
public void test_divide_unknownDouble_knownDouble() throws EvaluationException {
assertDivide(doubleValue(null), doubleValue(null), doubleValue(2.0));
}
@@ -402,10 +418,6 @@ public class DartObjectImplTest extends EngineTestCase {
assertNull(stringValue(null).getValue());
}
- public void test_greaterThan_invalid_knownInt() throws EvaluationException {
- assertGreaterThan(null, stringValue("1"), intValue(2));
- }
-
public void test_greaterThan_knownDouble_knownDouble_false() throws EvaluationException {
assertGreaterThan(boolValue(false), doubleValue(1.0), doubleValue(2.0));
}
@@ -430,10 +442,6 @@ public class DartObjectImplTest extends EngineTestCase {
assertGreaterThan(boolValue(null), doubleValue(1.0), intValue(null));
}
- public void test_greaterThan_knownInt_invalid() throws EvaluationException {
- assertGreaterThan(null, intValue(1), stringValue("2"));
- }
-
public void test_greaterThan_knownInt_knownInt_false() throws EvaluationException {
assertGreaterThan(boolValue(false), intValue(1), intValue(2));
}
@@ -442,6 +450,10 @@ public class DartObjectImplTest extends EngineTestCase {
assertGreaterThan(boolValue(true), intValue(2), intValue(1));
}
+ public void test_greaterThan_knownInt_knownString() throws EvaluationException {
+ assertGreaterThan(null, intValue(1), stringValue("2"));
+ }
+
public void test_greaterThan_knownInt_unknownDouble() throws EvaluationException {
assertGreaterThan(boolValue(null), intValue(1), doubleValue(null));
}
@@ -450,6 +462,10 @@ public class DartObjectImplTest extends EngineTestCase {
assertGreaterThan(boolValue(null), intValue(1), intValue(null));
}
+ public void test_greaterThan_knownString_knownInt() throws EvaluationException {
+ assertGreaterThan(null, stringValue("1"), intValue(2));
+ }
+
public void test_greaterThan_unknownDouble_knownDouble() throws EvaluationException {
assertGreaterThan(boolValue(null), doubleValue(null), doubleValue(2.0));
}
@@ -466,10 +482,6 @@ public class DartObjectImplTest extends EngineTestCase {
assertGreaterThan(boolValue(null), intValue(null), intValue(2));
}
- public void test_greaterThanOrEqual_invalid_knownInt() throws EvaluationException {
- assertGreaterThanOrEqual(null, stringValue("1"), intValue(2));
- }
-
public void test_greaterThanOrEqual_knownDouble_knownDouble_false() throws EvaluationException {
assertGreaterThanOrEqual(boolValue(false), doubleValue(1.0), doubleValue(2.0));
}
@@ -494,10 +506,6 @@ public class DartObjectImplTest extends EngineTestCase {
assertGreaterThanOrEqual(boolValue(null), doubleValue(1.0), intValue(null));
}
- public void test_greaterThanOrEqual_knownInt_invalid() throws EvaluationException {
- assertGreaterThanOrEqual(null, intValue(1), stringValue("2"));
- }
-
public void test_greaterThanOrEqual_knownInt_knownInt_false() throws EvaluationException {
assertGreaterThanOrEqual(boolValue(false), intValue(1), intValue(2));
}
@@ -506,6 +514,10 @@ public class DartObjectImplTest extends EngineTestCase {
assertGreaterThanOrEqual(boolValue(true), intValue(2), intValue(2));
}
+ public void test_greaterThanOrEqual_knownInt_knownString() throws EvaluationException {
+ assertGreaterThanOrEqual(null, intValue(1), stringValue("2"));
+ }
+
public void test_greaterThanOrEqual_knownInt_unknownDouble() throws EvaluationException {
assertGreaterThanOrEqual(boolValue(null), intValue(1), doubleValue(null));
}
@@ -514,6 +526,10 @@ public class DartObjectImplTest extends EngineTestCase {
assertGreaterThanOrEqual(boolValue(null), intValue(1), intValue(null));
}
+ public void test_greaterThanOrEqual_knownString_knownInt() throws EvaluationException {
+ assertGreaterThanOrEqual(null, stringValue("1"), intValue(2));
+ }
+
public void test_greaterThanOrEqual_unknownDouble_knownDouble() throws EvaluationException {
assertGreaterThanOrEqual(boolValue(null), doubleValue(null), doubleValue(2.0));
}
@@ -606,10 +622,6 @@ public class DartObjectImplTest extends EngineTestCase {
assertTrue(stringValue(null).hasExactValue());
}
- public void test_integerDivide_invalid_knownInt() throws EvaluationException {
- assertIntegerDivide(null, stringValue("6"), intValue(2));
- }
-
public void test_integerDivide_knownDouble_knownDouble() throws EvaluationException {
assertIntegerDivide(intValue(3), doubleValue(6.0), doubleValue(2.0));
}
@@ -626,14 +638,14 @@ public class DartObjectImplTest extends EngineTestCase {
assertIntegerDivide(intValue(null), doubleValue(6.0), intValue(null));
}
- public void test_integerDivide_knownInt_invalid() throws EvaluationException {
- assertIntegerDivide(null, intValue(6), stringValue("2"));
- }
-
public void test_integerDivide_knownInt_knownInt() throws EvaluationException {
assertIntegerDivide(intValue(3), intValue(6), intValue(2));
}
+ public void test_integerDivide_knownInt_knownString() throws EvaluationException {
+ assertIntegerDivide(null, intValue(6), stringValue("2"));
+ }
+
public void test_integerDivide_knownInt_unknownDouble() throws EvaluationException {
assertIntegerDivide(intValue(null), intValue(6), doubleValue(null));
}
@@ -642,6 +654,10 @@ public class DartObjectImplTest extends EngineTestCase {
assertIntegerDivide(intValue(null), intValue(6), intValue(null));
}
+ public void test_integerDivide_knownString_knownInt() throws EvaluationException {
+ assertIntegerDivide(null, stringValue("6"), intValue(2));
+ }
+
public void test_integerDivide_unknownDouble_knownDouble() throws EvaluationException {
assertIntegerDivide(intValue(null), doubleValue(null), doubleValue(2.0));
}
@@ -710,10 +726,6 @@ public class DartObjectImplTest extends EngineTestCase {
assertTrue(stringValue(null).isBoolNumStringOrNull());
}
- public void test_lessThan_invalid_knownInt() throws EvaluationException {
- assertLessThan(null, stringValue("1"), intValue(2));
- }
-
public void test_lessThan_knownDouble_knownDouble_false() throws EvaluationException {
assertLessThan(boolValue(false), doubleValue(2.0), doubleValue(1.0));
}
@@ -738,10 +750,6 @@ public class DartObjectImplTest extends EngineTestCase {
assertLessThan(boolValue(null), doubleValue(1.0), intValue(null));
}
- public void test_lessThan_knownInt_invalid() throws EvaluationException {
- assertLessThan(null, intValue(1), stringValue("2"));
- }
-
public void test_lessThan_knownInt_knownInt_false() throws EvaluationException {
assertLessThan(boolValue(false), intValue(2), intValue(1));
}
@@ -750,6 +758,10 @@ public class DartObjectImplTest extends EngineTestCase {
assertLessThan(boolValue(true), intValue(1), intValue(2));
}
+ public void test_lessThan_knownInt_knownString() throws EvaluationException {
+ assertLessThan(null, intValue(1), stringValue("2"));
+ }
+
public void test_lessThan_knownInt_unknownDouble() throws EvaluationException {
assertLessThan(boolValue(null), intValue(1), doubleValue(null));
}
@@ -758,6 +770,10 @@ public class DartObjectImplTest extends EngineTestCase {
assertLessThan(boolValue(null), intValue(1), intValue(null));
}
+ public void test_lessThan_knownString_knownInt() throws EvaluationException {
+ assertLessThan(null, stringValue("1"), intValue(2));
+ }
+
public void test_lessThan_unknownDouble_knownDouble() throws EvaluationException {
assertLessThan(boolValue(null), doubleValue(null), doubleValue(2.0));
}
@@ -774,10 +790,6 @@ public class DartObjectImplTest extends EngineTestCase {
assertLessThan(boolValue(null), intValue(null), intValue(2));
}
- public void test_lessThanOrEqual_invalid_knownInt() throws EvaluationException {
- assertLessThanOrEqual(null, stringValue("1"), intValue(2));
- }
-
public void test_lessThanOrEqual_knownDouble_knownDouble_false() throws EvaluationException {
assertLessThanOrEqual(boolValue(false), doubleValue(2.0), doubleValue(1.0));
}
@@ -802,10 +814,6 @@ public class DartObjectImplTest extends EngineTestCase {
assertLessThanOrEqual(boolValue(null), doubleValue(1.0), intValue(null));
}
- public void test_lessThanOrEqual_knownInt_invalid() throws EvaluationException {
- assertLessThanOrEqual(null, intValue(1), stringValue("2"));
- }
-
public void test_lessThanOrEqual_knownInt_knownInt_false() throws EvaluationException {
assertLessThanOrEqual(boolValue(false), intValue(2), intValue(1));
}
@@ -814,6 +822,10 @@ public class DartObjectImplTest extends EngineTestCase {
assertLessThanOrEqual(boolValue(true), intValue(1), intValue(2));
}
+ public void test_lessThanOrEqual_knownInt_knownString() throws EvaluationException {
+ assertLessThanOrEqual(null, intValue(1), stringValue("2"));
+ }
+
public void test_lessThanOrEqual_knownInt_unknownDouble() throws EvaluationException {
assertLessThanOrEqual(boolValue(null), intValue(1), doubleValue(null));
}
@@ -822,6 +834,10 @@ public class DartObjectImplTest extends EngineTestCase {
assertLessThanOrEqual(boolValue(null), intValue(1), intValue(null));
}
+ public void test_lessThanOrEqual_knownString_knownInt() throws EvaluationException {
+ assertLessThanOrEqual(null, stringValue("1"), intValue(2));
+ }
+
public void test_lessThanOrEqual_unknownDouble_knownDouble() throws EvaluationException {
assertLessThanOrEqual(boolValue(null), doubleValue(null), doubleValue(2.0));
}
@@ -1029,10 +1045,6 @@ public class DartObjectImplTest extends EngineTestCase {
assertLogicalOr(boolValue(true), boolValue(true), boolValue(true));
}
- public void test_minus_invalid_knownInt() throws EvaluationException {
- assertMinus(null, stringValue("4"), intValue(3));
- }
-
public void test_minus_knownDouble_knownDouble() throws EvaluationException {
assertMinus(doubleValue(1.0), doubleValue(4.0), doubleValue(3.0));
}
@@ -1049,14 +1061,14 @@ public class DartObjectImplTest extends EngineTestCase {
assertMinus(doubleValue(null), doubleValue(4.0), intValue(null));
}
- public void test_minus_knownInt_invalid() throws EvaluationException {
- assertMinus(null, intValue(4), stringValue("3"));
- }
-
public void test_minus_knownInt_knownInt() throws EvaluationException {
assertMinus(intValue(1), intValue(4), intValue(3));
}
+ public void test_minus_knownInt_knownString() throws EvaluationException {
+ assertMinus(null, intValue(4), stringValue("3"));
+ }
+
public void test_minus_knownInt_unknownDouble() throws EvaluationException {
assertMinus(doubleValue(null), intValue(4), doubleValue(null));
}
@@ -1065,6 +1077,10 @@ public class DartObjectImplTest extends EngineTestCase {
assertMinus(intValue(null), intValue(4), intValue(null));
}
+ public void test_minus_knownString_knownInt() throws EvaluationException {
+ assertMinus(null, stringValue("4"), intValue(3));
+ }
+
public void test_minus_unknownDouble_knownDouble() throws EvaluationException {
assertMinus(doubleValue(null), doubleValue(null), doubleValue(3.0));
}
@@ -1193,10 +1209,6 @@ public class DartObjectImplTest extends EngineTestCase {
assertPerformToString(stringValue(null), stringValue(null));
}
- public void test_remainder_invalid_knownInt() throws EvaluationException {
- assertRemainder(null, stringValue("7"), intValue(2));
- }
-
public void test_remainder_knownDouble_knownDouble() throws EvaluationException {
assertRemainder(doubleValue(1.0), doubleValue(7.0), doubleValue(2.0));
}
@@ -1213,14 +1225,14 @@ public class DartObjectImplTest extends EngineTestCase {
assertRemainder(doubleValue(null), doubleValue(6.0), intValue(null));
}
- public void test_remainder_knownInt_invalid() throws EvaluationException {
- assertRemainder(null, intValue(7), stringValue("2"));
- }
-
public void test_remainder_knownInt_knownInt() throws EvaluationException {
assertRemainder(intValue(1), intValue(7), intValue(2));
}
+ public void test_remainder_knownInt_knownString() throws EvaluationException {
+ assertRemainder(null, intValue(7), stringValue("2"));
+ }
+
public void test_remainder_knownInt_unknownDouble() throws EvaluationException {
assertRemainder(doubleValue(null), intValue(7), doubleValue(null));
}
@@ -1229,6 +1241,10 @@ public class DartObjectImplTest extends EngineTestCase {
assertRemainder(intValue(null), intValue(7), intValue(null));
}
+ public void test_remainder_knownString_knownInt() throws EvaluationException {
+ assertRemainder(null, stringValue("7"), intValue(2));
+ }
+
public void test_remainder_unknownDouble_knownDouble() throws EvaluationException {
assertRemainder(doubleValue(null), doubleValue(null), doubleValue(2.0));
}
@@ -1245,18 +1261,14 @@ public class DartObjectImplTest extends EngineTestCase {
assertRemainder(intValue(null), intValue(null), intValue(2));
}
- public void test_shiftLeft_invalid_knownInt() throws EvaluationException {
- assertShiftLeft(null, stringValue(null), intValue(3));
+ public void test_shiftLeft_knownInt_knownInt() throws EvaluationException {
+ assertShiftLeft(intValue(48), intValue(6), intValue(3));
}
- public void test_shiftLeft_knownInt_invalid() throws EvaluationException {
+ public void test_shiftLeft_knownInt_knownString() throws EvaluationException {
assertShiftLeft(null, intValue(6), stringValue(null));
}
- public void test_shiftLeft_knownInt_knownInt() throws EvaluationException {
- assertShiftLeft(intValue(48), intValue(6), intValue(3));
- }
-
public void test_shiftLeft_knownInt_tooLarge() throws EvaluationException {
assertShiftLeft(intValue(null), intValue(6), new DartObjectImpl(
typeProvider.getIntType(),
@@ -1267,6 +1279,10 @@ public class DartObjectImplTest extends EngineTestCase {
assertShiftLeft(intValue(null), intValue(6), intValue(null));
}
+ public void test_shiftLeft_knownString_knownInt() throws EvaluationException {
+ assertShiftLeft(null, stringValue(null), intValue(3));
+ }
+
public void test_shiftLeft_unknownInt_knownInt() throws EvaluationException {
assertShiftLeft(intValue(null), intValue(null), intValue(3));
}
@@ -1275,18 +1291,14 @@ public class DartObjectImplTest extends EngineTestCase {
assertShiftLeft(intValue(null), intValue(null), intValue(null));
}
- public void test_shiftRight_invalid_knownInt() throws EvaluationException {
- assertShiftRight(null, stringValue(null), intValue(3));
+ public void test_shiftRight_knownInt_knownInt() throws EvaluationException {
+ assertShiftRight(intValue(6), intValue(48), intValue(3));
}
- public void test_shiftRight_knownInt_invalid() throws EvaluationException {
+ public void test_shiftRight_knownInt_knownString() throws EvaluationException {
assertShiftRight(null, intValue(48), stringValue(null));
}
- public void test_shiftRight_knownInt_knownInt() throws EvaluationException {
- assertShiftRight(intValue(6), intValue(48), intValue(3));
- }
-
public void test_shiftRight_knownInt_tooLarge() throws EvaluationException {
assertShiftRight(intValue(null), intValue(48), new DartObjectImpl(
typeProvider.getIntType(),
@@ -1297,6 +1309,10 @@ public class DartObjectImplTest extends EngineTestCase {
assertShiftRight(intValue(null), intValue(48), intValue(null));
}
+ public void test_shiftRight_knownString_knownInt() throws EvaluationException {
+ assertShiftRight(null, stringValue(null), intValue(3));
+ }
+
public void test_shiftRight_unknownInt_knownInt() throws EvaluationException {
assertShiftRight(intValue(null), intValue(null), intValue(3));
}
@@ -1305,8 +1321,21 @@ public class DartObjectImplTest extends EngineTestCase {
assertShiftRight(intValue(null), intValue(null), intValue(null));
}
- public void test_times_invalid_knownInt() throws EvaluationException {
- assertTimes(null, stringValue("2"), intValue(3));
+ public void test_stringLength_int() throws EvaluationException {
+ try {
+ assertStringLength(intValue(null), intValue(0));
+ fail("Expected EvaluationException");
+ } catch (EvaluationException exception) {
+ // Expected
+ }
+ }
+
+ public void test_stringLength_knownString() throws EvaluationException {
+ assertStringLength(intValue(3), stringValue("abc"));
+ }
+
+ public void test_stringLength_unknownString() throws EvaluationException {
+ assertStringLength(intValue(null), stringValue(null));
}
public void test_times_knownDouble_knownDouble() throws EvaluationException {
@@ -1325,14 +1354,14 @@ public class DartObjectImplTest extends EngineTestCase {
assertTimes(doubleValue(null), doubleValue(2.0), intValue(null));
}
- public void test_times_knownInt_invalid() throws EvaluationException {
- assertTimes(null, intValue(2), stringValue("3"));
- }
-
public void test_times_knownInt_knownInt() throws EvaluationException {
assertTimes(intValue(6), intValue(2), intValue(3));
}
+ public void test_times_knownInt_knownString() throws EvaluationException {
+ assertTimes(null, intValue(2), stringValue("3"));
+ }
+
public void test_times_knownInt_unknownDouble() throws EvaluationException {
assertTimes(doubleValue(null), intValue(2), doubleValue(null));
}
@@ -1341,6 +1370,10 @@ public class DartObjectImplTest extends EngineTestCase {
assertTimes(intValue(null), intValue(2), intValue(null));
}
+ public void test_times_knownString_knownInt() throws EvaluationException {
+ assertTimes(null, stringValue("2"), intValue(3));
+ }
+
public void test_times_unknownDouble_knownDouble() throws EvaluationException {
assertTimes(doubleValue(null), doubleValue(null), doubleValue(3.0));
}
@@ -1934,6 +1967,30 @@ public class DartObjectImplTest extends EngineTestCase {
}
/**
+ * Assert that the length of the operand is the expected value, or that the operation throws an
+ * exception if the expected value is {@code null}.
+ *
+ * @param expected the expected result of the operation
+ * @param operand the operand to the operation
+ * @throws EvaluationException if the result is an exception when it should not be
+ */
+ private void assertStringLength(DartObjectImpl expected, DartObjectImpl operand)
+ throws EvaluationException {
+ if (expected == null) {
+ try {
+ operand.stringLength(typeProvider);
+ fail("Expected an EvaluationException");
+ } catch (EvaluationException exception) {
+ // Expected
+ }
+ } else {
+ DartObjectImpl result = operand.stringLength(typeProvider);
+ assertNotNull(result);
+ assertEquals(expected, result);
+ }
+ }
+
+ /**
* Assert that the result of multiplying the left and right operands is the expected value, or
* that the operation throws an exception if the expected value is {@code null}.
*

Powered by Google App Engine
This is Rietveld 408576698