diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2011-01-07 17:39:18 -0200 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:12:52 -0300 |
commit | 57c3abba8b09fdb3f9fc2ddccaf5efce3edace31 (patch) | |
tree | 77f7b31c408cd103b46eb10bb87ac1a49b58e82c /tests | |
parent | 9d16874b68af3b77d97613e579c83ac19590293f (diff) |
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.cpp | 6 | ||||
-rw-r--r-- | tests/libsample/point.h | 1 | ||||
-rw-r--r-- | tests/samplebinding/newdivision_test.py | 14 |
3 files changed, 21 insertions, 0 deletions
diff --git a/tests/libsample/point.cpp b/tests/libsample/point.cpp index b8d310cfe..484e7c11c 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 5c1e19a25..cc7a1bc5a 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 000000000..fbaeeab1b --- /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() + |