[pypy-svn] r65020 - pypy/branch/tagged-pointers-framework/pypy/rpython/memory/test
cfbolz at codespeak.net
cfbolz at codespeak.net
Mon May 4 13:58:19 CEST 2009
Author: cfbolz
Date: Mon May 4 13:58:19 2009
New Revision: 65020
Modified:
pypy/branch/tagged-pointers-framework/pypy/rpython/memory/test/test_gc.py
pypy/branch/tagged-pointers-framework/pypy/rpython/memory/test/test_transformed_gc.py
Log:
(failing) tests that I would like to pass
Modified: pypy/branch/tagged-pointers-framework/pypy/rpython/memory/test/test_gc.py
==============================================================================
--- pypy/branch/tagged-pointers-framework/pypy/rpython/memory/test/test_gc.py (original)
+++ pypy/branch/tagged-pointers-framework/pypy/rpython/memory/test/test_gc.py Mon May 4 13:58:19 2009
@@ -10,6 +10,7 @@
from pypy.rpython.lltypesystem.lloperation import llop
from pypy.rlib.objectmodel import we_are_translated
from pypy.rlib.objectmodel import compute_unique_id, keepalive_until_here
+from pypy.rlib import rgc
def stdout_ignore_ll_functions(msg):
@@ -427,7 +428,6 @@
def test_can_move(self):
TP = lltype.GcArray(lltype.Float)
def func():
- from pypy.rlib import rgc
return rgc.can_move(lltype.malloc(TP, 1))
assert self.interpret(func, []) == self.GC_CAN_MOVE
@@ -435,7 +435,6 @@
def test_malloc_nonmovable(self):
TP = lltype.GcArray(lltype.Char)
def func():
- from pypy.rlib import rgc
a = rgc.malloc_nonmovable(TP, 3)
if a:
assert not rgc.can_move(a)
@@ -449,7 +448,6 @@
TP = lltype.GcStruct('T', ('s', lltype.Ptr(S)))
def func():
try:
- from pypy.rlib import rgc
a = rgc.malloc_nonmovable(TP)
rgc.collect()
if a:
@@ -464,7 +462,6 @@
def test_resizable_buffer(self):
from pypy.rpython.lltypesystem.rstr import STR
from pypy.rpython.annlowlevel import hlstr
- from pypy.rlib import rgc
def f():
ptr = rgc.resizable_buffer_of_shape(STR, 1)
@@ -475,6 +472,36 @@
assert self.interpret(f, []) == 2
+ def test_tagged(self):
+ from pypy.rlib.objectmodel import UnboxedValue
+ class A(object):
+ __slots__ = ()
+ def meth(self, x):
+ raise NotImplementedError
+
+ class B(A):
+ attrvalue = 66
+ def __init__(self, normalint):
+ self.normalint = normalint
+ def meth(self, x):
+ return self.normalint + x + 2
+
+ class C(A, UnboxedValue):
+ __slots__ = 'smallint'
+ def meth(self, x):
+ return self.smallint + x + 3
+ def fn(n):
+ if n > 0:
+ x = B(n)
+ else:
+ x = C(n)
+ rgc.collect()
+ return x.meth(100)
+ res = self.interpret(fn, [1000])
+ assert res == 1102
+ res = self.interpret(fn, [-1000])
+ assert res == -897
+
class TestMarkSweepGC(GCTest):
from pypy.rpython.memory.gc.marksweep import MarkSweepGC as GCClass
Modified: pypy/branch/tagged-pointers-framework/pypy/rpython/memory/test/test_transformed_gc.py
==============================================================================
--- pypy/branch/tagged-pointers-framework/pypy/rpython/memory/test/test_transformed_gc.py (original)
+++ pypy/branch/tagged-pointers-framework/pypy/rpython/memory/test/test_transformed_gc.py Mon May 4 13:58:19 2009
@@ -9,6 +9,7 @@
from pypy.rpython.memory.gc.marksweep import X_CLONE, X_POOL, X_POOL_PTR
from pypy.rlib.objectmodel import compute_unique_id
from pypy.rlib.debug import ll_assert
+from pypy.rlib import rgc
from pypy import conftest
from pypy.rlib.rstring import StringBuilder
@@ -455,7 +456,6 @@
def test_can_move(self):
TP = lltype.GcArray(lltype.Float)
def func():
- from pypy.rlib import rgc
return rgc.can_move(lltype.malloc(TP, 1))
run = self.runner(func)
res = run([])
@@ -465,7 +465,6 @@
TP = lltype.GcArray(lltype.Char)
def func():
#try:
- from pypy.rlib import rgc
a = rgc.malloc_nonmovable(TP, 3)
rgc.collect()
if a:
@@ -483,7 +482,6 @@
TP = lltype.GcStruct('T', ('s', lltype.Ptr(S)))
def func():
try:
- from pypy.rlib import rgc
a = rgc.malloc_nonmovable(TP)
rgc.collect()
if a:
@@ -499,7 +497,6 @@
def test_resizable_buffer(self):
from pypy.rpython.lltypesystem.rstr import STR
from pypy.rpython.annlowlevel import hlstr
- from pypy.rlib import rgc
def f():
ptr = rgc.resizable_buffer_of_shape(STR, 2)
@@ -528,6 +525,37 @@
res = fn([])
assert res == 'y'
+ def test_tagged(self):
+ from pypy.rlib.objectmodel import UnboxedValue
+ class A(object):
+ __slots__ = ()
+ def meth(self, x):
+ raise NotImplementedError
+
+ class B(A):
+ attrvalue = 66
+ def __init__(self, normalint):
+ self.normalint = normalint
+ def meth(self, x):
+ return self.normalint + x + 2
+
+ class C(A, UnboxedValue):
+ __slots__ = 'smallint'
+ def meth(self, x):
+ return self.smallint + x + 3
+ def fn(n):
+ if n > 0:
+ x = B(n)
+ else:
+ x = C(n)
+ rgc.collect()
+ return x.meth(100)
+ def func():
+ return fn(1000) + fn(-1000)
+ func = self.runner(func)
+ res = func([])
+ assert res == fn(1000) + fn(-1000)
+
class GenericMovingGCTests(GenericGCTests):
GC_CAN_MOVE = True
GC_CANNOT_MALLOC_NONMOVABLE = True
@@ -638,7 +666,6 @@
assert res == 22220221
def test_cloning_highlevel(self):
- from pypy.rlib import rgc
class A:
pass
class B(A):
@@ -672,7 +699,6 @@
assert res == 1
def test_cloning_highlevel_varsize(self):
- from pypy.rlib import rgc
class A:
pass
def func(n, dummy):
More information about the Pypy-commit
mailing list