Chromium Code Reviews| 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 |