Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "vm/dart_api_state.h" | |
| 6 #include "vm/flags.h" | 7 #include "vm/flags.h" |
| 7 #include "vm/handles.h" | 8 #include "vm/handles.h" |
| 8 #include "vm/heap.h" | 9 #include "vm/heap.h" |
| 9 #include "vm/object.h" | 10 #include "vm/object.h" |
| 10 #include "vm/unit_test.h" | 11 #include "vm/unit_test.h" |
| 11 #include "vm/zone.h" | 12 #include "vm/zone.h" |
| 12 | 13 |
| 13 namespace dart { | 14 namespace dart { |
| 14 | 15 |
| 15 // Unit test for Zone handle allocation. | 16 // Unit test for Zone handle allocation. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 const Smi& handle = Smi::Handle(Smi::New(i)); | 71 const Smi& handle = Smi::Handle(Smi::New(i)); |
| 71 EXPECT(handle.IsSmi()); | 72 EXPECT(handle.IsSmi()); |
| 72 EXPECT_EQ(i, handle.Value()); | 73 EXPECT_EQ(i, handle.Value()); |
| 73 } | 74 } |
| 74 EXPECT_EQ((handle_count + (2 * kNumHandles)), | 75 EXPECT_EQ((handle_count + (2 * kNumHandles)), |
| 75 VMHandles::ScopedHandleCount()); | 76 VMHandles::ScopedHandleCount()); |
| 76 } | 77 } |
| 77 EXPECT_EQ(handle_count, VMHandles::ScopedHandleCount()); | 78 EXPECT_EQ(handle_count, VMHandles::ScopedHandleCount()); |
| 78 } | 79 } |
| 79 | 80 |
| 81 | |
| 82 // Unit test for handle validity checks. | |
| 83 TEST_CASE(CheckHandleValidity) { | |
| 84 #if defined(DEBUG) | |
| 85 FLAG_trace_handles = true; | |
| 86 #endif | |
| 87 Dart_Handle handle = NULL; | |
| 88 { | |
| 89 StackZone sz(Thread::Current()); | |
| 90 handle = reinterpret_cast<Dart_Handle>(&Smi::ZoneHandle(Smi::New(1))); | |
| 91 EXPECT_VALID(handle); | |
| 92 } | |
| 93 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
| |
| 94 } | |
| 95 | |
| 80 } // namespace dart | 96 } // namespace dart |
| OLD | NEW |