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

Unified 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, 4 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 side-by-side diff with in-line comments
Download patch
Index: base/bind_unittest.nc
diff --git a/base/bind_unittest.nc b/base/bind_unittest.nc
new file mode 100644
index 0000000000000000000000000000000000000000..d6a98193cec6090e6b8932949535c733e97efeaa
--- /dev/null
+++ b/base/bind_unittest.nc
@@ -0,0 +1,52 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/callback.h"
+#include "base/bind.h"
+
+namespace base {
+namespace {
+
+class NoRef {
+ public:
+ void VoidMethod0() {}
+};
+
+class HasRef : public NoRef {
+ public:
+ void AddRef(void) const {}
+ bool Release(void) const { return true; }
+};
+
+int Identity(int n) {
+ return n;
+}
+
+#if defined(TEST_METHOD_ON_CONST_OBJECT) // [r"invalid conversion from 'const base::<unnamed>::NoRef\*' to 'base::<unnamed>::NoRef\*'"]
+
+// - Method bound to const-object.
+//
+// Only const methods should be allowed to work with const objects.
+
+void WontCompile() {
+ HasRef has_ref;
+ const HasRef* const_has_ref_ptr_ = &has_ref;
+ Callback<void(void)> method_to_const_cb =
+ Bind(&HasRef::VoidMethod0, const_has_ref_ptr_);
+ method_to_const_cb.Run();
+}
+
+
+#elif defined(TEST_SUPERTYPE_ASSIGNMENT) // [r"no match for 'operator=' in 'cb_a1 = cb_b1'"]
+
+void WontCompile() {
+ Callback<int(void)> cb_a1 = Bind(&Identity, 1);
+ Callback<void(void)> cb_b1;
+ cb_a1 = cb_b1;
+}
+
+#endif
+
+} // namespace
+} // namespace base
« 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