[pypy-svn] r17068 - in pypy/dist/pypy: . objspace objspace/test

arigo at codespeak.net arigo at codespeak.net
Mon Aug 29 21:02:33 CEST 2005


Author: arigo
Date: Mon Aug 29 21:02:32 2005
New Revision: 17068

Modified:
   pypy/dist/pypy/conftest.py
   pypy/dist/pypy/objspace/test/test_thunkobjspace.py
   pypy/dist/pypy/objspace/thunk.py
Log:
- conftest fix for testing the thunk objspace (the previous version didn't
  put the 'raises' in the space)

- some fix in the thunk, more things marked "XXX in-progress"

(It's getting late)



Modified: pypy/dist/pypy/conftest.py
==============================================================================
--- pypy/dist/pypy/conftest.py	(original)
+++ pypy/dist/pypy/conftest.py	Mon Aug 29 21:02:32 2005
@@ -46,7 +46,8 @@
         return _spacecache[name]
     except KeyError:
         assert name in ('std', 'thunk'), name 
-        from pypy.objspace.std import Space 
+        mod = __import__('pypy.objspace.%s' % name, None, None, ['Space'])
+        Space = mod.Space
         try: 
             space = Space(uselibfile=option.uselibfile, 
                           nofaking=option.nofaking, 

Modified: pypy/dist/pypy/objspace/test/test_thunkobjspace.py
==============================================================================
--- pypy/dist/pypy/objspace/test/test_thunkobjspace.py	(original)
+++ pypy/dist/pypy/objspace/test/test_thunkobjspace.py	Mon Aug 29 21:02:32 2005
@@ -1,9 +1,9 @@
-from pypy.objspace import thunk 
+from pypy.conftest import gettestobjspace
 
 class AppTest_Thunk:
 
     def setup_class(cls):
-        cls.space = thunk.Space()
+        cls.space = gettestobjspace('thunk')
 
     def test_simple(self):
         computed = []
@@ -58,3 +58,15 @@
         become(x, y)
         become(y, z)
         assert x is y is z
+
+    def test_thunk_forcing_while_forcing(self):
+        def f():
+            return x+1
+        x = thunk(f)
+        raises(RuntimeError, 'x+1')
+
+    def INPROGRESS_test_thunk_forcing_while_forcing_2(self):
+        def f():
+            return x
+        x = thunk(f)
+        raises(RuntimeError, 'x+1')

Modified: pypy/dist/pypy/objspace/thunk.py
==============================================================================
--- pypy/dist/pypy/objspace/thunk.py	(original)
+++ pypy/dist/pypy/objspace/thunk.py	Mon Aug 29 21:02:32 2005
@@ -44,10 +44,11 @@
             args       = w_self.args
             if w_callable is None or args is None:
                 raise OperationError(space.w_RuntimeError,
-                                     "thunk is already being computed")
+                                 space.wrap("thunk is already being computed"))
             w_self.w_callable = None
             w_self.args       = None
             w_alias = space.call_args(w_callable, args)
+            # XXX detect circular w_alias result
             w_self.w_thunkalias = w_alias
         w_self = w_alias
         w_alias = w_self.w_thunkalias



More information about the Pypy-commit mailing list