summaryrefslogtreecommitdiff
path: root/tests/float/cmath_dunder.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/float/cmath_dunder.py')
-rw-r--r--tests/float/cmath_dunder.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/float/cmath_dunder.py b/tests/float/cmath_dunder.py
new file mode 100644
index 000000000..352634151
--- /dev/null
+++ b/tests/float/cmath_dunder.py
@@ -0,0 +1,21 @@
+# test that cmath functions support user classes with __float__ and __complex__
+
+try:
+ import cmath
+except ImportError:
+ print("SKIP")
+ raise SystemExit
+
+
+class TestFloat:
+ def __float__(self):
+ return 1.0
+
+
+class TestComplex:
+ def __complex__(self):
+ return 1j + 10
+
+
+for clas in TestFloat, TestComplex:
+ print("%.5g" % cmath.phase(clas()))