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

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

Issue 17577008: Revert "Remove IsInitialized checks from inlined API functions." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 | « src/isolate.cc ('k') | 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 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 18778 matching lines...) Expand 10 before | Expand all | Expand 10 after
18789 TEST(SecondaryStubCache) { 18789 TEST(SecondaryStubCache) {
18790 StubCacheHelper(true); 18790 StubCacheHelper(true);
18791 } 18791 }
18792 18792
18793 18793
18794 TEST(PrimaryStubCache) { 18794 TEST(PrimaryStubCache) {
18795 StubCacheHelper(false); 18795 StubCacheHelper(false);
18796 } 18796 }
18797 18797
18798 18798
18799 static int fatal_error_callback_counter = 0;
18800 static void CountingErrorCallback(const char* location, const char* message) {
18801 printf("CountingErrorCallback(\"%s\", \"%s\")\n", location, message);
18802 fatal_error_callback_counter++;
18803 }
18804
18805
18799 TEST(StaticGetters) { 18806 TEST(StaticGetters) {
18800 LocalContext context; 18807 LocalContext context;
18801 i::Factory* factory = i::Isolate::Current()->factory(); 18808 i::Factory* factory = i::Isolate::Current()->factory();
18802 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 18809 v8::Isolate* isolate = v8::Isolate::GetCurrent();
18803 v8::HandleScope scope(isolate); 18810 v8::HandleScope scope(isolate);
18804 i::Handle<i::Object> undefined_value = factory->undefined_value(); 18811 i::Handle<i::Object> undefined_value = factory->undefined_value();
18805 CHECK(*v8::Utils::OpenHandle(*v8::Undefined()) == *undefined_value); 18812 CHECK(*v8::Utils::OpenHandle(*v8::Undefined()) == *undefined_value);
18806 CHECK(*v8::Utils::OpenHandle(*v8::Undefined(isolate)) == *undefined_value); 18813 CHECK(*v8::Utils::OpenHandle(*v8::Undefined(isolate)) == *undefined_value);
18807 i::Handle<i::Object> null_value = factory->null_value(); 18814 i::Handle<i::Object> null_value = factory->null_value();
18808 CHECK(*v8::Utils::OpenHandle(*v8::Null()) == *null_value); 18815 CHECK(*v8::Utils::OpenHandle(*v8::Null()) == *null_value);
18809 CHECK(*v8::Utils::OpenHandle(*v8::Null(isolate)) == *null_value); 18816 CHECK(*v8::Utils::OpenHandle(*v8::Null(isolate)) == *null_value);
18810 i::Handle<i::Object> true_value = factory->true_value(); 18817 i::Handle<i::Object> true_value = factory->true_value();
18811 CHECK(*v8::Utils::OpenHandle(*v8::True()) == *true_value); 18818 CHECK(*v8::Utils::OpenHandle(*v8::True()) == *true_value);
18812 CHECK(*v8::Utils::OpenHandle(*v8::True(isolate)) == *true_value); 18819 CHECK(*v8::Utils::OpenHandle(*v8::True(isolate)) == *true_value);
18813 i::Handle<i::Object> false_value = factory->false_value(); 18820 i::Handle<i::Object> false_value = factory->false_value();
18814 CHECK(*v8::Utils::OpenHandle(*v8::False()) == *false_value); 18821 CHECK(*v8::Utils::OpenHandle(*v8::False()) == *false_value);
18815 CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value); 18822 CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value);
18823
18824 // Test after-death behavior.
18825 CHECK(i::Internals::IsInitialized(isolate));
18826 CHECK_EQ(0, fatal_error_callback_counter);
18827 v8::V8::SetFatalErrorHandler(CountingErrorCallback);
18828 v8::Utils::ReportApiFailure("StaticGetters()", "Kill V8");
18829 i::Isolate::Current()->TearDown();
18830 CHECK(!i::Internals::IsInitialized(isolate));
18831 CHECK_EQ(1, fatal_error_callback_counter);
18832 CHECK(v8::Undefined().IsEmpty());
18833 CHECK_EQ(2, fatal_error_callback_counter);
18834 CHECK(v8::Undefined(isolate).IsEmpty());
18835 CHECK_EQ(3, fatal_error_callback_counter);
18836 CHECK(v8::Null().IsEmpty());
18837 CHECK_EQ(4, fatal_error_callback_counter);
18838 CHECK(v8::Null(isolate).IsEmpty());
18839 CHECK_EQ(5, fatal_error_callback_counter);
18840 CHECK(v8::True().IsEmpty());
18841 CHECK_EQ(6, fatal_error_callback_counter);
18842 CHECK(v8::True(isolate).IsEmpty());
18843 CHECK_EQ(7, fatal_error_callback_counter);
18844 CHECK(v8::False().IsEmpty());
18845 CHECK_EQ(8, fatal_error_callback_counter);
18846 CHECK(v8::False(isolate).IsEmpty());
18847 CHECK_EQ(9, fatal_error_callback_counter);
18816 } 18848 }
18817 18849
18818 18850
18819 TEST(IsolateEmbedderData) { 18851 TEST(IsolateEmbedderData) {
18820 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 18852 v8::Isolate* isolate = v8::Isolate::GetCurrent();
18821 CHECK_EQ(NULL, isolate->GetData()); 18853 CHECK_EQ(NULL, isolate->GetData());
18822 CHECK_EQ(NULL, ISOLATE->GetData()); 18854 CHECK_EQ(NULL, ISOLATE->GetData());
18823 static void* data1 = reinterpret_cast<void*>(0xacce55ed); 18855 static void* data1 = reinterpret_cast<void*>(0xacce55ed);
18824 isolate->SetData(data1); 18856 isolate->SetData(data1);
18825 CHECK_EQ(data1, isolate->GetData()); 18857 CHECK_EQ(data1, isolate->GetData());
18826 CHECK_EQ(data1, ISOLATE->GetData()); 18858 CHECK_EQ(data1, ISOLATE->GetData());
18827 static void* data2 = reinterpret_cast<void*>(0xdecea5ed); 18859 static void* data2 = reinterpret_cast<void*>(0xdecea5ed);
18828 ISOLATE->SetData(data2); 18860 ISOLATE->SetData(data2);
18829 CHECK_EQ(data2, isolate->GetData()); 18861 CHECK_EQ(data2, isolate->GetData());
18830 CHECK_EQ(data2, ISOLATE->GetData()); 18862 CHECK_EQ(data2, ISOLATE->GetData());
18831 ISOLATE->TearDown(); 18863 ISOLATE->TearDown();
18832 CHECK_EQ(data2, isolate->GetData()); 18864 CHECK_EQ(data2, isolate->GetData());
18833 CHECK_EQ(data2, ISOLATE->GetData()); 18865 CHECK_EQ(data2, ISOLATE->GetData());
18834 } 18866 }
18835 18867
18836 18868
18837 TEST(StringEmpty) { 18869 TEST(StringEmpty) {
18838 LocalContext context; 18870 LocalContext context;
18839 i::Factory* factory = i::Isolate::Current()->factory(); 18871 i::Factory* factory = i::Isolate::Current()->factory();
18840 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 18872 v8::Isolate* isolate = v8::Isolate::GetCurrent();
18841 v8::HandleScope scope(isolate); 18873 v8::HandleScope scope(isolate);
18842 i::Handle<i::Object> empty_string = factory->empty_string(); 18874 i::Handle<i::Object> empty_string = factory->empty_string();
18843 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty()) == *empty_string); 18875 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty()) == *empty_string);
18844 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string); 18876 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string);
18877
18878 // Test after-death behavior.
18879 CHECK(i::Internals::IsInitialized(isolate));
18880 CHECK_EQ(0, fatal_error_callback_counter);
18881 v8::V8::SetFatalErrorHandler(CountingErrorCallback);
18882 v8::Utils::ReportApiFailure("StringEmpty()", "Kill V8");
18883 i::Isolate::Current()->TearDown();
18884 CHECK(!i::Internals::IsInitialized(isolate));
18885 CHECK_EQ(1, fatal_error_callback_counter);
18886 CHECK(v8::String::Empty().IsEmpty());
18887 CHECK_EQ(2, fatal_error_callback_counter);
18888 CHECK(v8::String::Empty(isolate).IsEmpty());
18889 CHECK_EQ(3, fatal_error_callback_counter);
18845 } 18890 }
18846 18891
18847 18892
18848 static int instance_checked_getter_count = 0; 18893 static int instance_checked_getter_count = 0;
18849 static void InstanceCheckedGetter( 18894 static void InstanceCheckedGetter(
18850 Local<String> name, 18895 Local<String> name,
18851 const v8::PropertyCallbackInfo<v8::Value>& info) { 18896 const v8::PropertyCallbackInfo<v8::Value>& info) {
18852 CHECK_EQ(name, v8_str("foo")); 18897 CHECK_EQ(name, v8_str("foo"));
18853 instance_checked_getter_count++; 18898 instance_checked_getter_count++;
18854 info.GetReturnValue().Set(v8_num(11)); 18899 info.GetReturnValue().Set(v8_num(11));
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
19306 i::Semaphore* sem_; 19351 i::Semaphore* sem_;
19307 volatile int sem_value_; 19352 volatile int sem_value_;
19308 }; 19353 };
19309 19354
19310 19355
19311 THREADED_TEST(SemaphoreInterruption) { 19356 THREADED_TEST(SemaphoreInterruption) {
19312 ThreadInterruptTest().RunTest(); 19357 ThreadInterruptTest().RunTest();
19313 } 19358 }
19314 19359
19315 #endif // WIN32 19360 #endif // WIN32
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698