OLD | NEW |
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 18764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18775 TEST(SecondaryStubCache) { | 18775 TEST(SecondaryStubCache) { |
18776 StubCacheHelper(true); | 18776 StubCacheHelper(true); |
18777 } | 18777 } |
18778 | 18778 |
18779 | 18779 |
18780 TEST(PrimaryStubCache) { | 18780 TEST(PrimaryStubCache) { |
18781 StubCacheHelper(false); | 18781 StubCacheHelper(false); |
18782 } | 18782 } |
18783 | 18783 |
18784 | 18784 |
18785 static int fatal_error_callback_counter = 0; | |
18786 static void CountingErrorCallback(const char* location, const char* message) { | |
18787 printf("CountingErrorCallback(\"%s\", \"%s\")\n", location, message); | |
18788 fatal_error_callback_counter++; | |
18789 } | |
18790 | |
18791 | |
18792 TEST(StaticGetters) { | 18785 TEST(StaticGetters) { |
18793 LocalContext context; | 18786 LocalContext context; |
18794 i::Factory* factory = i::Isolate::Current()->factory(); | 18787 i::Factory* factory = i::Isolate::Current()->factory(); |
18795 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 18788 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
18796 v8::HandleScope scope(isolate); | 18789 v8::HandleScope scope(isolate); |
18797 i::Handle<i::Object> undefined_value = factory->undefined_value(); | 18790 i::Handle<i::Object> undefined_value = factory->undefined_value(); |
18798 CHECK(*v8::Utils::OpenHandle(*v8::Undefined()) == *undefined_value); | 18791 CHECK(*v8::Utils::OpenHandle(*v8::Undefined()) == *undefined_value); |
18799 CHECK(*v8::Utils::OpenHandle(*v8::Undefined(isolate)) == *undefined_value); | 18792 CHECK(*v8::Utils::OpenHandle(*v8::Undefined(isolate)) == *undefined_value); |
18800 i::Handle<i::Object> null_value = factory->null_value(); | 18793 i::Handle<i::Object> null_value = factory->null_value(); |
18801 CHECK(*v8::Utils::OpenHandle(*v8::Null()) == *null_value); | 18794 CHECK(*v8::Utils::OpenHandle(*v8::Null()) == *null_value); |
18802 CHECK(*v8::Utils::OpenHandle(*v8::Null(isolate)) == *null_value); | 18795 CHECK(*v8::Utils::OpenHandle(*v8::Null(isolate)) == *null_value); |
18803 i::Handle<i::Object> true_value = factory->true_value(); | 18796 i::Handle<i::Object> true_value = factory->true_value(); |
18804 CHECK(*v8::Utils::OpenHandle(*v8::True()) == *true_value); | 18797 CHECK(*v8::Utils::OpenHandle(*v8::True()) == *true_value); |
18805 CHECK(*v8::Utils::OpenHandle(*v8::True(isolate)) == *true_value); | 18798 CHECK(*v8::Utils::OpenHandle(*v8::True(isolate)) == *true_value); |
18806 i::Handle<i::Object> false_value = factory->false_value(); | 18799 i::Handle<i::Object> false_value = factory->false_value(); |
18807 CHECK(*v8::Utils::OpenHandle(*v8::False()) == *false_value); | 18800 CHECK(*v8::Utils::OpenHandle(*v8::False()) == *false_value); |
18808 CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value); | 18801 CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value); |
18809 | |
18810 // Test after-death behavior. | |
18811 CHECK(i::Internals::IsInitialized(isolate)); | |
18812 CHECK_EQ(0, fatal_error_callback_counter); | |
18813 v8::V8::SetFatalErrorHandler(CountingErrorCallback); | |
18814 v8::Utils::ReportApiFailure("StaticGetters()", "Kill V8"); | |
18815 i::Isolate::Current()->TearDown(); | |
18816 CHECK(!i::Internals::IsInitialized(isolate)); | |
18817 CHECK_EQ(1, fatal_error_callback_counter); | |
18818 CHECK(v8::Undefined().IsEmpty()); | |
18819 CHECK_EQ(2, fatal_error_callback_counter); | |
18820 CHECK(v8::Undefined(isolate).IsEmpty()); | |
18821 CHECK_EQ(3, fatal_error_callback_counter); | |
18822 CHECK(v8::Null().IsEmpty()); | |
18823 CHECK_EQ(4, fatal_error_callback_counter); | |
18824 CHECK(v8::Null(isolate).IsEmpty()); | |
18825 CHECK_EQ(5, fatal_error_callback_counter); | |
18826 CHECK(v8::True().IsEmpty()); | |
18827 CHECK_EQ(6, fatal_error_callback_counter); | |
18828 CHECK(v8::True(isolate).IsEmpty()); | |
18829 CHECK_EQ(7, fatal_error_callback_counter); | |
18830 CHECK(v8::False().IsEmpty()); | |
18831 CHECK_EQ(8, fatal_error_callback_counter); | |
18832 CHECK(v8::False(isolate).IsEmpty()); | |
18833 CHECK_EQ(9, fatal_error_callback_counter); | |
18834 } | 18802 } |
18835 | 18803 |
18836 | 18804 |
18837 TEST(IsolateEmbedderData) { | 18805 TEST(IsolateEmbedderData) { |
18838 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 18806 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
18839 CHECK_EQ(NULL, isolate->GetData()); | 18807 CHECK_EQ(NULL, isolate->GetData()); |
18840 CHECK_EQ(NULL, ISOLATE->GetData()); | 18808 CHECK_EQ(NULL, ISOLATE->GetData()); |
18841 static void* data1 = reinterpret_cast<void*>(0xacce55ed); | 18809 static void* data1 = reinterpret_cast<void*>(0xacce55ed); |
18842 isolate->SetData(data1); | 18810 isolate->SetData(data1); |
18843 CHECK_EQ(data1, isolate->GetData()); | 18811 CHECK_EQ(data1, isolate->GetData()); |
18844 CHECK_EQ(data1, ISOLATE->GetData()); | 18812 CHECK_EQ(data1, ISOLATE->GetData()); |
18845 static void* data2 = reinterpret_cast<void*>(0xdecea5ed); | 18813 static void* data2 = reinterpret_cast<void*>(0xdecea5ed); |
18846 ISOLATE->SetData(data2); | 18814 ISOLATE->SetData(data2); |
18847 CHECK_EQ(data2, isolate->GetData()); | 18815 CHECK_EQ(data2, isolate->GetData()); |
18848 CHECK_EQ(data2, ISOLATE->GetData()); | 18816 CHECK_EQ(data2, ISOLATE->GetData()); |
18849 ISOLATE->TearDown(); | 18817 ISOLATE->TearDown(); |
18850 CHECK_EQ(data2, isolate->GetData()); | 18818 CHECK_EQ(data2, isolate->GetData()); |
18851 CHECK_EQ(data2, ISOLATE->GetData()); | 18819 CHECK_EQ(data2, ISOLATE->GetData()); |
18852 } | 18820 } |
18853 | 18821 |
18854 | 18822 |
18855 TEST(StringEmpty) { | 18823 TEST(StringEmpty) { |
18856 LocalContext context; | 18824 LocalContext context; |
18857 i::Factory* factory = i::Isolate::Current()->factory(); | 18825 i::Factory* factory = i::Isolate::Current()->factory(); |
18858 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 18826 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
18859 v8::HandleScope scope(isolate); | 18827 v8::HandleScope scope(isolate); |
18860 i::Handle<i::Object> empty_string = factory->empty_string(); | 18828 i::Handle<i::Object> empty_string = factory->empty_string(); |
18861 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty()) == *empty_string); | 18829 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty()) == *empty_string); |
18862 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string); | 18830 CHECK(*v8::Utils::OpenHandle(*v8::String::Empty(isolate)) == *empty_string); |
18863 | |
18864 // Test after-death behavior. | |
18865 CHECK(i::Internals::IsInitialized(isolate)); | |
18866 CHECK_EQ(0, fatal_error_callback_counter); | |
18867 v8::V8::SetFatalErrorHandler(CountingErrorCallback); | |
18868 v8::Utils::ReportApiFailure("StringEmpty()", "Kill V8"); | |
18869 i::Isolate::Current()->TearDown(); | |
18870 CHECK(!i::Internals::IsInitialized(isolate)); | |
18871 CHECK_EQ(1, fatal_error_callback_counter); | |
18872 CHECK(v8::String::Empty().IsEmpty()); | |
18873 CHECK_EQ(2, fatal_error_callback_counter); | |
18874 CHECK(v8::String::Empty(isolate).IsEmpty()); | |
18875 CHECK_EQ(3, fatal_error_callback_counter); | |
18876 } | 18831 } |
18877 | 18832 |
18878 | 18833 |
18879 static int instance_checked_getter_count = 0; | 18834 static int instance_checked_getter_count = 0; |
18880 static void InstanceCheckedGetter( | 18835 static void InstanceCheckedGetter( |
18881 Local<String> name, | 18836 Local<String> name, |
18882 const v8::PropertyCallbackInfo<v8::Value>& info) { | 18837 const v8::PropertyCallbackInfo<v8::Value>& info) { |
18883 CHECK_EQ(name, v8_str("foo")); | 18838 CHECK_EQ(name, v8_str("foo")); |
18884 instance_checked_getter_count++; | 18839 instance_checked_getter_count++; |
18885 info.GetReturnValue().Set(v8_num(11)); | 18840 info.GetReturnValue().Set(v8_num(11)); |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19337 i::Semaphore* sem_; | 19292 i::Semaphore* sem_; |
19338 volatile int sem_value_; | 19293 volatile int sem_value_; |
19339 }; | 19294 }; |
19340 | 19295 |
19341 | 19296 |
19342 THREADED_TEST(SemaphoreInterruption) { | 19297 THREADED_TEST(SemaphoreInterruption) { |
19343 ThreadInterruptTest().RunTest(); | 19298 ThreadInterruptTest().RunTest(); |
19344 } | 19299 } |
19345 | 19300 |
19346 #endif // WIN32 | 19301 #endif // WIN32 |
OLD | NEW |