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

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

Issue 978783002: give UniquePersistent full move semantics (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: tests Created 5 years, 10 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 44270382d4e76e9f03e04d629066efd59d72b7d6..606411a1b97c258b3a7f29ce817c42e92068f00b 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -28,6 +28,7 @@
#include <climits>
#include <csignal>
#include <map>
+#include <memory>
#include <string>
#include "test/cctest/test-api.h"
@@ -3243,6 +3244,32 @@ TEST(PersistentValueVector) {
}
+TEST(PersistentStdContainerCompatible) {
+ LocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::internal::GlobalHandles* global_handles =
+ reinterpret_cast<v8::internal::Isolate*>(isolate)->global_handles();
+ int handle_count = global_handles->global_handles_count();
+ HandleScope scope(isolate);
+
+ std::vector<v8::UniquePersistent<v8::Object>> vector;
+
+ auto obj = v8::Object::New(isolate);
+ v8::UniquePersistent<v8::Object> global(isolate, obj);
+
+ vector.push_back(std::move(global));
jamesr 2015/03/04 18:52:37 this won't compile on all platforms that chromium
dcarney 2015/03/04 19:40:24 this test stuff is v8 only. I just wanted to chec
+
+ CHECK_EQ(1, static_cast<int>(vector.size()));
+ CHECK(global.IsEmpty());
+ CHECK(obj == vector[0]);
+
+ CHECK_EQ(1 + handle_count, global_handles->global_handles_count());
+
+ vector.clear();
+ CHECK_EQ(handle_count, global_handles->global_handles_count());
+}
+
+
THREADED_TEST(GlobalHandleUpcast) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
« 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