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

Side by Side Diff: runtime/vm/handles_test.cc

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/handles_impl.h ('k') | runtime/vm/hash_map.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "vm/handles.h"
5 #include "platform/assert.h" 6 #include "platform/assert.h"
6 #include "vm/dart_api_state.h" 7 #include "vm/dart_api_state.h"
7 #include "vm/flags.h" 8 #include "vm/flags.h"
8 #include "vm/handles.h"
9 #include "vm/heap.h" 9 #include "vm/heap.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
11 #include "vm/unit_test.h" 11 #include "vm/unit_test.h"
12 #include "vm/zone.h" 12 #include "vm/zone.h"
13 13
14 namespace dart { 14 namespace dart {
15 15
16 // Unit test for Zone handle allocation. 16 // Unit test for Zone handle allocation.
17 TEST_CASE(AllocateZoneHandle) { 17 TEST_CASE(AllocateZoneHandle) {
18 #if defined(DEBUG) 18 #if defined(DEBUG)
(...skipping 11 matching lines...) Expand all
30 EXPECT_EQ(kNumHandles + initial_count, VMHandles::ZoneHandleCount()); 30 EXPECT_EQ(kNumHandles + initial_count, VMHandles::ZoneHandleCount());
31 // Create some more zone handles. 31 // Create some more zone handles.
32 for (int i = kNumHandles; i < (2 * kNumHandles); i++) { 32 for (int i = kNumHandles; i < (2 * kNumHandles); i++) {
33 const Smi& handle = Smi::ZoneHandle(Smi::New(i)); 33 const Smi& handle = Smi::ZoneHandle(Smi::New(i));
34 EXPECT(handle.IsSmi()); 34 EXPECT(handle.IsSmi());
35 EXPECT_EQ(i, handle.Value()); 35 EXPECT_EQ(i, handle.Value());
36 } 36 }
37 EXPECT_EQ((2 * kNumHandles) + initial_count, VMHandles::ZoneHandleCount()); 37 EXPECT_EQ((2 * kNumHandles) + initial_count, VMHandles::ZoneHandleCount());
38 } 38 }
39 39
40
41 // Unit test for Scope handle allocation. 40 // Unit test for Scope handle allocation.
42 TEST_CASE(AllocateScopeHandle) { 41 TEST_CASE(AllocateScopeHandle) {
43 #if defined(DEBUG) 42 #if defined(DEBUG)
44 FLAG_trace_handles = true; 43 FLAG_trace_handles = true;
45 #endif 44 #endif
46 int32_t handle_count = VMHandles::ScopedHandleCount(); 45 int32_t handle_count = VMHandles::ScopedHandleCount();
47 static const int kNumHandles = 65; 46 static const int kNumHandles = 65;
48 // Create some scoped handles. 47 // Create some scoped handles.
49 { 48 {
50 Thread* thread = Thread::Current(); 49 Thread* thread = Thread::Current();
(...skipping 20 matching lines...) Expand all
71 const Smi& handle = Smi::Handle(Smi::New(i)); 70 const Smi& handle = Smi::Handle(Smi::New(i));
72 EXPECT(handle.IsSmi()); 71 EXPECT(handle.IsSmi());
73 EXPECT_EQ(i, handle.Value()); 72 EXPECT_EQ(i, handle.Value());
74 } 73 }
75 EXPECT_EQ((handle_count + (2 * kNumHandles)), 74 EXPECT_EQ((handle_count + (2 * kNumHandles)),
76 VMHandles::ScopedHandleCount()); 75 VMHandles::ScopedHandleCount());
77 } 76 }
78 EXPECT_EQ(handle_count, VMHandles::ScopedHandleCount()); 77 EXPECT_EQ(handle_count, VMHandles::ScopedHandleCount());
79 } 78 }
80 79
81
82 static void NoopCallback(void* isolate_callback_data, 80 static void NoopCallback(void* isolate_callback_data,
83 Dart_WeakPersistentHandle handle, 81 Dart_WeakPersistentHandle handle,
84 void* peer) {} 82 void* peer) {}
85 83
86
87 // Unit test for handle validity checks. 84 // Unit test for handle validity checks.
88 TEST_CASE(CheckHandleValidity) { 85 TEST_CASE(CheckHandleValidity) {
89 #if defined(DEBUG) 86 #if defined(DEBUG)
90 FLAG_trace_handles = true; 87 FLAG_trace_handles = true;
91 #endif 88 #endif
92 Thread* current = Thread::Current(); 89 Thread* current = Thread::Current();
93 Dart_Handle handle = NULL; 90 Dart_Handle handle = NULL;
94 // Check validity using zone handles. 91 // Check validity using zone handles.
95 { 92 {
96 StackZone sz(current); 93 StackZone sz(current);
(...skipping 28 matching lines...) Expand all
125 EXPECT_NOTNULL(handle); 122 EXPECT_NOTNULL(handle);
126 EXPECT_VALID(handle); 123 EXPECT_VALID(handle);
127 124
128 Dart_DeleteWeakPersistentHandle( 125 Dart_DeleteWeakPersistentHandle(
129 reinterpret_cast<Dart_Isolate>(isolate), 126 reinterpret_cast<Dart_Isolate>(isolate),
130 reinterpret_cast<Dart_WeakPersistentHandle>(handle)); 127 reinterpret_cast<Dart_WeakPersistentHandle>(handle));
131 EXPECT(!Api::IsValid(handle)); 128 EXPECT(!Api::IsValid(handle));
132 } 129 }
133 130
134 } // namespace dart 131 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/handles_impl.h ('k') | runtime/vm/hash_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698