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

Unified Diff: runtime/vm/intermediate_language_test.cc

Issue 321593004: Refactor RangeBoundary +/- infinity to be distinct RangeBoundary kinds. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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_mips.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | 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 ac57c557aec882bd2a2d1be0317f2005d00aa241..5d42bcbef96d411fc62e83e7610601e0a76d56e9 100644
--- a/runtime/vm/intermediate_language_test.cc
+++ b/runtime/vm/intermediate_language_test.cc
@@ -53,10 +53,73 @@ TEST_CASE(RangeTests) {
Range* range_x = new Range(
RangeBoundary::FromConstant(-15),
RangeBoundary::FromConstant(100));
+ EXPECT(negative->IsNegative());
+ EXPECT(positive->IsPositive());
EXPECT(zero->Overlaps(0, 0));
EXPECT(positive->Overlaps(0, 0));
EXPECT(!negative->Overlaps(0, 0));
EXPECT(range_x->Overlaps(0, 0));
+ EXPECT(range_x->IsWithin(-15, 100));
+ EXPECT(!range_x->IsWithin(-15, 99));
+ EXPECT(!range_x->IsWithin(-14, 100));
+}
+
+
+TEST_CASE(RangeTestsInfinity) {
Vyacheslav Egorov (Google) 2014/06/09 07:43:16 I was thinking that maybe we should move all arith
+ // +/- inf overflowed.
+ EXPECT(RangeBoundary::NegativeInfinity().Overflowed());
+ EXPECT(RangeBoundary::PositiveInfinity().Overflowed());
+
+ Range* all = new Range(RangeBoundary::NegativeInfinity(),
+ RangeBoundary::PositiveInfinity());
+ EXPECT(all->Overlaps(0, 0));
+ EXPECT(all->Overlaps(-1, 1));
+ EXPECT(!all->IsWithin(0, 100));
+ Range* positive = new Range(RangeBoundary::FromConstant(0),
+ RangeBoundary::PositiveInfinity());
+ EXPECT(positive->IsPositive());
+ EXPECT(!positive->IsNegative());
+ EXPECT(positive->Overlaps(0, 1));
+ EXPECT(positive->Overlaps(1, 100));
+ EXPECT(positive->Overlaps(-1, 0));
+ EXPECT(!positive->Overlaps(-2, -1));
+ Range* negative = new Range(RangeBoundary::NegativeInfinity(),
+ RangeBoundary::FromConstant(-1));
+ EXPECT(negative->IsNegative());
+ EXPECT(!negative->IsPositive());
+ EXPECT(!negative->Overlaps(0, 1));
+ EXPECT(!negative->Overlaps(1, 100));
+ EXPECT(negative->Overlaps(-1, 0));
+ EXPECT(negative->Overlaps(-2, -1));
+ Range* negpos = new Range(RangeBoundary::NegativeInfinity(),
+ RangeBoundary::FromConstant(0));
+ EXPECT(!negpos->IsNegative());
+ EXPECT(!negpos->IsPositive());
+
+ Range* a = new Range(RangeBoundary::NegativeInfinity(),
+ RangeBoundary::FromConstant(1));
+
+ Range* b = new Range(RangeBoundary::NegativeInfinity(),
+ RangeBoundary::FromConstant(31));
+
+ Range* c = new Range(RangeBoundary::NegativeInfinity(),
+ RangeBoundary::FromConstant(32));
+
+ EXPECT(a->OnlyLessThanOrEqualTo(31));
+ EXPECT(b->OnlyLessThanOrEqualTo(31));
+ EXPECT(!c->OnlyLessThanOrEqualTo(31));
+
+ Range* unsatisfiable = new Range(RangeBoundary::PositiveInfinity(),
+ RangeBoundary::NegativeInfinity());
+ EXPECT(unsatisfiable->IsUnsatisfiable());
+
+ Range* unsatisfiable_right = new Range(RangeBoundary::PositiveInfinity(),
+ RangeBoundary::FromConstant(0));
+ EXPECT(unsatisfiable_right->IsUnsatisfiable());
+
+ Range* unsatisfiable_left = new Range(RangeBoundary::FromConstant(0),
+ RangeBoundary::NegativeInfinity());
+ EXPECT(unsatisfiable_left->IsUnsatisfiable());
}
} // namespace dart
« no previous file with comments | « runtime/vm/intermediate_language_mips.cc ('k') | runtime/vm/intermediate_language_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698