| Index: base/bind_unittest.nc
|
| diff --git a/base/bind_unittest.nc b/base/bind_unittest.nc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4d0fcb2da90badf973605e27554daa26be8197eb
|
| --- /dev/null
|
| +++ b/base/bind_unittest.nc
|
| @@ -0,0 +1,85 @@
|
| +// 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(NCTEST_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(NCTEST_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;
|
| +}
|
| +
|
| +#elif defined(NCTEST_SUPERTYPE_ASSIGNMENT1) // [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;
|
| +}
|
| +
|
| +#elif defined(NCTEST_SUPERTYPE_ASSIGNMENT2) // [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;
|
| +}
|
| +
|
| +#elif defined(NCTEST_SUPERTYPE_ASSIGNMENT3k) // [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;
|
| +}
|
| +
|
| +#elif defined(NCTEST_SUPERTYPE_ASSIGNMENTr) // [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
|
|
|