Author: Armin Rigo <[email protected]>
Branch: kill-someobject
Changeset: r57950:e890f20e3560
Date: 2012-10-09 16:31 +0200
http://bitbucket.org/pypy/pypy/changeset/e890f20e3560/
Log: Fix test_backendoptimized.
diff --git a/pypy/translator/c/test/test_backendoptimized.py
b/pypy/translator/c/test/test_backendoptimized.py
--- a/pypy/translator/c/test/test_backendoptimized.py
+++ b/pypy/translator/c/test/test_backendoptimized.py
@@ -38,7 +38,7 @@
a = A()
return b.num_deleted
- fn = self.getcompiled(f, [int])
+ fn = self.getcompiled(f, [int], gcpolicy='ref')
res = f(5)
assert res == 5
res = fn(5)
@@ -70,7 +70,7 @@
return s.a_dels * 10 + s.b_dels
else:
return -1
- fn = self.getcompiled(f, [int])
+ fn = self.getcompiled(f, [int], gcpolicy='ref')
res = f(1)
assert res == 42
res = fn(1)
@@ -138,7 +138,7 @@
codegenerator = self.CodeGenerator()
fn = codegenerator.getcompiled(f, [r_uint])
for x in (0,1,2,3,9,27,48):
- assert fn(x) == f(x)
+ assert fn(r_uint(x)) == f(r_uint(x))
def test_longlong_switch(self):
def f(x):
@@ -152,7 +152,7 @@
codegenerator = self.CodeGenerator()
fn = codegenerator.getcompiled(f, [r_longlong])
for x in (0,1,2,3,9,27,48, -9):
- assert fn(x) == f(x)
+ assert fn(r_longlong(x)) == f(r_longlong(x))
def test_ulonglong_switch(self):
def f(x):
@@ -166,7 +166,7 @@
codegenerator = self.CodeGenerator()
fn = codegenerator.getcompiled(f, [r_ulonglong])
for x in (0,1,2,3,9,27,48, r_ulonglong(-9)):
- assert fn(x) == f(x)
+ assert fn(r_ulonglong(x)) == f(r_ulonglong(x))
def test_chr_switch(self):
def f(y):
diff --git a/pypy/translator/c/test/test_genc.py
b/pypy/translator/c/test/test_genc.py
--- a/pypy/translator/c/test/test_genc.py
+++ b/pypy/translator/c/test/test_genc.py
@@ -4,7 +4,8 @@
from pypy.rlib.entrypoint import entrypoint
from pypy.rlib.unroll import unrolling_iterable
-from pypy.rlib.rarithmetic import r_longlong, r_ulonglong, intmask
+from pypy.rlib.rarithmetic import r_longlong, r_ulonglong, r_uint, intmask
+from pypy.rlib.objectmodel import specialize
from pypy.rpython.lltypesystem import lltype
from pypy.rpython.lltypesystem.lltype import *
from pypy.rpython.lltypesystem.rstr import STR
@@ -16,7 +17,7 @@
signed_ffffffff = r_longlong(0xffffffff)
unsigned_ffffffff = r_ulonglong(0xffffffff)
-def llrepr(v):
+def llrepr_in(v):
if isinstance(v, r_ulonglong):
return "%d:%d" % (intmask(v >> 32), intmask(v & unsigned_ffffffff))
elif isinstance(v, r_longlong):
@@ -25,6 +26,13 @@
return repr(v) # extra precision than str(v)
return str(v)
[email protected](0)
+def llrepr_out(v):
+ if isinstance(v, float):
+ from pypy.rlib.rfloat import formatd, DTSF_ADD_DOT_0
+ return formatd(v, 'r', 0, DTSF_ADD_DOT_0)
+ return v
+
def parse_longlong(a):
p0, p1 = a.split(":")
return (r_longlong(int(p0)) << 32) + (r_longlong(int(p1)) &
@@ -40,7 +48,8 @@
argtypes_unroll = unrolling_iterable(enumerate(argtypes))
for argtype in argtypes:
- if argtype not in [int, float, str, bool, r_ulonglong, r_longlong]:
+ if argtype not in [int, float, str, bool, r_ulonglong, r_longlong,
+ r_uint]:
raise Exception("Unsupported argtype, %r" % (argtype,))
def entry_point(argv):
@@ -49,6 +58,8 @@
a = argv[i + 1]
if argtype is int:
args += (int(a),)
+ elif argtype is r_uint:
+ args += (r_uint(int(a)),)
elif argtype is r_longlong:
args += (parse_longlong(a),)
elif argtype is r_ulonglong:
@@ -64,10 +75,7 @@
else:
args += (a,)
res = fn(*args)
- if isinstance(res, float):
- from pypy.rlib.rfloat import formatd, DTSF_ADD_DOT_0
- res = formatd(res, 'r', 0, DTSF_ADD_DOT_0)
- print "THE RESULT IS:", res, ";"
+ print "THE RESULT IS:", llrepr_out(res), ";"
return 0
t = Translation(entry_point, None, gc=gcpolicy, backend="c",
@@ -93,7 +101,7 @@
assert len(args) == len(argtypes)
for arg, argtype in zip(args, argtypes):
assert isinstance(arg, argtype)
- stdout = t.driver.cbuilder.cmdexec(" ".join([llrepr(arg) for arg in
args]))
+ stdout = t.driver.cbuilder.cmdexec(" ".join([llrepr_in(arg) for arg in
args]))
print stdout
stdout, lastline, empty = stdout.rsplit('\n', 2)
assert empty == ''
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit