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

Unified Diff: test/cctest/test-api.cc

Issue 14788013: Add Persistent<T>::Reset which disposes the handle and redirects it to point to another object. (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: less whitespace Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
« include/v8.h ('K') | « include/v8.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 11d9fcaba8505908ba6c96c600f929ad540b656a..e867efbb025c97829b4b750a46016950da80124b 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -2486,6 +2486,33 @@ THREADED_TEST(GlobalHandle) {
}
+THREADED_TEST(ResettingGlobalHandle) {
Sven Panne 2013/05/07 09:49:31 A test for passing an empty handle to reset is mis
marja 2013/05/07 11:17:17 Added a test here which says that after resetting
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::internal::GlobalHandles* global_handles = NULL;
+ int initial_handle_count = 0;
+ v8::Persistent<String> global;
+ {
+ v8::HandleScope scope(isolate);
+ Local<String> str = v8_str("str");
+ global_handles =
+ reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles();
+ initial_handle_count = global_handles->NumberOfGlobalHandles();
+ global = v8::Persistent<String>::New(isolate, str);
+ }
+ CHECK_EQ(global->Length(), 3);
+ CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count + 1);
+ {
+ v8::HandleScope scope(isolate);
+ Local<String> str = v8_str("longer");
+ global.Reset(isolate, str);
+ }
+ CHECK_EQ(global->Length(), 6);
+ CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count + 1);
+ global.Dispose(isolate);
+ CHECK_EQ(global_handles->NumberOfGlobalHandles(), initial_handle_count);
+}
+
+
THREADED_TEST(LocalHandle) {
v8::HandleScope scope(v8::Isolate::GetCurrent());
v8::Local<String> local = v8::Local<String>::New(v8_str("str"));
« include/v8.h ('K') | « include/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698