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

Side by Side Diff: base/bind_unittest.nc

Issue 7458012: Create a "no compile" drivers script in python to unittest compile time asserts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: increase timeouts Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/callback.h"
6 #include "base/bind.h"
7
8 namespace base {
9 namespace {
10
11 class NoRef {
12 public:
13 void VoidMethod0() {}
14 };
15
16 class HasRef : public NoRef {
17 public:
18 void AddRef(void) const {}
19 bool Release(void) const { return true; }
20 };
21
22 int Identity(int n) {
23 return n;
24 }
25
26 #if defined(TEST_METHOD_ON_CONST_OBJECT) // [r"invalid conversion from 'const b ase::<unnamed>::NoRef\*' to 'base::<unnamed>::NoRef\*'"]
27
28 // - Method bound to const-object.
29 //
30 // Only const methods should be allowed to work with const objects.
31
32 void WontCompile() {
33 HasRef has_ref;
34 const HasRef* const_has_ref_ptr_ = &has_ref;
35 Callback<void(void)> method_to_const_cb =
36 Bind(&HasRef::VoidMethod0, const_has_ref_ptr_);
37 method_to_const_cb.Run();
38 }
39
40
41 #elif defined(TEST_SUPERTYPE_ASSIGNMENT) // [r"no match for 'operator=' in 'cb_ a1 = cb_b1'"]
42
43 void WontCompile() {
44 Callback<int(void)> cb_a1 = Bind(&Identity, 1);
45 Callback<void(void)> cb_b1;
46 cb_a1 = cb_b1;
47 }
48
49 #endif
50
51 } // namespace
52 } // namespace base
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | build/nocompile.gypi » ('j') | tools/nocompile_driver.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698