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

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: 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/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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698