[pypy-svn] r28214 - pypy/dist/pypy/objspace/std/test

ale at codespeak.net ale at codespeak.net
Sun Jun 4 11:08:16 CEST 2006


Author: ale
Date: Sun Jun  4 11:08:15 2006
New Revision: 28214

Modified:
   pypy/dist/pypy/objspace/std/test/test_complexobject.py
Log:
Added test for subclasses of complex

Modified: pypy/dist/pypy/objspace/std/test/test_complexobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/test/test_complexobject.py	(original)
+++ pypy/dist/pypy/objspace/std/test/test_complexobject.py	Sun Jun  4 11:08:15 2006
@@ -296,6 +296,19 @@
         for num in nums:
             h.assertAlmostEqual((num.real**2 + num.imag**2)  ** 0.5, abs(num))
 
+    def test_complex_subclass_ctr(self):
+        import sys
+        class j(complex):
+            pass
+        assert j(100 + 0j) == 100 + 0j
+        assert isinstance(j(100),j)
+        assert j(100L + 0j) == 100 + 0j
+        assert j("100 + 0j") == 100 + 0j
+        x = j(1+0j)
+        x.foo = 42
+        assert x.foo == 42
+        assert type(complex(x)) == complex
+                
     def test_repr(self):
         h = self.helper
         h.assertEqual(repr(1+6j), '(1+6j)')



More information about the Pypy-commit mailing list