summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_descr.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-09-12 19:12:49 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-09-12 19:12:49 (GMT)
commit2400fa4ad115e8ebe75c61c3bb96bd7cf2364dd4 (patch)
treeb7b324cfd94a932ccfb9d533ce1df33c57413e3d /Lib/test/test_descr.py
parent1140cb2b9e74ce302c35e84ac04adc0b11e2db00 (diff)
downloadcpython-2400fa4ad115e8ebe75c61c3bb96bd7cf2364dd4.zip
cpython-2400fa4ad115e8ebe75c61c3bb96bd7cf2364dd4.tar.gz
cpython-2400fa4ad115e8ebe75c61c3bb96bd7cf2364dd4.tar.bz2
Again perhaps the end of [#460020] bug or feature: unicode() and subclasses.
Inhibited complex unary plus optimization when applied to a complex subtype. Added PyComplex_CheckExact macro. Some comments and minor code fiddling.
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r--Lib/test/test_descr.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index b029979..f8b7fc7 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1430,6 +1430,30 @@ def inherits():
verify(hash(a) == hash(12345.0))
verify((+a).__class__ is float)
+ class madcomplex(complex):
+ def __repr__(self):
+ return "%.17gj%+.17g" % (self.imag, self.real)
+ a = madcomplex(-3, 4)
+ verify(repr(a) == "4j-3")
+ base = complex(-3, 4)
+ verify(base.__class__ is complex)
+ verify(complex(a) == base)
+ verify(complex(a).__class__ is complex)
+ a = madcomplex(a) # just trying another form of the constructor
+ verify(repr(a) == "4j-3")
+ verify(complex(a) == base)
+ verify(complex(a).__class__ is complex)
+ verify(hash(a) == hash(base))
+ verify((+a).__class__ is complex)
+ verify((a + 0).__class__ is complex)
+ verify(a + 0 == base)
+ verify((a - 0).__class__ is complex)
+ verify(a - 0 == base)
+ verify((a * 1).__class__ is complex)
+ verify(a * 1 == base)
+ verify((a / 1).__class__ is complex)
+ verify(a / 1 == base)
+
class madtuple(tuple):
_rev = None
def rev(self):