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

Unified Diff: test/cctest/test-types.cc

Issue 437393005: Extend some operations to range types. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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
« src/types.cc ('K') | « src/types.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-types.cc
diff --git a/test/cctest/test-types.cc b/test/cctest/test-types.cc
index 753457366701c26be2af0c798663fac2e7a092aa..bd13a451acd8bbedc0f2baa7f74c47417f449430 100644
--- a/test/cctest/test-types.cc
+++ b/test/cctest/test-types.cc
@@ -189,6 +189,23 @@ class Types {
ValueVector values;
DoubleVector doubles; // Some floating-point values, excluding NaN.
+ // Range type helper functions, partially copied from types.cc.
+ // Note: le(min(x,y), max(x,y)) holds iff neither x nor y is NaN.
+ static bool le(double x, double y) {
rossberg 2014/08/06 13:27:31 Hint: If you just don't make them static, then you
+ return x <= y && copysign(1, x) <= copysign(1, y);
+ }
+ static bool eq(double x, double y) {
+ return le(x, y) && le(y, x);
+ }
+ static double min(double x, double y) {
+ return le(x, y) ? x : y;
+ }
+ static double max(double x, double y) {
+ return le(x, y) ? y : x;
+ }
+
+
+
TypeHandle Of(Handle<i::Object> value) {
return Type::Of(value, region_);
}
@@ -549,8 +566,8 @@ struct Tests : Rep {
// Constructor
for (DoubleIterator i = T.doubles.begin(); i != T.doubles.end(); ++i) {
for (DoubleIterator j = T.doubles.begin(); j != T.doubles.end(); ++j) {
- double min = std::min(*i, *j);
- double max = std::max(*i, *j);
+ double min = TypesInstance::min(*i, *j);
+ double max = TypesInstance::max(*i, *j);
TypeHandle type = T.Range(min, max);
CHECK(type->IsRange());
}
@@ -559,8 +576,8 @@ struct Tests : Rep {
// Range attributes
for (DoubleIterator i = T.doubles.begin(); i != T.doubles.end(); ++i) {
for (DoubleIterator j = T.doubles.begin(); j != T.doubles.end(); ++j) {
- double min = std::min(*i, *j);
- double max = std::max(*i, *j);
+ double min = TypesInstance::min(*i, *j);
+ double max = TypesInstance::max(*i, *j);
printf("RangeType: min, max = %f, %f\n", min, max);
TypeHandle type = T.Range(min, max);
printf("RangeType: Min, Max = %f, %f\n",
@@ -579,13 +596,13 @@ struct Tests : Rep {
// i2 != T.doubles.end(); ++i2) {
// for (DoubleIterator j2 = T.doubles.begin();
// j2 != T.doubles.end(); ++j2) {
-// double min1 = std::min(*i1, *j1);
-// double max1 = std::max(*i1, *j1);
-// double min2 = std::min(*i2, *j2);
-// double max2 = std::max(*i2, *j2);
+// double min1 = TypesInstance::min(*i1, *j1);
+// double max1 = TypesInstance::max(*i1, *j1);
+// double min2 = TypesInstance::min(*i2, *j2);
+// double max2 = TypesInstance::max(*i2, *j2);
// TypeHandle type1 = T.Range(min1, max1);
// TypeHandle type2 = T.Range(min2, max2);
-// CHECK(Equal(type1, type2) == (min1 == min2 && max1 == max2));
+// CHECK(Equal(type1, type2) == (eq(min1, min2) && eq(max1, max2)));
// }
// }
// }
« src/types.cc ('K') | « src/types.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698