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

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

Issue 118158: Fix flakyness in tests: make sure to garbage collect temporary test... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 v8::internal::Heap::CollectAllGarbage(); 531 v8::internal::Heap::CollectAllGarbage();
532 CHECK_EQ(0, TestAsciiResource::dispose_count); 532 CHECK_EQ(0, TestAsciiResource::dispose_count);
533 } 533 }
534 v8::internal::CompilationCache::Clear(); 534 v8::internal::CompilationCache::Clear();
535 v8::internal::Heap::CollectAllGarbage(); 535 v8::internal::Heap::CollectAllGarbage();
536 CHECK_EQ(1, TestAsciiResource::dispose_count); 536 CHECK_EQ(1, TestAsciiResource::dispose_count);
537 } 537 }
538 538
539 539
540 THREADED_TEST(UsingExternalString) { 540 THREADED_TEST(UsingExternalString) {
541 v8::HandleScope scope; 541 {
542 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); 542 v8::HandleScope scope;
543 Local<String> string = String::NewExternal(new TestResource(two_byte_string)); 543 uint16_t* two_byte_string = AsciiToTwoByteString("test string");
544 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); 544 Local<String> string =
545 // Trigger GCs so that the newly allocated string moves to old gen. 545 String::NewExternal(new TestResource(two_byte_string));
546 i::Heap::CollectGarbage(0, i::NEW_SPACE); // in survivor space now 546 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
547 i::Heap::CollectGarbage(0, i::NEW_SPACE); // in old gen now 547 // Trigger GCs so that the newly allocated string moves to old gen.
548 i::Handle<i::String> isymbol = i::Factory::SymbolFromString(istring); 548 i::Heap::CollectGarbage(0, i::NEW_SPACE); // in survivor space now
549 CHECK(isymbol->IsSymbol()); 549 i::Heap::CollectGarbage(0, i::NEW_SPACE); // in old gen now
550 i::Handle<i::String> isymbol = i::Factory::SymbolFromString(istring);
551 CHECK(isymbol->IsSymbol());
552 }
553 i::Heap::CollectAllGarbage();
550 } 554 }
551 555
552 556
553 THREADED_TEST(UsingExternalAsciiString) { 557 THREADED_TEST(UsingExternalAsciiString) {
554 v8::HandleScope scope; 558 {
555 const char* one_byte_string = "test string"; 559 v8::HandleScope scope;
556 Local<String> string = String::NewExternal( 560 const char* one_byte_string = "test string";
557 new TestAsciiResource(i::StrDup(one_byte_string))); 561 Local<String> string = String::NewExternal(
558 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); 562 new TestAsciiResource(i::StrDup(one_byte_string)));
559 // Trigger GCs so that the newly allocated string moves to old gen. 563 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
560 i::Heap::CollectGarbage(0, i::NEW_SPACE); // in survivor space now 564 // Trigger GCs so that the newly allocated string moves to old gen.
561 i::Heap::CollectGarbage(0, i::NEW_SPACE); // in old gen now 565 i::Heap::CollectGarbage(0, i::NEW_SPACE); // in survivor space now
562 i::Handle<i::String> isymbol = i::Factory::SymbolFromString(istring); 566 i::Heap::CollectGarbage(0, i::NEW_SPACE); // in old gen now
563 CHECK(isymbol->IsSymbol()); 567 i::Handle<i::String> isymbol = i::Factory::SymbolFromString(istring);
568 CHECK(isymbol->IsSymbol());
569 }
570 i::Heap::CollectAllGarbage();
564 } 571 }
565 572
566 573
567 THREADED_TEST(GlobalProperties) { 574 THREADED_TEST(GlobalProperties) {
568 v8::HandleScope scope; 575 v8::HandleScope scope;
569 LocalContext env; 576 LocalContext env;
570 v8::Handle<v8::Object> global = env->Global(); 577 v8::Handle<v8::Object> global = env->Global();
571 global->Set(v8_str("pi"), v8_num(3.1415926)); 578 global->Set(v8_str("pi"), v8_num(3.1415926));
572 Local<Value> pi = global->Get(v8_str("pi")); 579 Local<Value> pi = global->Get(v8_str("pi"));
573 CHECK_EQ(3.1415926, pi->NumberValue()); 580 CHECK_EQ(3.1415926, pi->NumberValue());
(...skipping 6097 matching lines...) Expand 10 before | Expand all | Expand 10 after
6671 calling_context2->Exit(); 6678 calling_context2->Exit();
6672 6679
6673 // Dispose the contexts to allow them to be garbage collected. 6680 // Dispose the contexts to allow them to be garbage collected.
6674 calling_context0.Dispose(); 6681 calling_context0.Dispose();
6675 calling_context1.Dispose(); 6682 calling_context1.Dispose();
6676 calling_context2.Dispose(); 6683 calling_context2.Dispose();
6677 calling_context0.Clear(); 6684 calling_context0.Clear();
6678 calling_context1.Clear(); 6685 calling_context1.Clear();
6679 calling_context2.Clear(); 6686 calling_context2.Clear();
6680 } 6687 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698