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

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

Issue 2394213003: Named all zones in the project (Closed)
Patch Set: Merge branch 'master' into zonenames Created 4 years, 2 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
« no previous file with comments | « test/cctest/test-types.cc ('k') | test/cctest/wasm/test-run-wasm.cc » ('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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 CHECK(HO == HA); 143 CHECK(HO == HA);
144 CHECK_EQ(*HO.handle(), *HA.handle()); 144 CHECK_EQ(*HO.handle(), *HA.handle());
145 } 145 }
146 146
147 147
148 TEST(UniqueSet_Add) { 148 TEST(UniqueSet_Add) {
149 CcTest::InitializeVM(); 149 CcTest::InitializeVM();
150 MAKE_HANDLES_AND_DISALLOW_ALLOCATION; 150 MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
151 MAKE_UNIQUES_A_B_C; 151 MAKE_UNIQUES_A_B_C;
152 152
153 Zone zone(CcTest::i_isolate()->allocator()); 153 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
154 154
155 UniqueSet<String>* set = new(&zone) UniqueSet<String>(); 155 UniqueSet<String>* set = new(&zone) UniqueSet<String>();
156 156
157 CHECK_EQ(0, set->size()); 157 CHECK_EQ(0, set->size());
158 set->Add(A, &zone); 158 set->Add(A, &zone);
159 CHECK_EQ(1, set->size()); 159 CHECK_EQ(1, set->size());
160 set->Add(A, &zone); 160 set->Add(A, &zone);
161 CHECK_EQ(1, set->size()); 161 CHECK_EQ(1, set->size());
162 set->Add(B, &zone); 162 set->Add(B, &zone);
163 CHECK_EQ(2, set->size()); 163 CHECK_EQ(2, set->size());
164 set->Add(C, &zone); 164 set->Add(C, &zone);
165 CHECK_EQ(3, set->size()); 165 CHECK_EQ(3, set->size());
166 set->Add(C, &zone); 166 set->Add(C, &zone);
167 CHECK_EQ(3, set->size()); 167 CHECK_EQ(3, set->size());
168 set->Add(B, &zone); 168 set->Add(B, &zone);
169 CHECK_EQ(3, set->size()); 169 CHECK_EQ(3, set->size());
170 set->Add(A, &zone); 170 set->Add(A, &zone);
171 CHECK_EQ(3, set->size()); 171 CHECK_EQ(3, set->size());
172 } 172 }
173 173
174 174
175 TEST(UniqueSet_Remove) { 175 TEST(UniqueSet_Remove) {
176 CcTest::InitializeVM(); 176 CcTest::InitializeVM();
177 MAKE_HANDLES_AND_DISALLOW_ALLOCATION; 177 MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
178 MAKE_UNIQUES_A_B_C; 178 MAKE_UNIQUES_A_B_C;
179 179
180 Zone zone(CcTest::i_isolate()->allocator()); 180 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
181 181
182 UniqueSet<String>* set = new(&zone) UniqueSet<String>(); 182 UniqueSet<String>* set = new(&zone) UniqueSet<String>();
183 183
184 set->Add(A, &zone); 184 set->Add(A, &zone);
185 set->Add(B, &zone); 185 set->Add(B, &zone);
186 set->Add(C, &zone); 186 set->Add(C, &zone);
187 CHECK_EQ(3, set->size()); 187 CHECK_EQ(3, set->size());
188 188
189 set->Remove(A); 189 set->Remove(A);
190 CHECK_EQ(2, set->size()); 190 CHECK_EQ(2, set->size());
(...skipping 19 matching lines...) Expand all
210 CHECK(!set->Contains(B)); 210 CHECK(!set->Contains(B));
211 CHECK(!set->Contains(C)); 211 CHECK(!set->Contains(C));
212 } 212 }
213 213
214 214
215 TEST(UniqueSet_Contains) { 215 TEST(UniqueSet_Contains) {
216 CcTest::InitializeVM(); 216 CcTest::InitializeVM();
217 MAKE_HANDLES_AND_DISALLOW_ALLOCATION; 217 MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
218 MAKE_UNIQUES_A_B_C; 218 MAKE_UNIQUES_A_B_C;
219 219
220 Zone zone(CcTest::i_isolate()->allocator()); 220 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
221 221
222 UniqueSet<String>* set = new(&zone) UniqueSet<String>(); 222 UniqueSet<String>* set = new(&zone) UniqueSet<String>();
223 223
224 CHECK_EQ(0, set->size()); 224 CHECK_EQ(0, set->size());
225 set->Add(A, &zone); 225 set->Add(A, &zone);
226 CHECK(set->Contains(A)); 226 CHECK(set->Contains(A));
227 CHECK(!set->Contains(B)); 227 CHECK(!set->Contains(B));
228 CHECK(!set->Contains(C)); 228 CHECK(!set->Contains(C));
229 229
230 set->Add(A, &zone); 230 set->Add(A, &zone);
(...skipping 10 matching lines...) Expand all
241 CHECK(set->Contains(B)); 241 CHECK(set->Contains(B));
242 CHECK(set->Contains(C)); 242 CHECK(set->Contains(C));
243 } 243 }
244 244
245 245
246 TEST(UniqueSet_At) { 246 TEST(UniqueSet_At) {
247 CcTest::InitializeVM(); 247 CcTest::InitializeVM();
248 MAKE_HANDLES_AND_DISALLOW_ALLOCATION; 248 MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
249 MAKE_UNIQUES_A_B_C; 249 MAKE_UNIQUES_A_B_C;
250 250
251 Zone zone(CcTest::i_isolate()->allocator()); 251 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
252 252
253 UniqueSet<String>* set = new(&zone) UniqueSet<String>(); 253 UniqueSet<String>* set = new(&zone) UniqueSet<String>();
254 254
255 CHECK_EQ(0, set->size()); 255 CHECK_EQ(0, set->size());
256 set->Add(A, &zone); 256 set->Add(A, &zone);
257 CHECK(A == set->at(0)); 257 CHECK(A == set->at(0));
258 258
259 set->Add(A, &zone); 259 set->Add(A, &zone);
260 CHECK(A == set->at(0)); 260 CHECK(A == set->at(0));
261 261
(...skipping 16 matching lines...) Expand all
278 CHECK(expected == set1->Equals(set2)); 278 CHECK(expected == set1->Equals(set2));
279 CHECK(expected == set2->Equals(set1)); 279 CHECK(expected == set2->Equals(set1));
280 } 280 }
281 281
282 282
283 TEST(UniqueSet_Equals) { 283 TEST(UniqueSet_Equals) {
284 CcTest::InitializeVM(); 284 CcTest::InitializeVM();
285 MAKE_HANDLES_AND_DISALLOW_ALLOCATION; 285 MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
286 MAKE_UNIQUES_A_B_C; 286 MAKE_UNIQUES_A_B_C;
287 287
288 Zone zone(CcTest::i_isolate()->allocator()); 288 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
289 289
290 UniqueSet<String>* set1 = new(&zone) UniqueSet<String>(); 290 UniqueSet<String>* set1 = new(&zone) UniqueSet<String>();
291 UniqueSet<String>* set2 = new(&zone) UniqueSet<String>(); 291 UniqueSet<String>* set2 = new(&zone) UniqueSet<String>();
292 292
293 CHECK_SETS(set1, set2, true); 293 CHECK_SETS(set1, set2, true);
294 294
295 set1->Add(A, &zone); 295 set1->Add(A, &zone);
296 296
297 CHECK_SETS(set1, set2, false); 297 CHECK_SETS(set1, set2, false);
298 298
(...skipping 17 matching lines...) Expand all
316 316
317 CHECK_SETS(set1, set2, true); 317 CHECK_SETS(set1, set2, true);
318 } 318 }
319 319
320 320
321 TEST(UniqueSet_IsSubset1) { 321 TEST(UniqueSet_IsSubset1) {
322 CcTest::InitializeVM(); 322 CcTest::InitializeVM();
323 MAKE_HANDLES_AND_DISALLOW_ALLOCATION; 323 MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
324 MAKE_UNIQUES_A_B_C; 324 MAKE_UNIQUES_A_B_C;
325 325
326 Zone zone(CcTest::i_isolate()->allocator()); 326 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
327 327
328 UniqueSet<String>* set1 = new(&zone) UniqueSet<String>(); 328 UniqueSet<String>* set1 = new(&zone) UniqueSet<String>();
329 UniqueSet<String>* set2 = new(&zone) UniqueSet<String>(); 329 UniqueSet<String>* set2 = new(&zone) UniqueSet<String>();
330 330
331 CHECK(set1->IsSubset(set2)); 331 CHECK(set1->IsSubset(set2));
332 CHECK(set2->IsSubset(set1)); 332 CHECK(set2->IsSubset(set1));
333 333
334 set1->Add(A, &zone); 334 set1->Add(A, &zone);
335 335
336 CHECK(!set1->IsSubset(set2)); 336 CHECK(!set1->IsSubset(set2));
(...skipping 14 matching lines...) Expand all
351 CHECK(set1->IsSubset(set2)); 351 CHECK(set1->IsSubset(set2));
352 CHECK(set2->IsSubset(set1)); 352 CHECK(set2->IsSubset(set1));
353 } 353 }
354 354
355 355
356 TEST(UniqueSet_IsSubset2) { 356 TEST(UniqueSet_IsSubset2) {
357 CcTest::InitializeVM(); 357 CcTest::InitializeVM();
358 MAKE_HANDLES_AND_DISALLOW_ALLOCATION; 358 MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
359 MAKE_UNIQUES_A_B_C_D_E_F_G; 359 MAKE_UNIQUES_A_B_C_D_E_F_G;
360 360
361 Zone zone(CcTest::i_isolate()->allocator()); 361 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
362 362
363 UniqueSet<String>* set1 = new(&zone) UniqueSet<String>(); 363 UniqueSet<String>* set1 = new(&zone) UniqueSet<String>();
364 UniqueSet<String>* set2 = new(&zone) UniqueSet<String>(); 364 UniqueSet<String>* set2 = new(&zone) UniqueSet<String>();
365 365
366 set1->Add(A, &zone); 366 set1->Add(A, &zone);
367 set1->Add(C, &zone); 367 set1->Add(C, &zone);
368 set1->Add(E, &zone); 368 set1->Add(E, &zone);
369 369
370 set2->Add(A, &zone); 370 set2->Add(A, &zone);
371 set2->Add(B, &zone); 371 set2->Add(B, &zone);
(...skipping 22 matching lines...) Expand all
394 } 394 }
395 395
396 396
397 TEST(UniqueSet_IsSubsetExhaustive) { 397 TEST(UniqueSet_IsSubsetExhaustive) {
398 const int kSetSize = 6; 398 const int kSetSize = 6;
399 399
400 CcTest::InitializeVM(); 400 CcTest::InitializeVM();
401 MAKE_HANDLES_AND_DISALLOW_ALLOCATION; 401 MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
402 MAKE_UNIQUES_A_B_C_D_E_F_G; 402 MAKE_UNIQUES_A_B_C_D_E_F_G;
403 403
404 Zone zone(CcTest::i_isolate()->allocator()); 404 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
405 405
406 Unique<String> elements[] = { 406 Unique<String> elements[] = {
407 A, B, C, D, E, F, G 407 A, B, C, D, E, F, G
408 }; 408 };
409 409
410 // Exhaustively test all sets with <= 6 elements. 410 // Exhaustively test all sets with <= 6 elements.
411 for (int i = 0; i < (1 << kSetSize); i++) { 411 for (int i = 0; i < (1 << kSetSize); i++) {
412 for (int j = 0; j < (1 << kSetSize); j++) { 412 for (int j = 0; j < (1 << kSetSize); j++) {
413 UniqueSet<String>* set1 = MakeSet(&zone, i, elements); 413 UniqueSet<String>* set1 = MakeSet(&zone, i, elements);
414 UniqueSet<String>* set2 = MakeSet(&zone, j, elements); 414 UniqueSet<String>* set2 = MakeSet(&zone, j, elements);
415 415
416 CHECK(((i & j) == i) == set1->IsSubset(set2)); 416 CHECK(((i & j) == i) == set1->IsSubset(set2));
417 } 417 }
418 } 418 }
419 } 419 }
420 420
421 421
422 TEST(UniqueSet_Intersect1) { 422 TEST(UniqueSet_Intersect1) {
423 CcTest::InitializeVM(); 423 CcTest::InitializeVM();
424 MAKE_HANDLES_AND_DISALLOW_ALLOCATION; 424 MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
425 MAKE_UNIQUES_A_B_C; 425 MAKE_UNIQUES_A_B_C;
426 426
427 Zone zone(CcTest::i_isolate()->allocator()); 427 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
428 428
429 UniqueSet<String>* set1 = new(&zone) UniqueSet<String>(); 429 UniqueSet<String>* set1 = new(&zone) UniqueSet<String>();
430 UniqueSet<String>* set2 = new(&zone) UniqueSet<String>(); 430 UniqueSet<String>* set2 = new(&zone) UniqueSet<String>();
431 UniqueSet<String>* result; 431 UniqueSet<String>* result;
432 432
433 CHECK(set1->IsSubset(set2)); 433 CHECK(set1->IsSubset(set2));
434 CHECK(set2->IsSubset(set1)); 434 CHECK(set2->IsSubset(set1));
435 435
436 set1->Add(A, &zone); 436 set1->Add(A, &zone);
437 437
(...skipping 20 matching lines...) Expand all
458 } 458 }
459 459
460 460
461 TEST(UniqueSet_IntersectExhaustive) { 461 TEST(UniqueSet_IntersectExhaustive) {
462 const int kSetSize = 6; 462 const int kSetSize = 6;
463 463
464 CcTest::InitializeVM(); 464 CcTest::InitializeVM();
465 MAKE_HANDLES_AND_DISALLOW_ALLOCATION; 465 MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
466 MAKE_UNIQUES_A_B_C_D_E_F_G; 466 MAKE_UNIQUES_A_B_C_D_E_F_G;
467 467
468 Zone zone(CcTest::i_isolate()->allocator()); 468 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
469 469
470 Unique<String> elements[] = { 470 Unique<String> elements[] = {
471 A, B, C, D, E, F, G 471 A, B, C, D, E, F, G
472 }; 472 };
473 473
474 // Exhaustively test all sets with <= 6 elements. 474 // Exhaustively test all sets with <= 6 elements.
475 for (int i = 0; i < (1 << kSetSize); i++) { 475 for (int i = 0; i < (1 << kSetSize); i++) {
476 for (int j = 0; j < (1 << kSetSize); j++) { 476 for (int j = 0; j < (1 << kSetSize); j++) {
477 UniqueSet<String>* set1 = MakeSet(&zone, i, elements); 477 UniqueSet<String>* set1 = MakeSet(&zone, i, elements);
478 UniqueSet<String>* set2 = MakeSet(&zone, j, elements); 478 UniqueSet<String>* set2 = MakeSet(&zone, j, elements);
479 479
480 UniqueSet<String>* result = set1->Intersect(set2, &zone); 480 UniqueSet<String>* result = set1->Intersect(set2, &zone);
481 UniqueSet<String>* expected = MakeSet(&zone, i & j, elements); 481 UniqueSet<String>* expected = MakeSet(&zone, i & j, elements);
482 482
483 CHECK(result->Equals(expected)); 483 CHECK(result->Equals(expected));
484 CHECK(expected->Equals(result)); 484 CHECK(expected->Equals(result));
485 } 485 }
486 } 486 }
487 } 487 }
488 488
489 489
490 TEST(UniqueSet_Union1) { 490 TEST(UniqueSet_Union1) {
491 CcTest::InitializeVM(); 491 CcTest::InitializeVM();
492 MAKE_HANDLES_AND_DISALLOW_ALLOCATION; 492 MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
493 MAKE_UNIQUES_A_B_C; 493 MAKE_UNIQUES_A_B_C;
494 494
495 Zone zone(CcTest::i_isolate()->allocator()); 495 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
496 496
497 UniqueSet<String>* set1 = new(&zone) UniqueSet<String>(); 497 UniqueSet<String>* set1 = new(&zone) UniqueSet<String>();
498 UniqueSet<String>* set2 = new(&zone) UniqueSet<String>(); 498 UniqueSet<String>* set2 = new(&zone) UniqueSet<String>();
499 UniqueSet<String>* result; 499 UniqueSet<String>* result;
500 500
501 CHECK(set1->IsSubset(set2)); 501 CHECK(set1->IsSubset(set2));
502 CHECK(set2->IsSubset(set1)); 502 CHECK(set2->IsSubset(set1));
503 503
504 set1->Add(A, &zone); 504 set1->Add(A, &zone);
505 505
(...skipping 20 matching lines...) Expand all
526 } 526 }
527 527
528 528
529 TEST(UniqueSet_UnionExhaustive) { 529 TEST(UniqueSet_UnionExhaustive) {
530 const int kSetSize = 6; 530 const int kSetSize = 6;
531 531
532 CcTest::InitializeVM(); 532 CcTest::InitializeVM();
533 MAKE_HANDLES_AND_DISALLOW_ALLOCATION; 533 MAKE_HANDLES_AND_DISALLOW_ALLOCATION;
534 MAKE_UNIQUES_A_B_C_D_E_F_G; 534 MAKE_UNIQUES_A_B_C_D_E_F_G;
535 535
536 Zone zone(CcTest::i_isolate()->allocator()); 536 Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME);
537 537
538 Unique<String> elements[] = { 538 Unique<String> elements[] = {
539 A, B, C, D, E, F, G 539 A, B, C, D, E, F, G
540 }; 540 };
541 541
542 // Exhaustively test all sets with <= 6 elements. 542 // Exhaustively test all sets with <= 6 elements.
543 for (int i = 0; i < (1 << kSetSize); i++) { 543 for (int i = 0; i < (1 << kSetSize); i++) {
544 for (int j = 0; j < (1 << kSetSize); j++) { 544 for (int j = 0; j < (1 << kSetSize); j++) {
545 UniqueSet<String>* set1 = MakeSet(&zone, i, elements); 545 UniqueSet<String>* set1 = MakeSet(&zone, i, elements);
546 UniqueSet<String>* set2 = MakeSet(&zone, j, elements); 546 UniqueSet<String>* set2 = MakeSet(&zone, j, elements);
547 547
548 UniqueSet<String>* result = set1->Union(set2, &zone); 548 UniqueSet<String>* result = set1->Union(set2, &zone);
549 UniqueSet<String>* expected = MakeSet(&zone, i | j, elements); 549 UniqueSet<String>* expected = MakeSet(&zone, i | j, elements);
550 550
551 CHECK(result->Equals(expected)); 551 CHECK(result->Equals(expected));
552 CHECK(expected->Equals(result)); 552 CHECK(expected->Equals(result));
553 } 553 }
554 } 554 }
555 } 555 }
OLDNEW
« no previous file with comments | « test/cctest/test-types.cc ('k') | test/cctest/wasm/test-run-wasm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698