Author: Armin Rigo <[email protected]>
Branch:
Changeset: r50259:1a471ba2aa1d
Date: 2011-12-07 14:36 +0100
http://bitbucket.org/pypy/pypy/changeset/1a471ba2aa1d/
Log: Progress.
diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py
--- a/pypy/objspace/fake/objspace.py
+++ b/pypy/objspace/fake/objspace.py
@@ -7,6 +7,7 @@
from pypy.tool.sourcetools import compile2, func_with_new_name
from pypy.rlib.unroll import unrolling_iterable
from pypy.rlib.objectmodel import we_are_translated
+from pypy.rlib.nonconst import NonConstant
def is_root(w_obj):
@@ -40,9 +41,9 @@
self.seen_wrap = []
ObjSpace.__init__(self)
- w_None = W_Root()
- w_False = W_Root()
- w_True = W_Root()
+ def is_true(self, w_obj):
+ is_root(w_obj)
+ return NonConstant(False)
def newdict(self, module=False, instance=False, classofinstance=None,
strdict=False):
@@ -76,6 +77,11 @@
def setup():
+ for name in (ObjSpace.ConstantTable +
+ ObjSpace.ExceptionTable +
+ ['int', 'str', 'float', 'long', 'tuple', 'list', 'dict']):
+ setattr(FakeObjSpace, 'w_' + name, W_Root())
+ #
for (name, _, arity, _) in ObjSpace.MethodTable:
args = ['w_%d' % i for i in range(arity)]
d = {'is_root': is_root,
diff --git a/pypy/objspace/fake/test/test_objspace.py
b/pypy/objspace/fake/test/test_objspace.py
--- a/pypy/objspace/fake/test/test_objspace.py
+++ b/pypy/objspace/fake/test/test_objspace.py
@@ -1,3 +1,4 @@
+import py
from pypy.objspace.fake.objspace import FakeObjSpace, W_Root
from pypy.interpreter.argument import Arguments
from pypy.rlib.unroll import unrolling_iterable
@@ -36,7 +37,9 @@
def test_constants(self):
space = self.space
- space.translates(lambda: (space.w_None, space.w_True, space.w_False))
+ space.translates(lambda: (space.w_None, space.w_True, space.w_False,
+ space.w_int, space.w_str,
+ space.w_TypeError))
def test_wrap(self):
space = self.space
@@ -51,3 +54,9 @@
def test_gettypefor(self):
space = self.space
space.translates(lambda: space.gettypefor(W_Root))
+
+ def test_is_true(self):
+ space = self.space
+ space.translates(lambda: space.is_true(W_Root()))
+ py.test.raises(AssertionError,
+ space.translates, lambda: space.is_true(42))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit