[pypy-svn] r79884 - in pypy/branch/fast-forward/pypy/objspace/std: . test

agaynor at codespeak.net agaynor at codespeak.net
Wed Dec 8 06:02:58 CET 2010


Author: agaynor
Date: Wed Dec  8 06:02:55 2010
New Revision: 79884

Modified:
   pypy/branch/fast-forward/pypy/objspace/std/complextype.py
   pypy/branch/fast-forward/pypy/objspace/std/test/test_complexobject.py
Log:
Started implementing enhanced complex constructor parsing.


Modified: pypy/branch/fast-forward/pypy/objspace/std/complextype.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/complextype.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/complextype.py	Wed Dec  8 06:02:55 2010
@@ -32,6 +32,10 @@
     # ignore whitespace
     while i < slen and s[i] == ' ':
         i += 1
+    
+    if s[i] == '(' and s[slen-1] == ')':
+        i += 1
+        slen -= 1
 
     # extract first number
     realstart = i

Modified: pypy/branch/fast-forward/pypy/objspace/std/test/test_complexobject.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/test/test_complexobject.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/test/test_complexobject.py	Wed Dec  8 06:02:55 2010
@@ -36,6 +36,9 @@
         test_cparse('3L+3j', '3L', '3')
         test_cparse('3j', '0.0', '3')
         test_cparse('.e+5', '.e+5', '0.0')
+        test_cparse('(1+2j)', '1', '2')
+        test_cparse('(1-6j)', '1', '-6')
+        
 
     def test_pow(self):
         assert cobj._pow((0.0,2.0),(0.0,0.0)) == (1.0,0.0)



More information about the Pypy-commit mailing list