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

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

Issue 24243005: Use Unique<Map> in CompareMap. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Simplify Unique tests and disallow allocation during creation of unique in tests. Created 7 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
« no previous file with comments | « src/x64/lithium-x64.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-unique.cc
diff --git a/test/cctest/test-unique.cc b/test/cctest/test-unique.cc
index d482a3356aaaf818b13d2b916859c243172befc4..caa053036dd34819c083afa88d776c61e965d5c0 100644
--- a/test/cctest/test-unique.cc
+++ b/test/cctest/test-unique.cc
@@ -36,6 +36,35 @@
using namespace v8::internal;
+#define MAKE_HANDLES_AND_DISALLOW_ALLOCATION \
+Isolate* isolate = Isolate::Current(); \
+Factory* factory = isolate->factory(); \
+HandleScope sc(isolate); \
+Handle<String> handles[] = { \
+ factory->InternalizeUtf8String("A"), \
+ factory->InternalizeUtf8String("B"), \
+ factory->InternalizeUtf8String("C"), \
+ factory->InternalizeUtf8String("D"), \
+ factory->InternalizeUtf8String("E"), \
+ factory->InternalizeUtf8String("F"), \
+ factory->InternalizeUtf8String("G") \
+}; \
+DisallowHeapAllocation _disable
+
+#define MAKE_UNIQUES_A_B_C \
+ Unique<String> A(handles[0]); \
+ Unique<String> B(handles[1]); \
+ Unique<String> C(handles[2])
+
+#define MAKE_UNIQUES_A_B_C_D_E_F_G \
+ Unique<String> A(handles[0]); \
+ Unique<String> B(handles[1]); \
+ Unique<String> C(handles[2]); \
+ Unique<String> D(handles[3]); \
+ Unique<String> E(handles[4]); \
+ Unique<String> F(handles[5]); \
+ Unique<String> G(handles[6])
+
template <class T, class U>
void CheckHashCodeEqual(Unique<T> a, Unique<U> b) {
int64_t hasha = static_cast<int64_t>(a.Hashcode());
@@ -58,11 +87,9 @@ void CheckHashCodeNotEqual(Unique<T> a, Unique<U> b) {
TEST(UniqueCreate) {
CcTest::InitializeVM();
- Isolate* isolate = Isolate::Current();
- Factory* factory = isolate->factory();
- HandleScope sc(isolate);
+ MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
+ Handle<String> A = handles[0], B = handles[1];
- Handle<String> A = factory->InternalizeUtf8String("A");
Unique<String> HA(A);
CHECK(*HA.handle() == *A);
@@ -77,7 +104,6 @@ TEST(UniqueCreate) {
CHECK(HA2 == HA);
CHECK_EQ(*HA2.handle(), *HA.handle());
- Handle<String> B = factory->InternalizeUtf8String("B");
Unique<String> HB(B);
CheckHashCodeNotEqual(HA, HB);
@@ -93,11 +119,9 @@ TEST(UniqueCreate) {
TEST(UniqueSubsume) {
CcTest::InitializeVM();
- Isolate* isolate = Isolate::Current();
- Factory* factory = isolate->factory();
- HandleScope sc(isolate);
+ MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
+ Handle<String> A = handles[0];
- Handle<String> A = factory->InternalizeUtf8String("A");
Unique<String> HA(A);
CHECK(*HA.handle() == *A);
@@ -116,13 +140,8 @@ TEST(UniqueSubsume) {
TEST(UniqueSet_Add) {
CcTest::InitializeVM();
- Isolate* isolate = Isolate::Current();
- Factory* factory = isolate->factory();
- HandleScope sc(isolate);
-
- Unique<String> A(factory->InternalizeUtf8String("A"));
- Unique<String> B(factory->InternalizeUtf8String("B"));
- Unique<String> C(factory->InternalizeUtf8String("C"));
+ MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
+ MAKE_UNIQUES_A_B_C;
Zone zone(isolate);
@@ -148,13 +167,8 @@ TEST(UniqueSet_Add) {
TEST(UniqueSet_Contains) {
CcTest::InitializeVM();
- Isolate* isolate = Isolate::Current();
- Factory* factory = isolate->factory();
- HandleScope sc(isolate);
-
- Unique<String> A(factory->InternalizeUtf8String("A"));
- Unique<String> B(factory->InternalizeUtf8String("B"));
- Unique<String> C(factory->InternalizeUtf8String("C"));
+ MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
+ MAKE_UNIQUES_A_B_C;
Zone zone(isolate);
@@ -184,13 +198,8 @@ TEST(UniqueSet_Contains) {
TEST(UniqueSet_At) {
CcTest::InitializeVM();
- Isolate* isolate = Isolate::Current();
- Factory* factory = isolate->factory();
- HandleScope sc(isolate);
-
- Unique<String> A(factory->InternalizeUtf8String("A"));
- Unique<String> B(factory->InternalizeUtf8String("B"));
- Unique<String> C(factory->InternalizeUtf8String("C"));
+ MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
+ MAKE_UNIQUES_A_B_C;
Zone zone(isolate);
@@ -226,13 +235,8 @@ static void CHECK_SETS(
TEST(UniqueSet_Equals) {
CcTest::InitializeVM();
- Isolate* isolate = Isolate::Current();
- Factory* factory = isolate->factory();
- HandleScope sc(isolate);
-
- Unique<String> A(factory->InternalizeUtf8String("A"));
- Unique<String> B(factory->InternalizeUtf8String("B"));
- Unique<String> C(factory->InternalizeUtf8String("C"));
+ MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
+ MAKE_UNIQUES_A_B_C;
Zone zone(isolate);
@@ -269,13 +273,8 @@ TEST(UniqueSet_Equals) {
TEST(UniqueSet_IsSubset1) {
CcTest::InitializeVM();
- Isolate* isolate = Isolate::Current();
- Factory* factory = isolate->factory();
- HandleScope sc(isolate);
-
- Unique<String> A(factory->InternalizeUtf8String("A"));
- Unique<String> B(factory->InternalizeUtf8String("B"));
- Unique<String> C(factory->InternalizeUtf8String("C"));
+ MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
+ MAKE_UNIQUES_A_B_C;
Zone zone(isolate);
@@ -309,17 +308,8 @@ TEST(UniqueSet_IsSubset1) {
TEST(UniqueSet_IsSubset2) {
CcTest::InitializeVM();
- Isolate* isolate = Isolate::Current();
- Factory* factory = isolate->factory();
- HandleScope sc(isolate);
-
- Unique<String> A(factory->InternalizeUtf8String("A"));
- Unique<String> B(factory->InternalizeUtf8String("B"));
- Unique<String> C(factory->InternalizeUtf8String("C"));
- Unique<String> D(factory->InternalizeUtf8String("D"));
- Unique<String> E(factory->InternalizeUtf8String("E"));
- Unique<String> F(factory->InternalizeUtf8String("F"));
- Unique<String> G(factory->InternalizeUtf8String("G"));
+ MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
+ MAKE_UNIQUES_A_B_C_D_E_F_G;
Zone zone(isolate);
@@ -361,20 +351,11 @@ TEST(UniqueSet_IsSubsetExhaustive) {
const int kSetSize = 6;
CcTest::InitializeVM();
- Isolate* isolate = Isolate::Current();
- Factory* factory = isolate->factory();
- HandleScope sc(isolate);
+ MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
+ MAKE_UNIQUES_A_B_C_D_E_F_G;
Zone zone(isolate);
- Unique<String> A(factory->InternalizeUtf8String("A"));
- Unique<String> B(factory->InternalizeUtf8String("B"));
- Unique<String> C(factory->InternalizeUtf8String("C"));
- Unique<String> D(factory->InternalizeUtf8String("D"));
- Unique<String> E(factory->InternalizeUtf8String("E"));
- Unique<String> F(factory->InternalizeUtf8String("F"));
- Unique<String> G(factory->InternalizeUtf8String("G"));
-
Unique<String> elements[] = {
A, B, C, D, E, F, G
};
@@ -393,13 +374,8 @@ TEST(UniqueSet_IsSubsetExhaustive) {
TEST(UniqueSet_Intersect1) {
CcTest::InitializeVM();
- Isolate* isolate = Isolate::Current();
- Factory* factory = isolate->factory();
- HandleScope sc(isolate);
-
- Unique<String> A(factory->InternalizeUtf8String("A"));
- Unique<String> B(factory->InternalizeUtf8String("B"));
- Unique<String> C(factory->InternalizeUtf8String("C"));
+ MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
+ MAKE_UNIQUES_A_B_C;
Zone zone(isolate);
@@ -439,20 +415,11 @@ TEST(UniqueSet_IntersectExhaustive) {
const int kSetSize = 6;
CcTest::InitializeVM();
- Isolate* isolate = Isolate::Current();
- Factory* factory = isolate->factory();
- HandleScope sc(isolate);
+ MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
+ MAKE_UNIQUES_A_B_C_D_E_F_G;
Zone zone(isolate);
- Unique<String> A(factory->InternalizeUtf8String("A"));
- Unique<String> B(factory->InternalizeUtf8String("B"));
- Unique<String> C(factory->InternalizeUtf8String("C"));
- Unique<String> D(factory->InternalizeUtf8String("D"));
- Unique<String> E(factory->InternalizeUtf8String("E"));
- Unique<String> F(factory->InternalizeUtf8String("F"));
- Unique<String> G(factory->InternalizeUtf8String("G"));
-
Unique<String> elements[] = {
A, B, C, D, E, F, G
};
@@ -475,13 +442,8 @@ TEST(UniqueSet_IntersectExhaustive) {
TEST(UniqueSet_Union1) {
CcTest::InitializeVM();
- Isolate* isolate = Isolate::Current();
- Factory* factory = isolate->factory();
- HandleScope sc(isolate);
-
- Unique<String> A(factory->InternalizeUtf8String("A"));
- Unique<String> B(factory->InternalizeUtf8String("B"));
- Unique<String> C(factory->InternalizeUtf8String("C"));
+ MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
+ MAKE_UNIQUES_A_B_C;
Zone zone(isolate);
@@ -521,20 +483,11 @@ TEST(UniqueSet_UnionExhaustive) {
const int kSetSize = 6;
CcTest::InitializeVM();
- Isolate* isolate = Isolate::Current();
- Factory* factory = isolate->factory();
- HandleScope sc(isolate);
+ MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
+ MAKE_UNIQUES_A_B_C_D_E_F_G;
Zone zone(isolate);
- Unique<String> A(factory->InternalizeUtf8String("A"));
- Unique<String> B(factory->InternalizeUtf8String("B"));
- Unique<String> C(factory->InternalizeUtf8String("C"));
- Unique<String> D(factory->InternalizeUtf8String("D"));
- Unique<String> E(factory->InternalizeUtf8String("E"));
- Unique<String> F(factory->InternalizeUtf8String("F"));
- Unique<String> G(factory->InternalizeUtf8String("G"));
-
Unique<String> elements[] = {
A, B, C, D, E, F, G
};
« no previous file with comments | « src/x64/lithium-x64.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698