summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-02-10 10:55:13 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2011-02-10 10:56:15 -0300
commite5fc9e22416603a976873f22f99af365bf5bd928 (patch)
treece5090e65ec59da055d0f9ea18473280e368ba13 /tests
parent3d8672d3f9209b2e099fc610d266a87f70dedcc2 (diff)
downloadshiboken-e5fc9e22416603a976873f22f99af365bf5bd928.tar.gz
shiboken-e5fc9e22416603a976873f22f99af365bf5bd928.tar.xz
shiboken-e5fc9e22416603a976873f22f99af365bf5bd928.zip
Added test for overload decision situation involving inheritance.
Diffstat (limited to 'tests')
-rw-r--r--tests/libsample/objectmodel.h6
-rw-r--r--tests/samplebinding/decisor_test.py11
-rw-r--r--tests/samplebinding/typesystem_sample.xml1
3 files changed, 17 insertions, 1 deletions
diff --git a/tests/libsample/objectmodel.h b/tests/libsample/objectmodel.h
index 8c5dff72..8e350efb 100644
--- a/tests/libsample/objectmodel.h
+++ b/tests/libsample/objectmodel.h
@@ -36,6 +36,12 @@ public:
void setData(ObjectType* data);
virtual ObjectType* data() const;
+ // The MethodCalled enum and related static methods were created to
+ // test bug #630 [http://bugs.openbossa.org/show_bug.cgi?id=630]
+ enum MethodCalled { ObjectTypeCalled, ObjectModelCalled };
+ static MethodCalled receivesObjectTypeFamily(const ObjectType& object) { return ObjectModel::ObjectTypeCalled; }
+ static MethodCalled receivesObjectTypeFamily(const ObjectModel& object) { return ObjectModel::ObjectModelCalled; }
+
private:
// The model holds only one piece of data.
// (This is just a test after all.)
diff --git a/tests/samplebinding/decisor_test.py b/tests/samplebinding/decisor_test.py
index 458298c0..cb442cd9 100644
--- a/tests/samplebinding/decisor_test.py
+++ b/tests/samplebinding/decisor_test.py
@@ -28,7 +28,7 @@
import unittest
-from sample import SampleNamespace, Point
+from sample import SampleNamespace, Point, ObjectType, ObjectModel
class DecisorTest(unittest.TestCase):
'''Test cases for the method overload decisor.'''
@@ -46,6 +46,15 @@ class DecisorTest(unittest.TestCase):
pt = Point()
self.assertRaises(TypeError, SampleNamespace.forceDecisorSideB, 1, pt)
+ def testDecideCallWithInheritance(self):
+ '''Call methods overloads that receive parent and inheritor classes' instances.'''
+ objecttype = ObjectType()
+ objectmodel = ObjectModel()
+ self.assertEqual(ObjectModel.receivesObjectTypeFamily(objecttype), ObjectModel.ObjectTypeCalled)
+ self.assertNotEqual(ObjectModel.receivesObjectTypeFamily(objecttype), ObjectModel.ObjectModelCalled)
+ self.assertEqual(ObjectModel.receivesObjectTypeFamily(objectmodel), ObjectModel.ObjectModelCalled)
+ self.assertNotEqual(ObjectModel.receivesObjectTypeFamily(objectmodel), ObjectModel.ObjectTypeCalled)
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml
index b23e7f6d..b5ffb570 100644
--- a/tests/samplebinding/typesystem_sample.xml
+++ b/tests/samplebinding/typesystem_sample.xml
@@ -259,6 +259,7 @@
</object-type>
<object-type name="ObjectModel">
+ <enum-type name="MethodCalled" />
<modify-function signature="data() const">
<modify-argument index="return">
<define-ownership class="native" owner="c++"/>