[pypy-svn] r45708 - in pypy/branch/pypy-more-rtti-inprogress/interpreter: . test

arigo at codespeak.net arigo at codespeak.net
Thu Aug 16 13:03:07 CEST 2007


Author: arigo
Date: Thu Aug 16 13:03:06 2007
New Revision: 45708

Modified:
   pypy/branch/pypy-more-rtti-inprogress/interpreter/baseobjspace.py
   pypy/branch/pypy-more-rtti-inprogress/interpreter/test/test_objspace.py
Log:
space.r_longlong_w().


Modified: pypy/branch/pypy-more-rtti-inprogress/interpreter/baseobjspace.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/interpreter/baseobjspace.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/interpreter/baseobjspace.py	Thu Aug 16 13:03:06 2007
@@ -837,6 +837,14 @@
         else:
             return index
 
+    def r_longlong_w(self, w_obj):
+        bigint = self.bigint_w(w_obj)
+        try:
+            return bigint.tolonglong()
+        except OverflowError:
+            raise OperationError(self.w_OverflowError,
+                                 self.wrap('integer too large'))
+
 
 class AppExecCache(SpaceCache):
     def build(cache, source):

Modified: pypy/branch/pypy-more-rtti-inprogress/interpreter/test/test_objspace.py
==============================================================================
--- pypy/branch/pypy-more-rtti-inprogress/interpreter/test/test_objspace.py	(original)
+++ pypy/branch/pypy-more-rtti-inprogress/interpreter/test/test_objspace.py	Thu Aug 16 13:03:06 2007
@@ -2,6 +2,7 @@
 from pypy.interpreter.error import OperationError
 from pypy.interpreter.function import Function
 from pypy.interpreter.pycode import PyCode
+from pypy.rlib.rarithmetic import r_longlong
 import sys
 
 # this test isn't so much to test that the objspace interface *works*
@@ -164,6 +165,16 @@
         else:
             assert 0, "should have raised"
 
+    def test_r_longlong_w(self):
+        w_value = self.space.wrap(12)
+        res = self.space.r_longlong_w(w_value)
+        assert res == 12
+        assert type(res) is r_longlong
+        w_value = self.space.wrap(r_longlong(-sys.maxint * 42))
+        res = self.space.r_longlong_w(w_value)
+        assert res == -sys.maxint * 42
+        assert type(res) is r_longlong
+
 
 class TestModuleMinimal: 
     def test_sys_exists(self):



More information about the Pypy-commit mailing list