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/flags.h" | 6 #include "vm/flags.h" |
| 7 #include "vm/handles.h" | 7 #include "vm/handles.h" |
| 8 #include "vm/heap.h" | 8 #include "vm/heap.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 const Smi& handle = Smi::Handle(Smi::New(i)); | 70 const Smi& handle = Smi::Handle(Smi::New(i)); |
| 71 EXPECT(handle.IsSmi()); | 71 EXPECT(handle.IsSmi()); |
| 72 EXPECT_EQ(i, handle.Value()); | 72 EXPECT_EQ(i, handle.Value()); |
| 73 } | 73 } |
| 74 EXPECT_EQ((handle_count + (2 * kNumHandles)), | 74 EXPECT_EQ((handle_count + (2 * kNumHandles)), |
| 75 VMHandles::ScopedHandleCount()); | 75 VMHandles::ScopedHandleCount()); |
| 76 } | 76 } |
| 77 EXPECT_EQ(handle_count, VMHandles::ScopedHandleCount()); | 77 EXPECT_EQ(handle_count, VMHandles::ScopedHandleCount()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 | |
| 81 // Unit test for Zone handle allocation. | |
| 82 TEST_CASE(CheckHandleValidity) { | |
| 83 #if defined(DEBUG) | |
| 84 FLAG_trace_handles = true; | |
| 85 #endif | |
| 86 Dart_Handle handle = NULL; | |
| 87 { | |
| 88 StackZone sz(Thread::Current()); | |
| 89 handle = reinterpret_cast<Dart_Handle>(&Smi::ZoneHandle(Smi::New(1))); | |
| 90 EXPECT_VALID(handle); | |
| 91 } | |
| 92 EXPECT_INVALID(handle); | |
|
siva
2017/01/18 23:27:06
EXPECT(!Api::IsValid(handle));
bkonyi
2017/01/19 01:05:13
Done.
| |
| 93 } | |
| 94 | |
| 80 } // namespace dart | 95 } // namespace dart |
| OLD | NEW |