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

Unified Diff: runtime/vm/intermediate_language_test.cc

Issue 402913002: Don't force range of the RangeBoundary::Shl into the Smi. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix the tests Created 6 years, 5 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 | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language_test.cc
diff --git a/runtime/vm/intermediate_language_test.cc b/runtime/vm/intermediate_language_test.cc
index 918849b0db823975108b905eddf1d7f470084781..67f304efbbce2263b050fdc47a4fc109b486d9b4 100644
--- a/runtime/vm/intermediate_language_test.cc
+++ b/runtime/vm/intermediate_language_test.cc
@@ -62,7 +62,7 @@ TEST_CASE(RangeTests) {
EXPECT(!range_x->IsWithin(-15, 99));
EXPECT(!range_x->IsWithin(-14, 100));
-#define TEST_RANGE_OP(Op, l_min, l_max, r_min, r_max, result_min, result_max) \
+#define TEST_RANGE_OP_(Op, l_min, l_max, r_min, r_max, Clamp, res_min, res_max)\
{ \
RangeBoundary min, max; \
Range* left_range = new Range( \
@@ -72,12 +72,24 @@ TEST_CASE(RangeTests) {
RangeBoundary::FromConstant(r_min), \
RangeBoundary::FromConstant(r_max)); \
Op(left_range, shift_range, &min, &max); \
- EXPECT(min.Equals(result_min)); \
- if (!min.Equals(result_min)) OS::Print("%s\n", min.ToCString()); \
- EXPECT(max.Equals(result_max)); \
- if (!max.Equals(result_max)) OS::Print("%s\n", max.ToCString()); \
+ min = Clamp(min); \
+ max = Clamp(max); \
+ EXPECT(min.Equals(res_min)); \
+ if (!min.Equals(res_min)) OS::Print("%s\n", min.ToCString()); \
+ EXPECT(max.Equals(res_max)); \
+ if (!max.Equals(res_max)) OS::Print("%s\n", max.ToCString()); \
}
+#define NO_CLAMP(b) (b)
+#define TEST_RANGE_OP(Op, l_min, l_max, r_min, r_max, result_min, result_max) \
+ TEST_RANGE_OP_(Op, l_min, l_max, r_min, r_max, \
+ NO_CLAMP, result_min, result_max)
+
+#define CLAMP_TO_SMI(b) (b.Clamp(RangeBoundary::kRangeBoundarySmi))
+#define TEST_RANGE_OP_SMI(Op, l_min, l_max, r_min, r_max, res_min, res_max) \
+ TEST_RANGE_OP_(Op, l_min, l_max, r_min, r_max, \
+ CLAMP_TO_SMI, res_min, res_max)
+
TEST_RANGE_OP(Range::Shl, -15, 100, 0, 2,
RangeBoundary(-60), RangeBoundary(400));
TEST_RANGE_OP(Range::Shl, -15, 100, -2, 2,
@@ -90,22 +102,22 @@ TEST_CASE(RangeTests) {
RangeBoundary::NegativeInfinity(),
RangeBoundary::PositiveInfinity());
TEST_RANGE_OP(Range::Shl, -1, 1, 63, 63,
- RangeBoundary::NegativeInfinity(),
+ RangeBoundary(kMinInt64),
RangeBoundary::PositiveInfinity());
if (kBitsPerWord == 64) {
- TEST_RANGE_OP(Range::Shl, -1, 1, 62, 62,
+ TEST_RANGE_OP_SMI(Range::Shl, -1, 1, 62, 62,
RangeBoundary(kSmiMin),
- RangeBoundary::PositiveInfinity());
- TEST_RANGE_OP(Range::Shl, -1, 1, 30, 30,
+ RangeBoundary(kSmiMax));
+ TEST_RANGE_OP_SMI(Range::Shl, -1, 1, 30, 30,
RangeBoundary(-1 << 30),
RangeBoundary(1 << 30));
} else {
- TEST_RANGE_OP(Range::Shl, -1, 1, 30, 30,
+ TEST_RANGE_OP_SMI(Range::Shl, -1, 1, 30, 30,
+ RangeBoundary(kSmiMin),
+ RangeBoundary(kSmiMax));
+ TEST_RANGE_OP_SMI(Range::Shl, -1, 1, 62, 62,
RangeBoundary(kSmiMin),
- RangeBoundary::PositiveInfinity());
- TEST_RANGE_OP(Range::Shl, -1, 1, 62, 62,
- RangeBoundary::NegativeInfinity(),
- RangeBoundary::PositiveInfinity());
+ RangeBoundary(kSmiMax));
}
TEST_RANGE_OP(Range::Shl, 0, 100, 0, 64,
RangeBoundary(0), RangeBoundary::PositiveInfinity());
« no previous file with comments | « runtime/vm/intermediate_language.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698