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

Unified Diff: runtime/vm/handles_test.cc

Issue 2640573003: Resolution for issue #5092: Unit test handle checks consider dangling handles to be valid. (Closed)
Patch Set: Resolution for issue #5092: Unit test handle checks consider dangling handles to be valid. Created 3 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
Index: runtime/vm/handles_test.cc
diff --git a/runtime/vm/handles_test.cc b/runtime/vm/handles_test.cc
index 8a05fb750af0db59d9dc811f43dd6739a6394f46..83fc300ca454f371cc12521175600b5202b66bc3 100644
--- a/runtime/vm/handles_test.cc
+++ b/runtime/vm/handles_test.cc
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
#include "platform/assert.h"
+#include "vm/dart_api_state.h"
#include "vm/flags.h"
#include "vm/handles.h"
#include "vm/heap.h"
@@ -77,4 +78,19 @@ TEST_CASE(AllocateScopeHandle) {
EXPECT_EQ(handle_count, VMHandles::ScopedHandleCount());
}
+
+// Unit test for handle validity checks.
+TEST_CASE(CheckHandleValidity) {
+#if defined(DEBUG)
+ FLAG_trace_handles = true;
+#endif
+ Dart_Handle handle = NULL;
+ {
+ StackZone sz(Thread::Current());
+ handle = reinterpret_cast<Dart_Handle>(&Smi::ZoneHandle(Smi::New(1)));
+ EXPECT_VALID(handle);
+ }
+ EXPECT(!Api::IsValid(handle));
siva 2017/01/20 17:40:03 Can you enhance this test to also include tests fo
bkonyi 2017/01/20 23:07:11 I've gone ahead and added explicit tests for scope
+}
+
} // namespace dart

Powered by Google App Engine
This is Rietveld 408576698