[pypy-svn] r51821 - in pypy/branch/unified-rtti/pypy: rpython/lltypesystem/test rpython/test translator/c/test
arigo at codespeak.net
arigo at codespeak.net
Sat Feb 23 13:48:12 CET 2008
Author: arigo
Date: Sat Feb 23 13:48:10 2008
New Revision: 51821
Modified:
pypy/branch/unified-rtti/pypy/rpython/lltypesystem/test/test_llarena.py
pypy/branch/unified-rtti/pypy/rpython/test/test_rptr.py
pypy/branch/unified-rtti/pypy/translator/c/test/test_genc.py
Log:
Fix more tests.
Modified: pypy/branch/unified-rtti/pypy/rpython/lltypesystem/test/test_llarena.py
==============================================================================
--- pypy/branch/unified-rtti/pypy/rpython/lltypesystem/test/test_llarena.py (original)
+++ pypy/branch/unified-rtti/pypy/rpython/lltypesystem/test/test_llarena.py Sat Feb 23 13:48:10 2008
@@ -213,9 +213,10 @@
def test_replace_object_with_stub():
from pypy.rpython.memory.gcheader import GCHeaderBuilder
HDR = lltype.Struct('HDR', ('x', lltype.Signed))
+ TYPEINFO = lltype.Struct('TYPEINFO')
S = lltype.GcStruct('S', ('y', lltype.Signed), ('z', lltype.Signed))
STUB = lltype.GcStruct('STUB', ('t', lltype.Char))
- gcheaderbuilder = GCHeaderBuilder(HDR)
+ gcheaderbuilder = GCHeaderBuilder(HDR, TYPEINFO)
size_gc_header = gcheaderbuilder.size_gc_header
a = arena_malloc(50, True)
Modified: pypy/branch/unified-rtti/pypy/rpython/test/test_rptr.py
==============================================================================
--- pypy/branch/unified-rtti/pypy/rpython/test/test_rptr.py (original)
+++ pypy/branch/unified-rtti/pypy/rpython/test/test_rptr.py Sat Feb 23 13:48:10 2008
@@ -36,8 +36,8 @@
assert s.ll_ptrtype == PS2
def test_runtime_type_info():
- S = GcStruct('s', ('x', Signed))
- attachRuntimeTypeInfo(S)
+ rtti = malloc(RuntimeTypeInfo, immortal=True)
+ S = GcStruct('s', ('x', Signed), runtime_type_info=rtti)
def ll_example(p):
return (runtime_type_info(p),
runtime_type_info(p) == getRuntimeTypeInfo(S))
Modified: pypy/branch/unified-rtti/pypy/translator/c/test/test_genc.py
==============================================================================
--- pypy/branch/unified-rtti/pypy/translator/c/test/test_genc.py (original)
+++ pypy/branch/unified-rtti/pypy/translator/c/test/test_genc.py Sat Feb 23 13:48:10 2008
@@ -138,41 +138,18 @@
def test_runtime_type_info():
- S = GcStruct('s', ('is_actually_s1', Bool))
- S1 = GcStruct('s1', ('sub', S))
- attachRuntimeTypeInfo(S)
- attachRuntimeTypeInfo(S1)
- def rtti_S(p):
- if p.is_actually_s1:
- return getRuntimeTypeInfo(S1)
- else:
- return getRuntimeTypeInfo(S)
- def rtti_S1(p):
- return getRuntimeTypeInfo(S1)
+ rtti = malloc(RuntimeTypeInfo, immortal=True)
+ rtti1 = malloc(RuntimeTypeInfo, immortal=True)
+ S = GcStruct('s', runtime_type_info=rtti)
+ S1 = GcStruct('s1', ('sub', S), runtime_type_info=rtti1)
def does_stuff():
p = malloc(S)
- p.is_actually_s1 = False
p1 = malloc(S1)
- p1.sub.is_actually_s1 = True
# and no crash when p and p1 are decref'ed
return None
- t = TranslationContext()
- t.buildannotator().build_types(does_stuff, [])
- rtyper = t.buildrtyper()
- rtyper.attachRuntimeTypeInfoFunc(S, rtti_S)
- rtyper.attachRuntimeTypeInfoFunc(S1, rtti_S1)
- rtyper.specialize()
- #t.view()
- from pypy.translator.c import genc
- t.config.translation.countmallocs = True
- builder = genc.CExtModuleBuilder(t, does_stuff, config=t.config)
- builder.generate_source()
- builder.compile()
- f1 = builder.get_entry_point()
+ f1 = compile(does_stuff, [])
f1()
- mallocs, frees = builder.get_malloc_counters()()
- assert mallocs == frees
def test_str():
More information about the Pypy-commit
mailing list