[pypy-svn] r46214 - in pypy/dist/pypy/translator/jvm: src/pypy test

antocuni at codespeak.net antocuni at codespeak.net
Fri Aug 31 11:43:58 CEST 2007


Author: antocuni
Date: Fri Aug 31 11:43:57 2007
New Revision: 46214

Modified:
   pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java
   pypy/dist/pypy/translator/jvm/test/test_op.py
Log:
implement str_to_ulong and make these tests passing



Modified: pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java
==============================================================================
--- pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java	(original)
+++ pypy/dist/pypy/translator/jvm/src/pypy/PyPy.java	Fri Aug 31 11:43:57 2007
@@ -163,8 +163,15 @@
     }
 
     public static long str_to_ulong(String s) {
-        // oh bother
-        throw new RuntimeException("TODO--- str to ulong");
+        long res = 0;
+        s = s.trim();
+        for(int i=0; i<s.length(); i++) {
+            char ch = s.charAt(i);
+            if (!Character.isDigit(ch))
+                throw new RuntimeException("Invalid ulong: " + s);
+            res = res*10 + Character.getNumericValue(ch);
+        }
+        return res;
     }
 
     public static boolean str_to_bool(String s) {

Modified: pypy/dist/pypy/translator/jvm/test/test_op.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/test/test_op.py	(original)
+++ pypy/dist/pypy/translator/jvm/test/test_op.py	Fri Aug 31 11:43:57 2007
@@ -6,18 +6,6 @@
 
 class TestOperations(JvmTest, BaseTestOperations):
 
-    def test_eq(self):
-        py.test.skip("Str to long is not implemented, needed for test")
-        
-    def test_ne(self):
-        py.test.skip("Str to long is not implemented, needed for test")
-        
-    def test_ge(self):
-        py.test.skip("Str to long is not implemented, needed for test")
-        
-    def test_le(self):
-        py.test.skip("Str to long is not implemented, needed for test")
-        
     def test_and_not(self):
         py.test.skip("VerifyError happens. Accessing uninit reg")
         



More information about the Pypy-commit mailing list