Skip to content

Commit 10a1c96

Browse files
committed
Add a failure test for overloaded functions
1 parent 4f0727f commit 10a1c96

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

tests/test_callbacks.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ TEST_SUBMODULE(callbacks, m) {
9797
// test_cpp_function_roundtrip
9898
/* Test if passing a function pointer from C++ -> Python -> C++ yields the original pointer */
9999
m.def("dummy_function", &dummy_function);
100+
m.def("dummy_function_overloaded", [](int i, int j) { return i + j; });
101+
m.def("dummy_function_overloaded", &dummy_function);
100102
m.def("dummy_function2", [](int i, int j) { return i + j; });
101103
m.def("roundtrip", [](std::function<int(int)> f, bool expect_none = false) {
102104
if (expect_none && f)

tests/test_callbacks.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ def test_cpp_function_roundtrip():
9393
m.test_dummy_function(m.roundtrip(m.dummy_function))
9494
== "matches dummy_function: eval(1) = 2"
9595
)
96+
assert (
97+
m.test_dummy_function(m.dummy_function_overloaded)
98+
== "matches dummy_function: eval(1) = 2"
99+
)
96100
assert m.roundtrip(None, expect_none=True) is None
97101
assert (
98102
m.test_dummy_function(lambda x: x + 2)

0 commit comments

Comments
 (0)