Author: Armin Rigo <[email protected]>
Branch: stm-thread-2
Changeset: r61605:6f3fb622e2f6
Date: 2013-02-22 13:41 +0100
http://bitbucket.org/pypy/pypy/changeset/6f3fb622e2f6/
Log: Test and fix
diff --git a/pypy/module/__pypy__/interp_atomic.py
b/pypy/module/__pypy__/interp_atomic.py
--- a/pypy/module/__pypy__/interp_atomic.py
+++ b/pypy/module/__pypy__/interp_atomic.py
@@ -59,7 +59,8 @@
n = 0
while p[n] != 'e':
n += 1
- return (space.int(space.wrap(rffi.charpsize2str(p, n))),
+ return (space.call_function(space.w_int,
+ space.wrap(rffi.charpsize2str(p, n))),
rffi.ptradd(p, n + 1))
def bdecodelist(space, p):
diff --git a/pypy/module/__pypy__/test/test_atomic.py
b/pypy/module/__pypy__/test/test_atomic.py
--- a/pypy/module/__pypy__/test/test_atomic.py
+++ b/pypy/module/__pypy__/test/test_atomic.py
@@ -4,32 +4,21 @@
from rpython.rtyper.lltypesystem import rffi
-def test_bdecode():
- class FakeSpace:
- def wrap(self, x):
- assert isinstance(x, str)
- return x
- def int(self, x):
- assert isinstance(x, str)
- return int(x)
- def newlist(self, lst):
- assert isinstance(lst, list)
- return lst
+def test_bdecode(space):
- space = FakeSpace()
-
- def bdec(s):
+ def bdec(s, expected):
p = rffi.str2charp(s)
w_obj, q = bdecode(space, p)
assert q == rffi.ptradd(p, len(s))
rffi.free_charp(p)
- return w_obj
+ w_expected = space.wrap(expected)
+ assert space.eq_w(w_obj, w_expected)
- assert bdec("i123e") == 123
- assert bdec("i-123e") == -123
- assert bdec('12:+"*-%&/()=?\x00') == '+"*-%&/()=?\x00'
- assert bdec("li123eli456eee") == [123, [456]]
- assert bdec("l5:abcdei2ee") == ["abcde", 2]
+ bdec("i123e", 123)
+ bdec("i-123e", -123)
+ bdec('12:+"*-%&/()=?\x00', '+"*-%&/()=?\x00')
+ bdec("li123eli456eee", [123, [456]])
+ bdec("l5:abcdei2ee", ["abcde", 2])
class AppTestAtomic(GenericTestThread):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit