aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-04-14 19:49:22 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:15:21 -0300
commite27fed1a8e7c173e0dc08e929671b9f289c3b4f1 (patch)
tree12f3f516966d3f98e0b3afefae801f2d7ec7a3a6
parent660893caca7ebbe96c85ab33f53fc8d99fbabdc0 (diff)
Add tests for adding reverse operators.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Marcelo Lira <marcelo.lira@openbossa.org>
-rw-r--r--tests/samplebinding/point_test.py9
-rw-r--r--tests/samplebinding/typesystem_sample.xml13
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/samplebinding/point_test.py b/tests/samplebinding/point_test.py
index 752302c74..ae7cac0bb 100644
--- a/tests/samplebinding/point_test.py
+++ b/tests/samplebinding/point_test.py
@@ -83,6 +83,15 @@ class PointTest(unittest.TestCase):
self.assertRaises(OverflowError, pt1.setXAsUint, 840835495615213080)
self.assertEqual(pt1.x(), 0.0)
+ def testAddedOperator(self):
+ p = Point(0.0, 0.0)
+ r = p - u'Hi'
+ self.assertEqual(r, u'Hi')
+
+ # now the reverse op.
+ r = u'Hi' - p
+ self.assertEqual(r, u'Hi')
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml
index 56bfcfee3..e1837bbd3 100644
--- a/tests/samplebinding/typesystem_sample.xml
+++ b/tests/samplebinding/typesystem_sample.xml
@@ -1103,6 +1103,19 @@
%PYARG_0 = Py_BuildValue("(OO)", type, args);
</inject-code>
</add-function>
+ <add-function signature="operator-(PyUnicode)">
+ <inject-code>
+ %PYARG_0 = arg;
+ Py_INCREF(arg);
+ </inject-code>
+ </add-function>
+ <!-- A reverse operator -->
+ <add-function signature="operator-(PyUnicode, Point)">
+ <inject-code>
+ %PYARG_0 = arg;
+ Py_INCREF(arg);
+ </inject-code>
+ </add-function>
</value-type>
<value-type name="PointF">