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

Side by Side Diff: test/cctest/test-unique.cc

Issue 23890030: Rollback trunk to 3.21.15. (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/mjsunit/harmony/object-observe.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 CHECK_EQ(3, set->size()); 139 CHECK_EQ(3, set->size());
140 set->Add(C, &zone); 140 set->Add(C, &zone);
141 CHECK_EQ(3, set->size()); 141 CHECK_EQ(3, set->size());
142 set->Add(B, &zone); 142 set->Add(B, &zone);
143 CHECK_EQ(3, set->size()); 143 CHECK_EQ(3, set->size());
144 set->Add(A, &zone); 144 set->Add(A, &zone);
145 CHECK_EQ(3, set->size()); 145 CHECK_EQ(3, set->size());
146 } 146 }
147 147
148 148
149 TEST(UniqueSet_Contains) {
150 CcTest::InitializeVM();
151 Isolate* isolate = Isolate::Current();
152 Factory* factory = isolate->factory();
153 HandleScope sc(isolate);
154
155 Unique<String> A(factory->InternalizeUtf8String("A"));
156 Unique<String> B(factory->InternalizeUtf8String("B"));
157 Unique<String> C(factory->InternalizeUtf8String("C"));
158
159 Zone zone(isolate);
160
161 UniqueSet<String>* set = new(&zone) UniqueSet<String>();
162
163 CHECK_EQ(0, set->size());
164 set->Add(A, &zone);
165 CHECK(set->Contains(A));
166 CHECK(!set->Contains(B));
167 CHECK(!set->Contains(C));
168
169 set->Add(A, &zone);
170 CHECK(set->Contains(A));
171 CHECK(!set->Contains(B));
172 CHECK(!set->Contains(C));
173
174 set->Add(B, &zone);
175 CHECK(set->Contains(A));
176 CHECK(set->Contains(B));
177
178 set->Add(C, &zone);
179 CHECK(set->Contains(A));
180 CHECK(set->Contains(B));
181 CHECK(set->Contains(C));
182 }
183
184
185 TEST(UniqueSet_At) {
186 CcTest::InitializeVM();
187 Isolate* isolate = Isolate::Current();
188 Factory* factory = isolate->factory();
189 HandleScope sc(isolate);
190
191 Unique<String> A(factory->InternalizeUtf8String("A"));
192 Unique<String> B(factory->InternalizeUtf8String("B"));
193 Unique<String> C(factory->InternalizeUtf8String("C"));
194
195 Zone zone(isolate);
196
197 UniqueSet<String>* set = new(&zone) UniqueSet<String>();
198
199 CHECK_EQ(0, set->size());
200 set->Add(A, &zone);
201 CHECK(A == set->at(0));
202
203 set->Add(A, &zone);
204 CHECK(A == set->at(0));
205
206 set->Add(B, &zone);
207 CHECK(A == set->at(0) || B == set->at(0));
208 CHECK(A == set->at(1) || B == set->at(1));
209
210 set->Add(C, &zone);
211 CHECK(A == set->at(0) || B == set->at(0) || C == set->at(0));
212 CHECK(A == set->at(1) || B == set->at(1) || C == set->at(1));
213 CHECK(A == set->at(2) || B == set->at(2) || C == set->at(2));
214 }
215
216
217 template <class T> 149 template <class T>
218 static void CHECK_SETS( 150 static void CHECK_SETS(
219 UniqueSet<T>* set1, UniqueSet<T>* set2, bool expected) { 151 UniqueSet<T>* set1, UniqueSet<T>* set2, bool expected) {
220 CHECK(set1->Equals(set1)); 152 CHECK(set1->Equals(set1));
221 CHECK(set2->Equals(set2)); 153 CHECK(set2->Equals(set2));
222 CHECK(expected == set1->Equals(set2)); 154 CHECK(expected == set1->Equals(set2));
223 CHECK(expected == set2->Equals(set1)); 155 CHECK(expected == set2->Equals(set1));
224 } 156 }
225 157
226 158
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 479
548 UniqueSet<String>* result = set1->Union(set2, &zone); 480 UniqueSet<String>* result = set1->Union(set2, &zone);
549 UniqueSet<String>* expected = MakeSet(&zone, i | j, elements); 481 UniqueSet<String>* expected = MakeSet(&zone, i | j, elements);
550 482
551 CHECK(result->Equals(expected)); 483 CHECK(result->Equals(expected));
552 CHECK(expected->Equals(result)); 484 CHECK(expected->Equals(result));
553 } 485 }
554 } 486 }
555 } 487 }
556 488
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/mjsunit/harmony/object-observe.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698