Added a test to detect invalid RTTI caching

The current inheritance testing isn't sufficient to detect a cache
failure; the test added here breaks PR #390, which caches the
run-time-determined return type the first time a function is called,
then reuses that cached type even though the run-time type could be
different for a future call.
This commit is contained in:
Jason Rhinelander
2016-09-11 18:41:28 -04:00
parent f22683806e
commit 0e489777ff
2 changed files with 14 additions and 1 deletions

View File

@@ -77,5 +77,10 @@ test_initializer inheritance([](py::module &m) {
m.def("return_class_1", []() -> BaseClass* { return new DerivedClass1(); });
m.def("return_class_2", []() -> BaseClass* { return new DerivedClass2(); });
m.def("return_class_n", [](int n) -> BaseClass* {
if (n == 1) return new DerivedClass1();
if (n == 2) return new DerivedClass2();
return new BaseClass();
});
m.def("return_none", []() -> BaseClass* { return nullptr; });
});