Author: Armin Rigo <[email protected]>
Branch: kill-someobject
Changeset: r57949:03fee088dd73
Date: 2012-10-09 16:16 +0200
http://bitbucket.org/pypy/pypy/changeset/03fee088dd73/
Log: Fix test_lltyped.
diff --git a/pypy/rpython/tool/rffi_platform.py
b/pypy/rpython/tool/rffi_platform.py
--- a/pypy/rpython/tool/rffi_platform.py
+++ b/pypy/rpython/tool/rffi_platform.py
@@ -328,13 +328,14 @@
allfields = tuple(['c_' + name for name, _ in fields])
padfields = tuple(padfields)
name = self.name
- padding_drop = PaddingDrop(name, allfields, padfields,
- config_result.CConfig._compilation_info_)
+ eci = config_result.CConfig._compilation_info_
+ padding_drop = PaddingDrop(name, allfields, padfields, eci)
hints = {'align': info['align'],
'size': info['size'],
'fieldoffsets': tuple(fieldoffsets),
'padding': padfields,
- 'get_padding_drop': padding_drop}
+ 'get_padding_drop': padding_drop,
+ 'eci': eci}
if name.startswith('struct '):
name = name[7:]
else:
diff --git a/pypy/translator/c/genc.py b/pypy/translator/c/genc.py
--- a/pypy/translator/c/genc.py
+++ b/pypy/translator/c/genc.py
@@ -191,6 +191,11 @@
eci = node.compilation_info()
if eci:
all.append(eci)
+ for node in self.db.getstructdeflist():
+ try:
+ all.append(node.STRUCT._hints['eci'])
+ except (AttributeError, KeyError):
+ pass
self.merge_eci(*all)
def get_gcpolicyclass(self):
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
@@ -64,6 +64,9 @@
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, ";"
return 0
diff --git a/pypy/translator/c/test/test_lltyped.py
b/pypy/translator/c/test/test_lltyped.py
--- a/pypy/translator/c/test/test_lltyped.py
+++ b/pypy/translator/c/test/test_lltyped.py
@@ -1,17 +1,19 @@
import py
from pypy.rpython.lltypesystem.lltype import *
-from pypy.translator.c.test import test_typed
+from pypy.translator.c.test.test_genc import compile
from pypy.tool.sourcetools import func_with_new_name
-class TestLowLevelType(test_typed.CompilationTestCase):
+class TestLowLevelType(object):
+ def getcompiled(self, func, argtypes):
+ return compile(func, argtypes, backendopt=False)
def test_simple(self):
S = GcStruct("s", ('v', Signed))
def llf():
s = malloc(S)
return s.v
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [])
assert fn() == 0
def test_simple2(self):
@@ -22,7 +24,7 @@
s.a.v = 6
s.b.v = 12
return s.a.v + s.b.v
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [])
assert fn() == 18
def test_fixedsizearray(self):
@@ -49,7 +51,7 @@
assert a42[0][0] == -5
assert a42[5][6] == -6
return len(a42)*100 + len(a42[4])
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [])
res = fn()
assert fn() == 607
@@ -62,7 +64,7 @@
tree.root[0].a = tree.root
tree.root[1].a = tree.other
assert tree.root[0].a[0].a[0].a[0].a[0].a[1].a == tree.other
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [])
fn()
def test_prebuilt_array(self):
@@ -78,7 +80,7 @@
for i in range(5):
s += chr(64+a[i])
assert s == "HELLO"
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [])
fn()
def test_call_with_fixedsizearray(self):
@@ -92,7 +94,7 @@
s = malloc(S)
s.a = a
return g(s.a)
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [])
res = fn()
assert res == 123
@@ -218,7 +220,7 @@
s.y += 1
return p1[0] + p2[0] + p3[0] + p4[0]
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [])
res = fn()
assert res == 8765
@@ -484,18 +486,12 @@
x = getmax(cls)
res1 = OP(x, nn)
result = result + (res1,)
- return result
-
- def assert_eq(a, b):
- # for better error messages when it fails
- assert len(a) == len(b)
- for i in range(len(a)):
- assert a[i] == b[i]
+ return str(result)
fn = self.getcompiled(f, [int])
res = fn(1)
print res
- assert_eq(res, (
+ assert eval(res) == (
# int
-sys.maxint, undefined, # add
undefined, sys.maxint-1, # sub
@@ -528,11 +524,11 @@
0, 0, # mod
0, maxlonglong*2, # lshift
0, maxlonglong, # rshift
- ))
+ )
res = fn(5)
print res
- assert_eq(res, (
+ assert eval(res) == (
# int
-sys.maxint+4, undefined, # add
undefined, sys.maxint-5, # sub
@@ -565,7 +561,7 @@
0, (maxlonglong*2+1)%5, # mod
0, maxlonglong*2-30, # lshift
0, maxlonglong>>4, # rshift
- ))
+ )
def test_direct_ptradd_barebone(self):
from pypy.rpython.lltypesystem import rffi
@@ -582,7 +578,7 @@
assert a2[i] == a[i + 2]
free(a, flavor='raw')
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [])
fn()
def test_r_singlefloat(self):
@@ -617,7 +613,7 @@
a[2][5] = 888000
def llf():
return b[3][4] + a[2][5]
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [])
assert fn() == 888999
def test_prebuilt_nolength_array(self):
@@ -633,7 +629,7 @@
for i in range(5):
s += chr(64+a[i])
assert s == "HELLO"
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [])
fn()
def test_prebuilt_nolength_char_array(self):
@@ -654,7 +650,7 @@
s += a[i]
print s
assert s == "85?!" + lastchar
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [])
fn()
def test_prebuilt_raw_arrays(self):
@@ -692,7 +688,7 @@
return i # returns the index of the failing function
i += 1
return -42
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [])
res = fn()
assert res == -42, "failing function: %r" % (records[res],)
@@ -714,7 +710,7 @@
s += a[i]
return 'abcd' == s
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [])
assert fn()
def test_ll2ctypes_array_from_c(self):
@@ -736,7 +732,7 @@
s += a[i]
print s
return s == 'abcd'
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [])
assert fn()
def test_cast_to_void_array(self):
@@ -744,13 +740,13 @@
def llf():
TYPE = Ptr(rffi.CArray(Void))
y = rffi.cast(TYPE, 0)
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [])
fn()
def test_llgroup(self):
from pypy.rpython.lltypesystem.test import test_llgroup
f = test_llgroup.build_test()
- fn = self.getcompiled(f)
+ fn = self.getcompiled(f, [])
res = fn()
assert res == 42
@@ -868,6 +864,7 @@
("l3", Signed)])
S = rffi_platform.configure(CConfig)['STRUCT']
assert 'get_padding_drop' in S._hints
+ assert 'eci' in S._hints
s1 = malloc(S, immortal=True)
s1.c_c1 = rffi.cast(S.c_c1, -12)
s1.c_s1 = rffi.cast(S.c_s1, -7843)
@@ -884,7 +881,6 @@
s = s2
return s.c_l3
#
- self.include_also_eci = eci
fn = self.getcompiled(f, [int])
res = fn(10)
assert res == -98765432
@@ -901,7 +897,7 @@
render_immortal(a2)
a2[0] = 3
return a1[0] + a2[0]
- fn = self.getcompiled(llf)
+ fn = self.getcompiled(llf, [])
assert fn() == 45
def test_rstring_to_float(self):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit