[pypy-svn] r29813 - in pypy/dist/pypy/translator/cli: src test

antocuni at codespeak.net antocuni at codespeak.net
Sat Jul 8 14:19:36 CEST 2006


Author: antocuni
Date: Sat Jul  8 14:19:13 2006
New Revision: 29813

Added:
   pypy/dist/pypy/translator/cli/test/test_int.py   (contents, props changed)
Modified:
   pypy/dist/pypy/translator/cli/src/pypylib.cs
Log:
Added tests for int, and fixed a bug.



Modified: pypy/dist/pypy/translator/cli/src/pypylib.cs
==============================================================================
--- pypy/dist/pypy/translator/cli/src/pypylib.cs	(original)
+++ pypy/dist/pypy/translator/cli/src/pypylib.cs	Sat Jul  8 14:19:13 2006
@@ -55,10 +55,10 @@
 
         public static string OOString(int n, int base_)
         {
-            if (n<0)
+            if (n<0 && base_ != 10)
                 return "-" + Convert.ToString(-n, base_);
             else
-                return  Convert.ToString(n, base_);
+                return Convert.ToString(n, base_);
         }
 
         public static string OOString(double d, int base_)

Added: pypy/dist/pypy/translator/cli/test/test_int.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/translator/cli/test/test_int.py	Sat Jul  8 14:19:13 2006
@@ -0,0 +1,18 @@
+import py
+from pypy.translator.cli.test.runtest import CliTest
+from pypy.rpython.test.test_rint import BaseTestRint
+
+class TestCliInt(CliTest, BaseTestRint):
+    def test_char_constant(self):
+        def dummyfn(i):
+            return chr(i)
+        res = self.interpret(dummyfn, [ord(' ')])
+        assert res == ' '
+        # remove the following test, it's not supported by CLI
+##        res = self.interpret(dummyfn, [0])
+##        assert res == '\0'
+        res = self.interpret(dummyfn, [ord('a')])
+        assert res == 'a'
+
+    def test_rarithmetic(self):
+        pass # it doesn't make sense here



More information about the Pypy-commit mailing list