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

Side by Side 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 unified diff | Download patch
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 "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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698