summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-01-07 17:39:18 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2011-01-07 17:54:08 -0200
commit635ae97b304dae295bf15d666c06c6e67660629b (patch)
treeee5690cb9d2b1129586ed99aec83987ae382f586 /tests
parent20f57828674fabc0ef1b5f0fbcea7c8732477979 (diff)
downloadshiboken-635ae97b304dae295bf15d666c06c6e67660629b.tar.gz
shiboken-635ae97b304dae295bf15d666c06c6e67660629b.tar.xz
shiboken-635ae97b304dae295bf15d666c06c6e67660629b.zip
Fix bug#530 - "Importing division from future breaks QPoint division"
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Lauro Moura <lauro.neto@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/libsample/point.cpp6
-rw-r--r--tests/libsample/point.h1
-rw-r--r--tests/samplebinding/newdivision_test.py14
3 files changed, 21 insertions, 0 deletions
diff --git a/tests/libsample/point.cpp b/tests/libsample/point.cpp
index b8d310cf..484e7c11 100644
--- a/tests/libsample/point.cpp
+++ b/tests/libsample/point.cpp
@@ -118,6 +118,12 @@ operator!(const Point& pt)
return (pt.m_x == 0.0 && pt.m_y == 0.0);
}
+Point
+Point::operator/(int operand)
+{
+ return Point(m_x/operand, m_y/operand);
+}
+
Complex
transmutePointIntoComplex(const Point& point)
{
diff --git a/tests/libsample/point.h b/tests/libsample/point.h
index 5c1e19a2..cc7a1bc5 100644
--- a/tests/libsample/point.h
+++ b/tests/libsample/point.h
@@ -54,6 +54,7 @@ public:
Point operator+(const Point& other);
Point operator-(const Point& other);
+ Point operator/(int operand);
friend LIBSAMPLE_API Point operator*(const Point& pt, double mult);
friend LIBSAMPLE_API Point operator*(const Point& pt, int mult);
diff --git a/tests/samplebinding/newdivision_test.py b/tests/samplebinding/newdivision_test.py
new file mode 100644
index 00000000..fbaeeab1
--- /dev/null
+++ b/tests/samplebinding/newdivision_test.py
@@ -0,0 +1,14 @@
+from __future__ import division
+from sample import *
+import unittest
+
+class TestNewDivision(unittest.TestCase):
+
+ def testIt(self):
+ p = Point(4, 4)
+ p2 = p/2
+ self.assertEqual(p2, Point(2, 2))
+
+if __name__ == "__main__":
+ unittest.main()
+