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

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: Address Ami's comments and don't busyloop. 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
9 namespace base {
10 namespace {
11
12 class NoRef {
13 public:
14 void VoidMethod0() {}
15 };
16
17 class HasRef : public NoRef {
18 public:
19 void AddRef(void) const {}
20 bool Release(void) const { return true; }
21 };
22
23 int Identity(int n) {
24 return n;
25 }
26
27
28 #if defined(NCTEST_METHOD_ON_CONST_OBJECT) // [r"invalid conversion from 'const base::<unnamed>::NoRef\*' to 'base::<unnamed>::NoRef\*'"]
29
30 // - Method bound to const-object.
31 //
32 // Only const methods should be allowed to work with const objects.
33
34 void WontCompile() {
35 HasRef has_ref;
36 const HasRef* const_has_ref_ptr_ = &has_ref;
37 Callback<void(void)> method_to_const_cb =
38 Bind(&HasRef::VoidMethod0, const_has_ref_ptr_);
39 method_to_const_cb.Run();
40 }
41
42 #elif defined(NCTEST_SUPERTYPE_ASSIGNMENT) // [r"no match for 'operator=' in 'c b_a1 = cb_b1'"]
43
44 void WontCompile() {
45 Callback<int(void)> cb_a1 = Bind(&Identity, 1);
46 Callback<void(void)> cb_b1;
47 cb_a1 = cb_b1;
48 }
49
50 #elif defined(NCTEST_SUPERTYPE_ASSIGNMENT1) // [r"no match for 'operator=' in ' cb_a1 = cb_b1'"]
51
52 void WontCompile() {
53 Callback<int(void)> cb_a1 = Bind(&Identity, 1);
54 Callback<void(void)> cb_b1;
55 cb_a1 = cb_b1;
56 }
57
58 #elif defined(NCTEST_SUPERTYPE_ASSIGNMENT2) // [r"no match for 'operator=' in ' cb_a1 = cb_b1'"]
59
60 void WontCompile() {
61 Callback<int(void)> cb_a1 = Bind(&Identity, 1);
62 Callback<void(void)> cb_b1;
63 cb_a1 = cb_b1;
64 }
65
66 #elif defined(NCTEST_SUPERTYPE_ASSIGNMENT3k) // [r"no match for 'operator=' in 'cb_a1 = cb_b1'"]
67
68 void WontCompile() {
69 Callback<int(void)> cb_a1 = Bind(&Identity, 1);
70 Callback<void(void)> cb_b1;
71 cb_a1 = cb_b1;
72 }
73
74 #elif defined(NCTEST_SUPERTYPE_ASSIGNMENTr) // [r"no match for 'operator=' in ' cb_a1 = cb_b1'"]
75
76 void WontCompile() {
77 Callback<int(void)> cb_a1 = Bind(&Identity, 1);
78 Callback<void(void)> cb_b1;
79 cb_a1 = cb_b1;
80 }
81
82 #endif
83
84 } // namespace
85 } // namespace base
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | build/nocompile.gypi » ('j') | build/nocompile.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698