pybind11/tests
Dean Moldovan 03f627ebb1 Make reference(_internal) the default return value policy for properties (#473)
* Make reference(_internal) the default return value policy for properties

Before this, all `def_property*` functions used `automatic` as their
default return value policy. This commit makes it so that:

 * Non-static properties use `reference_interal` by default, thus
   matching `def_readonly` and `def_readwrite`.

 * Static properties use `reference` by default, thus matching
   `def_readonly_static` and `def_readwrite_static`.

In case `cpp_function` is passed to any `def_property*`, its policy will
be used instead of any defaults. User-defined arguments in `extras`
still have top priority and will override both the default policies and
the ones from `cpp_function`.

Resolves #436.

* Almost always use return_value_policy::move for rvalues

For functions which return rvalues or rvalue references, the only viable
return value policies are `copy` and `move`. `reference(_internal)` and
`take_ownership` would take the address of a temporary which is always
an error.

This commit prevents possible user errors by overriding the bad rvalue
policies with `move`. Besides `move`, only `copy` is allowed, and only
if it's explicitly selected by the user.

This is also a necessary safety feature to support the new default
return value policies for properties: `reference(_internal)`.
2016-11-01 11:44:57 +01:00
..
CMakeLists.txt Test uncopyable static member 2016-10-20 21:32:55 +01:00
conftest.py Replace std::cout with py::print in tests 2016-09-07 01:25:27 +02:00
constructor_stats.h Extend attribute and item accessor interface using object_api 2016-09-23 02:00:01 +02:00
object.h minor doc & style fixes 2016-09-06 13:02:29 +09:00
pybind11_tests.cpp Make attr and item accessors throw on error instead of returning nullptr 2016-09-23 01:40:22 +02:00
pybind11_tests.h Replace std::cout with py::print in tests 2016-09-07 01:25:27 +02:00
test_alias_initialization.cpp Implement py::init_alias<>() constructors 2016-09-09 03:04:09 -04:00
test_alias_initialization.py Implement py::init_alias<>() constructors 2016-09-09 03:04:09 -04:00
test_buffers.cpp Make test initialization self-registering 2016-09-03 17:34:41 -04:00
test_buffers.py Port tests to pytest 2016-08-19 13:19:38 +02:00
test_callbacks.cpp Add py::dict() keyword constructor 2016-09-06 16:41:50 +02:00
test_callbacks.py nicer error message for invalid function arguments 2016-09-19 13:43:43 +02:00
test_chrono.cpp Changed non system clocks to be time deltas 2016-09-13 20:40:28 +10:00
test_chrono.py Relax constraints on testing to ensure they work in all cases. 2016-09-28 00:59:21 +10:00
test_class_args.cpp Support std::shared_ptr holder type out of the box 2016-10-20 16:19:58 +02:00
test_class_args.py Allow arbitrary class_ template option ordering 2016-09-06 12:22:13 -04:00
test_constants_and_functions.cpp Make test initialization self-registering 2016-09-03 17:34:41 -04:00
test_constants_and_functions.py Move enum tests into a new file 2016-08-19 13:19:38 +02:00
test_copy_move_policies.cpp Test uncopyable static member 2016-10-20 21:32:55 +01:00
test_copy_move_policies.py Test uncopyable static member 2016-10-20 21:32:55 +01:00
test_eigen.cpp minor doc & style fixes 2016-09-06 13:02:29 +09:00
test_eigen.py Fix test suite failure without numpy and improve module init diagnostics 2016-08-25 17:08:09 +02:00
test_enum.cpp minor doc & style fixes 2016-09-06 13:02:29 +09:00
test_enum.py Move enum tests into a new file 2016-08-19 13:19:38 +02:00
test_eval_call.py Rewrite eval tests to allow for simple asserts 2016-08-19 16:31:48 +02:00
test_eval.cpp Make error_already_set fetch and hold the Python error 2016-09-10 12:08:32 +02:00
test_eval.py Rewrite eval tests to allow for simple asserts 2016-08-19 16:31:48 +02:00
test_exceptions.cpp Added py::register_exception for simple case (#296) 2016-09-16 08:04:15 +02:00
test_exceptions.py Added py::register_exception for simple case (#296) 2016-09-16 08:04:15 +02:00
test_inheritance.cpp Multiple inheritance support 2016-09-19 13:45:31 +02:00
test_inheritance.py nicer error message for invalid function arguments 2016-09-19 13:43:43 +02:00
test_issues.cpp Prevent overwriting previous declarations 2016-10-24 22:45:51 -04:00
test_issues.py Prevent overwriting previous declarations 2016-10-24 22:45:51 -04:00
test_keep_alive.cpp Replace std::cout with py::print in tests 2016-09-07 01:25:27 +02:00
test_keep_alive.py Port tests to pytest 2016-08-19 13:19:38 +02:00
test_kwargs_and_defaults.cpp Remove superseded handle::operator() overloads 2016-09-06 16:41:50 +02:00
test_kwargs_and_defaults.py nicer error message for invalid function arguments 2016-09-19 13:43:43 +02:00
test_methods_and_attributes.cpp Make reference(_internal) the default return value policy for properties (#473) 2016-11-01 11:44:57 +01:00
test_methods_and_attributes.py Make reference(_internal) the default return value policy for properties (#473) 2016-11-01 11:44:57 +01:00
test_modules.cpp Make test initialization self-registering 2016-09-03 17:34:41 -04:00
test_modules.py Simplify tests by replacing output capture with asserts where possible 2016-08-19 13:19:38 +02:00
test_multiple_inheritance.cpp Support std::shared_ptr holder type out of the box 2016-10-20 16:19:58 +02:00
test_multiple_inheritance.py Multiple inheritance support 2016-09-19 13:45:31 +02:00
test_numpy_array.cpp minor style fix 2016-10-28 01:23:42 +02:00
test_numpy_array.py pybind11: implicitly convert NumPy integer scalars 2016-10-28 01:02:46 +02:00
test_numpy_dtypes.cpp Require existing typeinfo for direct conversions 2016-10-23 15:29:10 +01:00
test_numpy_dtypes.py Require existing typeinfo for direct conversions 2016-10-23 15:29:10 +01:00
test_numpy_vectorize.cpp Replace std::cout with py::print in tests 2016-09-07 01:25:27 +02:00
test_numpy_vectorize.py Simplify tests by replacing output capture with asserts where possible 2016-08-19 13:19:38 +02:00
test_opaque_types.cpp Make test initialization self-registering 2016-09-03 17:34:41 -04:00
test_opaque_types.py nicer error message for invalid function arguments 2016-09-19 13:43:43 +02:00
test_operator_overloading.cpp Make test initialization self-registering 2016-09-03 17:34:41 -04:00
test_operator_overloading.py Port tests to pytest 2016-08-19 13:19:38 +02:00
test_pickling.cpp Add dynamic attribute support 2016-10-11 22:13:02 +02:00
test_pickling.py Add dynamic attribute support 2016-10-11 22:13:02 +02:00
test_python_types.cpp Later assignments to accessors should not overwrite the original field 2016-09-23 02:00:01 +02:00
test_python_types.py Accept any sequence type as std::vector (or std::list) 2016-10-12 12:35:36 -04:00
test_sequences_and_iterators.cpp Make test initialization self-registering 2016-09-03 17:34:41 -04:00
test_sequences_and_iterators.py Add tests for generalized iterators 2016-08-24 23:30:00 +01:00
test_smart_ptr.cpp Support std::shared_ptr holder type out of the box 2016-10-20 16:19:58 +02:00
test_smart_ptr.py Make unique_ptr's with non-default deleters work 2016-09-04 18:23:55 -04:00
test_stl_binders.cpp minor doc & style fixes 2016-09-06 13:02:29 +09:00
test_stl_binders.py Adding bind_map 2016-09-05 17:11:16 -04:00
test_virtual_functions.cpp Update OVERLOAD macros to support ref/ptr return type overloads 2016-09-11 01:21:53 -04:00
test_virtual_functions.py Update OVERLOAD macros to support ref/ptr return type overloads 2016-09-11 01:21:53 -04:00