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 |