aboutsummaryrefslogtreecommitdiffstats
path: root/tests/samplebinding
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2009-12-18 11:43:00 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-12-18 11:57:11 -0300
commit27f6ed14ad776cdc5a9587211709ffcc19b92d8f (patch)
tree90371a45988518ecf781ded334fe78361adf7c4b /tests/samplebinding
parent6a2d25727e23273127a52a303361941f0d22b271 (diff)
New unit test for added function with varargs parameter.
Reviewed by Hugo Lima <hugo.lima@openbossa.org>
Diffstat (limited to 'tests/samplebinding')
-rwxr-xr-xtests/samplebinding/sample_test.py6
-rw-r--r--tests/samplebinding/typesystem_sample.xml6
2 files changed, 12 insertions, 0 deletions
diff --git a/tests/samplebinding/sample_test.py b/tests/samplebinding/sample_test.py
index 35110a0c9..785efaac3 100755
--- a/tests/samplebinding/sample_test.py
+++ b/tests/samplebinding/sample_test.py
@@ -63,6 +63,12 @@ class ModuleTest(unittest.TestCase):
self.assertEqual(sample.multiplyString(str1, 3), str1 * 3)
self.assertEqual(sample.multiplyString(str1, 0), str1 * 0)
+ def testAddedFunctionWithVarargs(self):
+ '''Calls function that receives varargs added to module from type system description.'''
+ self.assertEqual(sample.countVarargs(1), 0)
+ self.assertEqual(sample.countVarargs(1, 2), 1)
+ self.assertEqual(sample.countVarargs(1, 2, 3, 'a', 'b', 4, (5, 6)), 6)
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml
index 9dc3d1798..631f5a9ee 100644
--- a/tests/samplebinding/typesystem_sample.xml
+++ b/tests/samplebinding/typesystem_sample.xml
@@ -828,6 +828,12 @@
</inject-code>
</add-function>
+ <add-function signature="countVarargs(int, ...)" return-type="int">
+ <inject-code class="target" position="beginning">
+ %PYARG_0 = %CONVERTTOPYTHON[int](PyTuple_GET_SIZE(%PYARG_2));
+ </inject-code>
+ </add-function>
+
<rejection class="ListUser" function-name="createList()"/>
<rejection class="ListUser" function-name="callCreateList()"/>
<rejection class="ListUser" function-name="createComplexList(Complex, Complex)"/>