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

Unified Diff: dart/runtime/vm/dart_api_impl_test.cc

Issue 119673004: Version 1.1.0-dev.5.2 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 11 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
« no previous file with comments | « dart/runtime/vm/dart_api_impl.cc ('k') | dart/runtime/vm/debugger.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/runtime/vm/dart_api_impl_test.cc
===================================================================
--- dart/runtime/vm/dart_api_impl_test.cc (revision 31530)
+++ dart/runtime/vm/dart_api_impl_test.cc (working copy)
@@ -1897,6 +1897,38 @@
}
+// Test that we can assign to a persistent handle.
+UNIT_TEST_CASE(AssignToPersistentHandle) {
+ const char* kTestString1 = "Test String1";
+ const char* kTestString2 = "Test String2";
+ TestIsolateScope __test_isolate__;
+
+ Isolate* isolate = Isolate::Current();
+ EXPECT(isolate != NULL);
+ ApiState* state = isolate->api_state();
+ EXPECT(state != NULL);
+ DARTSCOPE(isolate);
+ String& str = String::Handle();
+
+ // Start with a known persistent handle.
+ Dart_Handle ref1 = Api::NewHandle(isolate, String::New(kTestString1));
+ Dart_PersistentHandle obj = Dart_NewPersistentHandle(ref1);
+ EXPECT(state->IsValidPersistentHandle(obj));
+ str ^= Api::UnwrapAsPersistentHandle(obj)->raw();
+ EXPECT(str.Equals(kTestString1));
+
+ // Now create another local handle and assign it to the persistent handle.
+ Dart_Handle ref2 = Api::NewHandle(isolate, String::New(kTestString2));
+ Dart_SetPersistentHandle(obj, ref2);
+ str ^= Api::UnwrapAsPersistentHandle(obj)->raw();
+ EXPECT(str.Equals(kTestString2));
+
+ // Now assign Null to the persistent handle and check.
+ Dart_SetPersistentHandle(obj, Dart_Null());
+ EXPECT(Dart_IsNull(obj));
+}
+
+
// Helper class to ensure new gen GC is triggered without any side effects.
// The normal call to CollectGarbage(Heap::kNew) could potentially trigger
// an old gen collection if there is a promotion failure and this could
« no previous file with comments | « dart/runtime/vm/dart_api_impl.cc ('k') | dart/runtime/vm/debugger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698