Add a test case for the hidden subclass pointe return problem.

This commit is contained in:
Gustavo J. A. M. Carneiro committed 2007-08-18 15:27:37 +01:00
1 parent 885a4090f5
commit bc69e7e825
4 files changed
+24

No files matched your search

+13
View File
@@ -37,3 +37,16 @@ int SomeObject::get_int (double from_float)
{
return (int) from_float;
}
class HiddenClass : public Bar
{
};
Foo*
get_hidden_subclass_pointer ()
{
return new HiddenClass;
}
+2
View File
@@ -49,6 +49,8 @@ public:
virtual ~Bar() {}
};
// caller owns return
Foo* get_hidden_subclass_pointer ();
class Zbr
{
+4
View File
@@ -68,6 +68,10 @@ def my_module_gen(out_file):
Bar.add_method(CppMethod(ReturnValue.new('std::string'), 'Hooray', [], is_static=True))
mod.add_class(Bar)
## to test RTTI with a hidden subclass
mod.add_function(Function(ReturnValue.new('Foo*', caller_owns_return=True),
'get_hidden_subclass_pointer', []))
## Zbr is a reference counted class
Zbr = CppClass('Zbr', incref_method='Ref', decref_method='Unref')
+5
View File
@@ -133,5 +133,10 @@ class TestFoo(unittest.TestCase):
foo2 = obj.get_foo_ptr()
self.assertEqual(type(foo2), foo.Bar)
def test_type_narrowing_hidden_subclass(self):
"""This test only works with GCC >= 3.0 (and not with other compilers)"""
obj = foo.get_hidden_subclass_pointer()
self.assertEqual(type(obj), foo.Bar)
if __name__ == '__main__':
unittest.main()