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

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

Issue 23929006: remove remaining uses of default isolate in tests (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix serializer 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/cctest.cc ('k') | test/cctest/test-debug.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 12428 matching lines...) Expand 10 before | Expand all | Expand 10 after
12439 void ApiTestFuzzer::TearDown() { 12439 void ApiTestFuzzer::TearDown() {
12440 fuzzing_ = false; 12440 fuzzing_ = false;
12441 for (int i = 0; i < RegisterThreadedTest::count(); i++) { 12441 for (int i = 0; i < RegisterThreadedTest::count(); i++) {
12442 ApiTestFuzzer *fuzzer = RegisterThreadedTest::nth(i)->fuzzer_; 12442 ApiTestFuzzer *fuzzer = RegisterThreadedTest::nth(i)->fuzzer_;
12443 if (fuzzer != NULL) fuzzer->Join(); 12443 if (fuzzer != NULL) fuzzer->Join();
12444 } 12444 }
12445 } 12445 }
12446 12446
12447 12447
12448 // Lets not be needlessly self-referential. 12448 // Lets not be needlessly self-referential.
12449 UNINITIALIZED_TEST(Threading1) { 12449 TEST(Threading1) {
12450 ApiTestFuzzer::SetUp(ApiTestFuzzer::FIRST_PART); 12450 ApiTestFuzzer::SetUp(ApiTestFuzzer::FIRST_PART);
12451 ApiTestFuzzer::RunAllTests(); 12451 ApiTestFuzzer::RunAllTests();
12452 ApiTestFuzzer::TearDown(); 12452 ApiTestFuzzer::TearDown();
12453 } 12453 }
12454 12454
12455 12455
12456 UNINITIALIZED_TEST(Threading2) { 12456 TEST(Threading2) {
12457 ApiTestFuzzer::SetUp(ApiTestFuzzer::SECOND_PART); 12457 ApiTestFuzzer::SetUp(ApiTestFuzzer::SECOND_PART);
12458 ApiTestFuzzer::RunAllTests(); 12458 ApiTestFuzzer::RunAllTests();
12459 ApiTestFuzzer::TearDown(); 12459 ApiTestFuzzer::TearDown();
12460 } 12460 }
12461 12461
12462 12462
12463 UNINITIALIZED_TEST(Threading3) { 12463 TEST(Threading3) {
12464 ApiTestFuzzer::SetUp(ApiTestFuzzer::THIRD_PART); 12464 ApiTestFuzzer::SetUp(ApiTestFuzzer::THIRD_PART);
12465 ApiTestFuzzer::RunAllTests(); 12465 ApiTestFuzzer::RunAllTests();
12466 ApiTestFuzzer::TearDown(); 12466 ApiTestFuzzer::TearDown();
12467 } 12467 }
12468 12468
12469 12469
12470 UNINITIALIZED_TEST(Threading4) { 12470 TEST(Threading4) {
12471 ApiTestFuzzer::SetUp(ApiTestFuzzer::FOURTH_PART); 12471 ApiTestFuzzer::SetUp(ApiTestFuzzer::FOURTH_PART);
12472 ApiTestFuzzer::RunAllTests(); 12472 ApiTestFuzzer::RunAllTests();
12473 ApiTestFuzzer::TearDown(); 12473 ApiTestFuzzer::TearDown();
12474 } 12474 }
12475 12475
12476 12476
12477 void ApiTestFuzzer::CallTest() { 12477 void ApiTestFuzzer::CallTest() {
12478 v8::Isolate::Scope scope(CcTest::isolate());
12478 if (kLogThreading) 12479 if (kLogThreading)
12479 printf("Start test %d\n", test_number_); 12480 printf("Start test %d\n", test_number_);
12480 CallTestNumber(test_number_); 12481 CallTestNumber(test_number_);
12481 if (kLogThreading) 12482 if (kLogThreading)
12482 printf("End test %d\n", test_number_); 12483 printf("End test %d\n", test_number_);
12483 } 12484 }
12484 12485
12485 12486
12486 static void ThrowInJS(const v8::FunctionCallbackInfo<v8::Value>& args) { 12487 static void ThrowInJS(const v8::FunctionCallbackInfo<v8::Value>& args) {
12487 CHECK(v8::Locker::IsLocked(CcTest::isolate())); 12488 CHECK(v8::Locker::IsLocked(CcTest::isolate()));
(...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after
14250 } 14251 }
14251 private: 14252 private:
14252 RegExpInterruptTest* test_; 14253 RegExpInterruptTest* test_;
14253 }; 14254 };
14254 14255
14255 void CollectGarbage() { 14256 void CollectGarbage() {
14256 block_.Wait(); 14257 block_.Wait();
14257 while (gc_during_regexp_ < kRequiredGCs) { 14258 while (gc_during_regexp_ < kRequiredGCs) {
14258 { 14259 {
14259 v8::Locker lock(CcTest::isolate()); 14260 v8::Locker lock(CcTest::isolate());
14261 v8::Isolate::Scope isolate_scope(CcTest::isolate());
14260 // TODO(lrn): Perhaps create some garbage before collecting. 14262 // TODO(lrn): Perhaps create some garbage before collecting.
14261 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); 14263 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
14262 gc_count_++; 14264 gc_count_++;
14263 } 14265 }
14264 i::OS::Sleep(1); 14266 i::OS::Sleep(1);
14265 } 14267 }
14266 gc_success_ = true; 14268 gc_success_ = true;
14267 } 14269 }
14268 14270
14269 void LongRunningRegExp() { 14271 void LongRunningRegExp() {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
14308 i::Semaphore block_; 14310 i::Semaphore block_;
14309 int gc_count_; 14311 int gc_count_;
14310 int gc_during_regexp_; 14312 int gc_during_regexp_;
14311 bool regexp_success_; 14313 bool regexp_success_;
14312 bool gc_success_; 14314 bool gc_success_;
14313 }; 14315 };
14314 14316
14315 14317
14316 // Test that a regular expression execution can be interrupted and 14318 // Test that a regular expression execution can be interrupted and
14317 // survive a garbage collection. 14319 // survive a garbage collection.
14318 UNINITIALIZED_TEST(RegExpInterruption) { 14320 TEST(RegExpInterruption) {
14319 v8::Locker lock(CcTest::isolate()); 14321 v8::Locker lock(CcTest::isolate());
14320 v8::V8::Initialize();
14321 v8::HandleScope scope(CcTest::isolate()); 14322 v8::HandleScope scope(CcTest::isolate());
14322 Local<Context> local_env; 14323 Local<Context> local_env;
14323 { 14324 {
14324 LocalContext env; 14325 LocalContext env;
14325 local_env = env.local(); 14326 local_env = env.local();
14326 } 14327 }
14327 14328
14328 // Local context should still be live. 14329 // Local context should still be live.
14329 CHECK(!local_env.IsEmpty()); 14330 CHECK(!local_env.IsEmpty());
14330 local_env->Enter(); 14331 local_env->Enter();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
14372 } 14373 }
14373 private: 14374 private:
14374 ApplyInterruptTest* test_; 14375 ApplyInterruptTest* test_;
14375 }; 14376 };
14376 14377
14377 void CollectGarbage() { 14378 void CollectGarbage() {
14378 block_.Wait(); 14379 block_.Wait();
14379 while (gc_during_apply_ < kRequiredGCs) { 14380 while (gc_during_apply_ < kRequiredGCs) {
14380 { 14381 {
14381 v8::Locker lock(CcTest::isolate()); 14382 v8::Locker lock(CcTest::isolate());
14383 v8::Isolate::Scope isolate_scope(CcTest::isolate());
14382 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); 14384 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
14383 gc_count_++; 14385 gc_count_++;
14384 } 14386 }
14385 i::OS::Sleep(1); 14387 i::OS::Sleep(1);
14386 } 14388 }
14387 gc_success_ = true; 14389 gc_success_ = true;
14388 } 14390 }
14389 14391
14390 void LongRunningApply() { 14392 void LongRunningApply() {
14391 block_.Signal(); 14393 block_.Signal();
(...skipping 24 matching lines...) Expand all
14416 i::Semaphore block_; 14418 i::Semaphore block_;
14417 int gc_count_; 14419 int gc_count_;
14418 int gc_during_apply_; 14420 int gc_during_apply_;
14419 bool apply_success_; 14421 bool apply_success_;
14420 bool gc_success_; 14422 bool gc_success_;
14421 }; 14423 };
14422 14424
14423 14425
14424 // Test that nothing bad happens if we get a preemption just when we were 14426 // Test that nothing bad happens if we get a preemption just when we were
14425 // about to do an apply(). 14427 // about to do an apply().
14426 UNINITIALIZED_TEST(ApplyInterruption) { 14428 TEST(ApplyInterruption) {
14427 v8::Locker lock(CcTest::isolate()); 14429 v8::Locker lock(CcTest::isolate());
14428 v8::V8::Initialize(); 14430 v8::V8::Initialize();
14429 v8::HandleScope scope(CcTest::isolate()); 14431 v8::HandleScope scope(CcTest::isolate());
14430 Local<Context> local_env; 14432 Local<Context> local_env;
14431 { 14433 {
14432 LocalContext env; 14434 LocalContext env;
14433 local_env = env.local(); 14435 local_env = env.local();
14434 } 14436 }
14435 14437
14436 // Local context should still be live. 14438 // Local context should still be live.
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
14687 private: 14689 private:
14688 RegExpStringModificationTest* test_; 14690 RegExpStringModificationTest* test_;
14689 }; 14691 };
14690 14692
14691 void MorphString() { 14693 void MorphString() {
14692 block_.Wait(); 14694 block_.Wait();
14693 while (morphs_during_regexp_ < kRequiredModifications && 14695 while (morphs_during_regexp_ < kRequiredModifications &&
14694 morphs_ < kMaxModifications) { 14696 morphs_ < kMaxModifications) {
14695 { 14697 {
14696 v8::Locker lock(CcTest::isolate()); 14698 v8::Locker lock(CcTest::isolate());
14699 v8::Isolate::Scope isolate_scope(CcTest::isolate());
14697 // Swap string between ascii and two-byte representation. 14700 // Swap string between ascii and two-byte representation.
14698 i::String* string = *input_; 14701 i::String* string = *input_;
14699 MorphAString(string, &ascii_resource_, &uc16_resource_); 14702 MorphAString(string, &ascii_resource_, &uc16_resource_);
14700 morphs_++; 14703 morphs_++;
14701 } 14704 }
14702 i::OS::Sleep(1); 14705 i::OS::Sleep(1);
14703 } 14706 }
14704 morph_success_ = true; 14707 morph_success_ = true;
14705 } 14708 }
14706 14709
(...skipping 26 matching lines...) Expand all
14733 bool regexp_success_; 14736 bool regexp_success_;
14734 bool morph_success_; 14737 bool morph_success_;
14735 i::Handle<i::String> input_; 14738 i::Handle<i::String> input_;
14736 AsciiVectorResource ascii_resource_; 14739 AsciiVectorResource ascii_resource_;
14737 UC16VectorResource uc16_resource_; 14740 UC16VectorResource uc16_resource_;
14738 }; 14741 };
14739 14742
14740 14743
14741 // Test that a regular expression execution can be interrupted and 14744 // Test that a regular expression execution can be interrupted and
14742 // the string changed without failing. 14745 // the string changed without failing.
14743 UNINITIALIZED_TEST(RegExpStringModification) { 14746 TEST(RegExpStringModification) {
14744 v8::Locker lock(CcTest::isolate()); 14747 v8::Locker lock(CcTest::isolate());
14745 v8::V8::Initialize();
14746 v8::HandleScope scope(CcTest::isolate()); 14748 v8::HandleScope scope(CcTest::isolate());
14747 Local<Context> local_env; 14749 Local<Context> local_env;
14748 { 14750 {
14749 LocalContext env; 14751 LocalContext env;
14750 local_env = env.local(); 14752 local_env = env.local();
14751 } 14753 }
14752 14754
14753 // Local context should still be live. 14755 // Local context should still be live.
14754 CHECK(!local_env.IsEmpty()); 14756 CHECK(!local_env.IsEmpty());
14755 local_env->Enter(); 14757 local_env->Enter();
(...skipping 4975 matching lines...) Expand 10 before | Expand all | Expand 10 after
19731 i::Handle<i::Object> true_value = factory->true_value(); 19733 i::Handle<i::Object> true_value = factory->true_value();
19732 CHECK(*v8::Utils::OpenHandle(*v8::True()) == *true_value); 19734 CHECK(*v8::Utils::OpenHandle(*v8::True()) == *true_value);
19733 CHECK(*v8::Utils::OpenHandle(*v8::True(isolate)) == *true_value); 19735 CHECK(*v8::Utils::OpenHandle(*v8::True(isolate)) == *true_value);
19734 i::Handle<i::Object> false_value = factory->false_value(); 19736 i::Handle<i::Object> false_value = factory->false_value();
19735 CHECK(*v8::Utils::OpenHandle(*v8::False()) == *false_value); 19737 CHECK(*v8::Utils::OpenHandle(*v8::False()) == *false_value);
19736 CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value); 19738 CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value);
19737 } 19739 }
19738 19740
19739 19741
19740 UNINITIALIZED_TEST(IsolateEmbedderData) { 19742 UNINITIALIZED_TEST(IsolateEmbedderData) {
19741 v8::Isolate* isolate = CcTest::isolate(); 19743 CcTest::DisableAutomaticDispose();
19744 v8::Isolate* isolate = v8::Isolate::New();
19745 isolate->Enter();
19742 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 19746 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
19743 CHECK_EQ(NULL, isolate->GetData()); 19747 CHECK_EQ(NULL, isolate->GetData());
19744 CHECK_EQ(NULL, i_isolate->GetData()); 19748 CHECK_EQ(NULL, i_isolate->GetData());
19745 static void* data1 = reinterpret_cast<void*>(0xacce55ed); 19749 static void* data1 = reinterpret_cast<void*>(0xacce55ed);
19746 isolate->SetData(data1); 19750 isolate->SetData(data1);
19747 CHECK_EQ(data1, isolate->GetData()); 19751 CHECK_EQ(data1, isolate->GetData());
19748 CHECK_EQ(data1, i_isolate->GetData()); 19752 CHECK_EQ(data1, i_isolate->GetData());
19749 static void* data2 = reinterpret_cast<void*>(0xdecea5ed); 19753 static void* data2 = reinterpret_cast<void*>(0xdecea5ed);
19750 i_isolate->SetData(data2); 19754 i_isolate->SetData(data2);
19751 CHECK_EQ(data2, isolate->GetData()); 19755 CHECK_EQ(data2, isolate->GetData());
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
20593 Local<Object> data2 = v8::Object::New(); 20597 Local<Object> data2 = v8::Object::New();
20594 function_new_expected_env = data2; 20598 function_new_expected_env = data2;
20595 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); 20599 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2);
20596 CHECK(!func2->IsNull()); 20600 CHECK(!func2->IsNull());
20597 CHECK_NE(func, func2); 20601 CHECK_NE(func, func2);
20598 env->Global()->Set(v8_str("func2"), func2); 20602 env->Global()->Set(v8_str("func2"), func2);
20599 Local<Value> result2 = CompileRun("func2();"); 20603 Local<Value> result2 = CompileRun("func2();");
20600 CHECK_EQ(v8::Integer::New(17, isolate), result2); 20604 CHECK_EQ(v8::Integer::New(17, isolate), result2);
20601 } 20605 }
20602 20606
OLDNEW
« no previous file with comments | « test/cctest/cctest.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698