mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-24 22:25:10 +00:00
perhaps should not touch newly created tuple as object
This commit is contained in:
parent
bf238d91ed
commit
c19ac6a55c
@ -138,12 +138,14 @@ TEST_SUBMODULE(pytypes, m) {
|
|||||||
m.def("tuple_ssize_t", []() { return py::tuple{(py::ssize_t) 0}; });
|
m.def("tuple_ssize_t", []() { return py::tuple{(py::ssize_t) 0}; });
|
||||||
m.def("tuple_size_t", []() { return py::tuple{(py::size_t) 0}; });
|
m.def("tuple_size_t", []() { return py::tuple{(py::size_t) 0}; });
|
||||||
m.def("get_tuple", []() { return py::make_tuple(42, py::none(), "spam"); });
|
m.def("get_tuple", []() { return py::make_tuple(42, py::none(), "spam"); });
|
||||||
m.def("access_tuple_with_int_index", []() {
|
|
||||||
py::object tpl = py::make_tuple(1, 2);
|
m.def("access_tuple", [](py::tuple &tpl) {
|
||||||
return tpl[1];
|
return tpl[1];
|
||||||
});
|
});
|
||||||
m.def("access_tuple_with_int_index_multidimension", []() {
|
m.def("access_tuple_as_object_with_int_index", [](py::object &tpl) {
|
||||||
py::object tpl = py::make_tuple(py::make_tuple(1, 2, 3), py::make_tuple(3, 4, 5));
|
return tpl[1];
|
||||||
|
});
|
||||||
|
m.def("access_tuple_as_object_with_int_index_multidimension", [](py::object &tpl) {
|
||||||
return tpl[1][2];
|
return tpl[1][2];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -155,8 +155,9 @@ def test_tuple():
|
|||||||
assert m.tuple_ssize_t() == ()
|
assert m.tuple_ssize_t() == ()
|
||||||
assert m.tuple_size_t() == ()
|
assert m.tuple_size_t() == ()
|
||||||
assert m.get_tuple() == (42, None, "spam")
|
assert m.get_tuple() == (42, None, "spam")
|
||||||
assert m.access_tuple_with_int_index() == 2
|
assert m.access_tuple((1,2)) == 2
|
||||||
assert m.access_tuple_with_int_index_multidimension() == 5
|
assert m.access_tuple_as_object_with_int_index((1,2)) == 2
|
||||||
|
assert m.access_tuple_as_object_with_int_index_multidimension(((1,2,3),(4,5,6))) == 6
|
||||||
|
|
||||||
|
|
||||||
def test_simple_namespace():
|
def test_simple_namespace():
|
||||||
|
Loading…
Reference in New Issue
Block a user