diff options
Diffstat (limited to 'deps/v8/test/cctest')
-rw-r--r-- | deps/v8/test/cctest/test-accessors.cc | 2 | ||||
-rw-r--r-- | deps/v8/test/cctest/test-api.cc | 113 | ||||
-rw-r--r-- | deps/v8/test/cctest/test-circular-queue.cc | 2 | ||||
-rw-r--r-- | deps/v8/test/cctest/test-cpu-profiler.cc | 2 | ||||
-rw-r--r-- | deps/v8/test/cctest/test-heap-profiler.cc | 2 | ||||
-rw-r--r-- | deps/v8/test/cctest/test-lockers.cc | 4 | ||||
-rw-r--r-- | deps/v8/test/cctest/test-log-stack-tracer.cc | 2 | ||||
-rw-r--r-- | deps/v8/test/cctest/test-log.cc | 2 | ||||
-rwxr-xr-x | deps/v8/test/cctest/test-parsing.cc | 8 | ||||
-rw-r--r-- | deps/v8/test/cctest/test-profile-generator.cc | 2 | ||||
-rw-r--r-- | deps/v8/test/cctest/test-unbound-queue.cc | 2 |
11 files changed, 67 insertions, 74 deletions
diff --git a/deps/v8/test/cctest/test-accessors.cc b/deps/v8/test/cctest/test-accessors.cc index 028f82f3d..d95536d2d 100644 --- a/deps/v8/test/cctest/test-accessors.cc +++ b/deps/v8/test/cctest/test-accessors.cc @@ -44,8 +44,6 @@ using ::v8::Function; using ::v8::AccessorInfo; using ::v8::Extension; -namespace i = ::v8::internal; - static v8::Handle<Value> handle_property(Local<String> name, const AccessorInfo&) { ApiTestFuzzer::Fuzz(); diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index c694ae38a..d5e17b89a 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -72,8 +72,6 @@ using ::v8::Undefined; using ::v8::V8; using ::v8::Value; -namespace i = ::i; - static void ExpectString(const char* code, const char* expected) { Local<Value> result = CompileRun(code); @@ -331,16 +329,14 @@ static uint16_t* AsciiToTwoByteString(const char* source) { class TestResource: public String::ExternalStringResource { public: - static int dispose_count; - - explicit TestResource(uint16_t* data) - : data_(data), length_(0) { + explicit TestResource(uint16_t* data, int* counter = NULL) + : data_(data), length_(0), counter_(counter) { while (data[length_]) ++length_; } ~TestResource() { i::DeleteArray(data_); - ++dispose_count; + if (counter_ != NULL) ++*counter_; } const uint16_t* data() const { @@ -353,23 +349,18 @@ class TestResource: public String::ExternalStringResource { private: uint16_t* data_; size_t length_; + int* counter_; }; -int TestResource::dispose_count = 0; - - class TestAsciiResource: public String::ExternalAsciiStringResource { public: - static int dispose_count; - - explicit TestAsciiResource(const char* data) - : data_(data), - length_(strlen(data)) { } + explicit TestAsciiResource(const char* data, int* counter = NULL) + : data_(data), length_(strlen(data)), counter_(counter) { } ~TestAsciiResource() { i::DeleteArray(data_); - ++dispose_count; + if (counter_ != NULL) ++*counter_; } const char* data() const { @@ -382,20 +373,18 @@ class TestAsciiResource: public String::ExternalAsciiStringResource { private: const char* data_; size_t length_; + int* counter_; }; -int TestAsciiResource::dispose_count = 0; - - THREADED_TEST(ScriptUsingStringResource) { - TestResource::dispose_count = 0; + int dispose_count = 0; const char* c_source = "1 + 2 * 3"; uint16_t* two_byte_source = AsciiToTwoByteString(c_source); { v8::HandleScope scope; LocalContext env; - TestResource* resource = new TestResource(two_byte_source); + TestResource* resource = new TestResource(two_byte_source, &dispose_count); Local<String> source = String::NewExternal(resource); Local<Script> script = Script::Compile(source); Local<Value> value = script->Run(); @@ -405,37 +394,38 @@ THREADED_TEST(ScriptUsingStringResource) { CHECK_EQ(resource, static_cast<TestResource*>(source->GetExternalStringResource())); HEAP->CollectAllGarbage(false); - CHECK_EQ(0, TestResource::dispose_count); + CHECK_EQ(0, dispose_count); } v8::internal::Isolate::Current()->compilation_cache()->Clear(); HEAP->CollectAllGarbage(false); - CHECK_EQ(1, TestResource::dispose_count); + CHECK_EQ(1, dispose_count); } THREADED_TEST(ScriptUsingAsciiStringResource) { - TestAsciiResource::dispose_count = 0; + int dispose_count = 0; const char* c_source = "1 + 2 * 3"; { v8::HandleScope scope; LocalContext env; Local<String> source = - String::NewExternal(new TestAsciiResource(i::StrDup(c_source))); + String::NewExternal(new TestAsciiResource(i::StrDup(c_source), + &dispose_count)); Local<Script> script = Script::Compile(source); Local<Value> value = script->Run(); CHECK(value->IsNumber()); CHECK_EQ(7, value->Int32Value()); HEAP->CollectAllGarbage(false); - CHECK_EQ(0, TestAsciiResource::dispose_count); + CHECK_EQ(0, dispose_count); } i::Isolate::Current()->compilation_cache()->Clear(); HEAP->CollectAllGarbage(false); - CHECK_EQ(1, TestAsciiResource::dispose_count); + CHECK_EQ(1, dispose_count); } THREADED_TEST(ScriptMakingExternalString) { - TestResource::dispose_count = 0; + int dispose_count = 0; uint16_t* two_byte_source = AsciiToTwoByteString("1 + 2 * 3"); { v8::HandleScope scope; @@ -444,23 +434,24 @@ THREADED_TEST(ScriptMakingExternalString) { // Trigger GCs so that the newly allocated string moves to old gen. HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now - bool success = source->MakeExternal(new TestResource(two_byte_source)); + bool success = source->MakeExternal(new TestResource(two_byte_source, + &dispose_count)); CHECK(success); Local<Script> script = Script::Compile(source); Local<Value> value = script->Run(); CHECK(value->IsNumber()); CHECK_EQ(7, value->Int32Value()); HEAP->CollectAllGarbage(false); - CHECK_EQ(0, TestResource::dispose_count); + CHECK_EQ(0, dispose_count); } i::Isolate::Current()->compilation_cache()->Clear(); HEAP->CollectAllGarbage(false); - CHECK_EQ(1, TestResource::dispose_count); + CHECK_EQ(1, dispose_count); } THREADED_TEST(ScriptMakingExternalAsciiString) { - TestAsciiResource::dispose_count = 0; + int dispose_count = 0; const char* c_source = "1 + 2 * 3"; { v8::HandleScope scope; @@ -470,18 +461,18 @@ THREADED_TEST(ScriptMakingExternalAsciiString) { HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now bool success = source->MakeExternal( - new TestAsciiResource(i::StrDup(c_source))); + new TestAsciiResource(i::StrDup(c_source), &dispose_count)); CHECK(success); Local<Script> script = Script::Compile(source); Local<Value> value = script->Run(); CHECK(value->IsNumber()); CHECK_EQ(7, value->Int32Value()); HEAP->CollectAllGarbage(false); - CHECK_EQ(0, TestAsciiResource::dispose_count); + CHECK_EQ(0, dispose_count); } i::Isolate::Current()->compilation_cache()->Clear(); HEAP->CollectAllGarbage(false); - CHECK_EQ(1, TestAsciiResource::dispose_count); + CHECK_EQ(1, dispose_count); } @@ -605,49 +596,52 @@ THREADED_TEST(UsingExternalAsciiString) { THREADED_TEST(ScavengeExternalString) { - TestResource::dispose_count = 0; + int dispose_count = 0; bool in_new_space = false; { v8::HandleScope scope; uint16_t* two_byte_string = AsciiToTwoByteString("test string"); Local<String> string = - String::NewExternal(new TestResource(two_byte_string)); + String::NewExternal(new TestResource(two_byte_string, + &dispose_count)); i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); HEAP->CollectGarbage(i::NEW_SPACE); in_new_space = HEAP->InNewSpace(*istring); CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring)); - CHECK_EQ(0, TestResource::dispose_count); + CHECK_EQ(0, dispose_count); } HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); - CHECK_EQ(1, TestResource::dispose_count); + CHECK_EQ(1, dispose_count); } THREADED_TEST(ScavengeExternalAsciiString) { - TestAsciiResource::dispose_count = 0; + int dispose_count = 0; bool in_new_space = false; { v8::HandleScope scope; const char* one_byte_string = "test string"; Local<String> string = String::NewExternal( - new TestAsciiResource(i::StrDup(one_byte_string))); + new TestAsciiResource(i::StrDup(one_byte_string), &dispose_count)); i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); HEAP->CollectGarbage(i::NEW_SPACE); in_new_space = HEAP->InNewSpace(*istring); CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring)); - CHECK_EQ(0, TestAsciiResource::dispose_count); + CHECK_EQ(0, dispose_count); } HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); - CHECK_EQ(1, TestAsciiResource::dispose_count); + CHECK_EQ(1, dispose_count); } class TestAsciiResourceWithDisposeControl: public TestAsciiResource { public: + // Only used by non-threaded tests, so it can use static fields. static int dispose_calls; + static int dispose_count; TestAsciiResourceWithDisposeControl(const char* data, bool dispose) - : TestAsciiResource(data), + : TestAsciiResource(data, &dispose_count), dispose_(dispose) { } void Dispose() { @@ -659,6 +653,7 @@ class TestAsciiResourceWithDisposeControl: public TestAsciiResource { }; +int TestAsciiResourceWithDisposeControl::dispose_count = 0; int TestAsciiResourceWithDisposeControl::dispose_calls = 0; @@ -666,7 +661,7 @@ TEST(ExternalStringWithDisposeHandling) { const char* c_source = "1 + 2 * 3"; // Use a stack allocated external string resource allocated object. - TestAsciiResource::dispose_count = 0; + TestAsciiResourceWithDisposeControl::dispose_count = 0; TestAsciiResourceWithDisposeControl::dispose_calls = 0; TestAsciiResourceWithDisposeControl res_stack(i::StrDup(c_source), false); { @@ -678,15 +673,15 @@ TEST(ExternalStringWithDisposeHandling) { CHECK(value->IsNumber()); CHECK_EQ(7, value->Int32Value()); HEAP->CollectAllGarbage(false); - CHECK_EQ(0, TestAsciiResource::dispose_count); + CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); } i::Isolate::Current()->compilation_cache()->Clear(); HEAP->CollectAllGarbage(false); CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); - CHECK_EQ(0, TestAsciiResource::dispose_count); + CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); // Use a heap allocated external string resource allocated object. - TestAsciiResource::dispose_count = 0; + TestAsciiResourceWithDisposeControl::dispose_count = 0; TestAsciiResourceWithDisposeControl::dispose_calls = 0; TestAsciiResource* res_heap = new TestAsciiResourceWithDisposeControl(i::StrDup(c_source), true); @@ -699,12 +694,12 @@ TEST(ExternalStringWithDisposeHandling) { CHECK(value->IsNumber()); CHECK_EQ(7, value->Int32Value()); HEAP->CollectAllGarbage(false); - CHECK_EQ(0, TestAsciiResource::dispose_count); + CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); } i::Isolate::Current()->compilation_cache()->Clear(); HEAP->CollectAllGarbage(false); CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); - CHECK_EQ(1, TestAsciiResource::dispose_count); + CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_count); } @@ -14595,6 +14590,24 @@ THREADED_TEST(CreationContext) { } +THREADED_TEST(CreationContextOfJsFunction) { + HandleScope handle_scope; + Persistent<Context> context = Context::New(); + InstallContextId(context, 1); + + Local<Object> function; + { + Context::Scope scope(context); + function = CompileRun("function foo() {}; foo").As<Object>(); + } + + CHECK(function->CreationContext() == context); + CheckContextId(function, 1); + + context.Dispose(); +} + + Handle<Value> HasOwnPropertyIndexedPropertyGetter(uint32_t index, const AccessorInfo& info) { if (index == 42) return v8_str("yes"); diff --git a/deps/v8/test/cctest/test-circular-queue.cc b/deps/v8/test/cctest/test-circular-queue.cc index c4e5c4c24..2861b1f76 100644 --- a/deps/v8/test/cctest/test-circular-queue.cc +++ b/deps/v8/test/cctest/test-circular-queue.cc @@ -6,8 +6,6 @@ #include "circular-queue-inl.h" #include "cctest.h" -namespace i = v8::internal; - using i::SamplingCircularQueue; diff --git a/deps/v8/test/cctest/test-cpu-profiler.cc b/deps/v8/test/cctest/test-cpu-profiler.cc index 9ff2a171a..81c487da8 100644 --- a/deps/v8/test/cctest/test-cpu-profiler.cc +++ b/deps/v8/test/cctest/test-cpu-profiler.cc @@ -7,8 +7,6 @@ #include "cctest.h" #include "../include/v8-profiler.h" -namespace i = v8::internal; - using i::CodeEntry; using i::CpuProfile; using i::CpuProfiler; diff --git a/deps/v8/test/cctest/test-heap-profiler.cc b/deps/v8/test/cctest/test-heap-profiler.cc index 8675a0146..169e6dcbd 100644 --- a/deps/v8/test/cctest/test-heap-profiler.cc +++ b/deps/v8/test/cctest/test-heap-profiler.cc @@ -10,8 +10,6 @@ #include "utils-inl.h" #include "../include/v8-profiler.h" -namespace i = v8::internal; - namespace { class NamedEntriesDetector { diff --git a/deps/v8/test/cctest/test-lockers.cc b/deps/v8/test/cctest/test-lockers.cc index 2b184e913..d61fde250 100644 --- a/deps/v8/test/cctest/test-lockers.cc +++ b/deps/v8/test/cctest/test-lockers.cc @@ -54,10 +54,6 @@ using ::v8::String; using ::v8::Value; using ::v8::V8; -namespace i = ::i; - - - // Migrating an isolate class KangarooThread : public v8::internal::Thread { diff --git a/deps/v8/test/cctest/test-log-stack-tracer.cc b/deps/v8/test/cctest/test-log-stack-tracer.cc index 2bcb3fe0b..f536e6b19 100644 --- a/deps/v8/test/cctest/test-log-stack-tracer.cc +++ b/deps/v8/test/cctest/test-log-stack-tracer.cc @@ -54,8 +54,6 @@ using v8::internal::JSFunction; using v8::internal::StackTracer; using v8::internal::TickSample; -namespace i = v8::internal; - static v8::Persistent<v8::Context> env; diff --git a/deps/v8/test/cctest/test-log.cc b/deps/v8/test/cctest/test-log.cc index 262e7bb50..dfbc733e0 100644 --- a/deps/v8/test/cctest/test-log.cc +++ b/deps/v8/test/cctest/test-log.cc @@ -23,8 +23,6 @@ using v8::internal::EmbeddedVector; using v8::internal::Logger; using v8::internal::StrLength; -namespace i = v8::internal; - namespace { class ScopedLoggerInitializer { diff --git a/deps/v8/test/cctest/test-parsing.cc b/deps/v8/test/cctest/test-parsing.cc index fe738768d..8b6afdc59 100755 --- a/deps/v8/test/cctest/test-parsing.cc +++ b/deps/v8/test/cctest/test-parsing.cc @@ -40,8 +40,6 @@ #include "preparser.h" #include "cctest.h" -namespace i = ::v8::internal; - TEST(ScanKeywords) { struct KeywordToken { const char* keyword; @@ -66,6 +64,8 @@ TEST(ScanKeywords) { { i::Utf8ToUC16CharacterStream stream(keyword, length); i::JavaScriptScanner scanner(&unicode_cache); + // The scanner should parse 'let' as Token::LET for this test. + scanner.SetHarmonyBlockScoping(true); scanner.Initialize(&stream); CHECK_EQ(key_token.token, scanner.Next()); CHECK_EQ(i::Token::EOS, scanner.Next()); @@ -289,7 +289,7 @@ TEST(RegressChromium62639) { i::Utf8ToUC16CharacterStream stream(reinterpret_cast<const i::byte*>(program), static_cast<unsigned>(strlen(program))); i::ScriptDataImpl* data = - i::ParserApi::PreParse(&stream, NULL); + i::ParserApi::PreParse(&stream, NULL, false); CHECK(data->HasError()); delete data; } @@ -313,7 +313,7 @@ TEST(Regress928) { i::Utf8ToUC16CharacterStream stream(reinterpret_cast<const i::byte*>(program), static_cast<unsigned>(strlen(program))); i::ScriptDataImpl* data = - i::ParserApi::PartialPreParse(&stream, NULL); + i::ParserApi::PartialPreParse(&stream, NULL, false); CHECK(!data->HasError()); data->Initialize(); diff --git a/deps/v8/test/cctest/test-profile-generator.cc b/deps/v8/test/cctest/test-profile-generator.cc index 6d3044317..250ebd4a5 100644 --- a/deps/v8/test/cctest/test-profile-generator.cc +++ b/deps/v8/test/cctest/test-profile-generator.cc @@ -7,8 +7,6 @@ #include "cctest.h" #include "../include/v8-profiler.h" -namespace i = v8::internal; - using i::CodeEntry; using i::CodeMap; using i::CpuProfile; diff --git a/deps/v8/test/cctest/test-unbound-queue.cc b/deps/v8/test/cctest/test-unbound-queue.cc index df5509ef8..3dc87ae24 100644 --- a/deps/v8/test/cctest/test-unbound-queue.cc +++ b/deps/v8/test/cctest/test-unbound-queue.cc @@ -6,8 +6,6 @@ #include "unbound-queue-inl.h" #include "cctest.h" -namespace i = v8::internal; - using i::UnboundQueue; |