Index: test/cctest/test-types.cc |
diff --git a/test/cctest/test-types.cc b/test/cctest/test-types.cc |
index 86a8d4ee40dbf8bea93ffbcae139299d37205043..fdf5a0a9822d2c0704999141328c389a0c7e4b19 100644 |
--- a/test/cctest/test-types.cc |
+++ b/test/cctest/test-types.cc |
@@ -159,6 +159,10 @@ class Types { |
if (!IsMinusZero(x)) integers.push_back(isolate->factory()->NewNumber(x)); |
} |
+ Integer = Type::Range( |
+ isolate->factory()->NewNumber(-V8_INFINITY), |
+ isolate->factory()->NewNumber(-V8_INFINITY), region); |
+ |
NumberArray = Type::Array(Number, region); |
StringArray = Type::Array(String, region); |
AnyArray = Type::Array(Any, region); |
@@ -189,6 +193,8 @@ class Types { |
BITSET_TYPE_LIST(DECLARE_TYPE) |
#undef DECLARE_TYPE |
+ TypeHandle Integer; |
+ |
TypeHandle ObjectClass; |
TypeHandle ArrayClass; |
TypeHandle NumberClass; |
@@ -653,6 +659,21 @@ struct Tests : Rep { |
} |
} |
} |
+ |
+ // Weakening: |
+ // 1.) Range(x,y)->Is(Range(x,y)->Weaken()) |
+ // 2.) Range(x,y)->Weaken()->IsRange() iff Range(x,y)->Maybe(OtherNumber) |
+ for (ValueIterator i = T.integers.begin(); i != T.integers.end(); ++i) { |
+ for (ValueIterator j = T.integers.begin(); j != T.integers.end(); ++j) { |
+ i::Handle<i::Object> min = *i; |
+ i::Handle<i::Object> max = *j; |
+ if (min->Number() > max->Number()) std::swap(min, max); |
+ typename Type::RangeType* range = T.Range(min, max)->AsRange(); |
+ CHECK(range->Is(range->Weaken(T.region()))); |
+ CHECK(range->Weaken(T.region())->IsRange() == |
+ range->Maybe(T.OtherNumber)); |
+ } |
+ } |
} |
void Context() { |
@@ -867,6 +888,8 @@ struct Tests : Rep { |
} |
void MinMax() { |
+ Factory* fac = isolate->factory(); |
+ |
// If b is regular numeric bitset, then Range(b->Min(), b->Max())->Is(b). |
// TODO(neis): Need to ignore representation for this to be true. |
/* |
@@ -885,8 +908,7 @@ struct Tests : Rep { |
// If b is regular numeric bitset, then b->Min() and b->Max() are integers. |
for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
TypeHandle type = *it; |
- if (this->IsBitset(type) && type->Is(T.Number) && |
- !type->Is(T.None) && !type->Is(T.NaN)) { |
+ if (this->IsBitset(type) && type->Is(T.Number) && !type->Is(T.NaN)) { |
CHECK(IsInteger(type->Min()) && IsInteger(type->Max())); |
} |
} |
@@ -914,6 +936,16 @@ struct Tests : Rep { |
CHECK(lub->Min() <= type->Min() && type->Max() <= lub->Max()); |
} |
} |
+ |
+ // Rangification: If T->Is(Range(-inf,+inf)) and !T->Is(None), then |
+ // T->Is(Range(T->Min(), T->Max())). |
+ for (TypeIterator it = T.types.begin(); it != T.types.end(); ++it) { |
+ TypeHandle type = *it; |
+ CHECK( |
+ !(type->Is(T.Integer) && !type->Is(T.None)) || |
+ type->Is(T.Range( |
+ fac->NewNumber(type->Min()), fac->NewNumber(type->Max())))); |
+ } |
} |
void BitsetGlb() { |