diff --git a/tests/exo_planet_pybind11.cpp b/tests/exo_planet_pybind11.cpp index 9d1a2b84b6..f0a5e23c9f 100644 --- a/tests/exo_planet_pybind11.cpp +++ b/tests/exo_planet_pybind11.cpp @@ -13,6 +13,8 @@ namespace test_cpp_conduit { PYBIND11_MODULE(exo_planet_pybind11, m) { wrap_traveler(m); m.def("wrap_very_lonely_traveler", [m]() { wrap_very_lonely_traveler(m); }); + + py::class_(m, "A", "class A").def(py::init<>()).def_readwrite("value", &A::value); } } // namespace test_cpp_conduit diff --git a/tests/test_cpp_conduit.cpp b/tests/test_cpp_conduit.cpp index 4ee4f06905..9ec2d2762e 100644 --- a/tests/test_cpp_conduit.cpp +++ b/tests/test_cpp_conduit.cpp @@ -16,6 +16,8 @@ TEST_SUBMODULE(cpp_conduit, m) { wrap_traveler(m); wrap_lonely_traveler(m); + + py::class_(m, "B", "class B").def(py::init<>()).def_readonly("a", &B::a); } } // namespace test_cpp_conduit diff --git a/tests/test_cpp_conduit.py b/tests/test_cpp_conduit.py index eb300587fa..dff959fdab 100644 --- a/tests/test_cpp_conduit.py +++ b/tests/test_cpp_conduit.py @@ -164,3 +164,12 @@ def test_exo_planet_pybind11_wrap_very_lonely_traveler(): '"pybind11_tests::test_cpp_conduit::LonelyTraveler"$', ): exo_planet_pybind11.wrap_very_lonely_traveler() + + +def test_return_instance_from_exo_planet(): + b = home_planet.B() + a = b.a + assert a.value == 0.0 + + a.value = 1.0 + assert a.value == 1.0 diff --git a/tests/test_cpp_conduit_traveler_types.h b/tests/test_cpp_conduit_traveler_types.h index b8e6a5a771..55eefd8547 100644 --- a/tests/test_cpp_conduit_traveler_types.h +++ b/tests/test_cpp_conduit_traveler_types.h @@ -21,5 +21,13 @@ struct PremiumTraveler : Traveler { struct LonelyTraveler {}; struct VeryLonelyTraveler : LonelyTraveler {}; +struct A { + double value; +}; + +struct B { + A a{0.0}; +}; + } // namespace test_cpp_conduit } // namespace pybind11_tests