aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests/samplebinding/stdcomplex_test.py
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-09-01 08:41:36 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-09-05 11:17:14 +0200
commit45e39b3e69e370967be11a25d989e00d3bd54880 (patch)
treefadcb1facd4e9e5b7376f4ad75c9155986fe45e7 /sources/shiboken6/tests/samplebinding/stdcomplex_test.py
parenteceacdd605a10d282a9c3161430eeeaa6ef1b28f (diff)
shiboken6: Add __int__, __float__
[ChangeLog][shiboken6] operator int() and/or operator double() on classes are now used to provide the __int__ and/or __float__ special functions enabling the use of int() and float() for numerical types. Fixes: PYSIDE-2446 Change-Id: Iabb6392b5754d6e31d44209cfdd27d38c5055b2c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken6/tests/samplebinding/stdcomplex_test.py')
-rw-r--r--sources/shiboken6/tests/samplebinding/stdcomplex_test.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/sources/shiboken6/tests/samplebinding/stdcomplex_test.py b/sources/shiboken6/tests/samplebinding/stdcomplex_test.py
index 539463508..0caa9764d 100644
--- a/sources/shiboken6/tests/samplebinding/stdcomplex_test.py
+++ b/sources/shiboken6/tests/samplebinding/stdcomplex_test.py
@@ -25,6 +25,11 @@ class StdComplexTest(unittest.TestCase):
'''Test case for StdComplex class, exercising esoteric number
protocols (Py_nb_). For standard number protocols, see Point.'''
+ def testConversion(self):
+ pt = StdComplex(REAL, IMAG)
+ self.assertEqual(int(pt), int(round(pt.abs_value())))
+ self.assertEqual(float(pt), pt.abs_value())
+
def testAbs(self):
pt = StdComplex(REAL, IMAG)
self.assertEqual(abs(pt), pt.abs_value())