[pypy-svn] r13549 - in pypy/dist/pypy/rpython: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Fri Jun 17 19:46:42 CEST 2005
Author: cfbolz
Date: Fri Jun 17 19:46:41 2005
New Revision: 13549
Modified:
pypy/dist/pypy/rpython/llinterp.py
pypy/dist/pypy/rpython/test/test_llinterp.py
Log:
(cf + hpk)
added tests for list operations
added some assertions
Modified: pypy/dist/pypy/rpython/llinterp.py
==============================================================================
--- pypy/dist/pypy/rpython/llinterp.py (original)
+++ pypy/dist/pypy/rpython/llinterp.py Fri Jun 17 19:46:41 2005
@@ -175,7 +175,7 @@
return malloc(obj)
def op_getfield(self, obj, field):
- # assert: obj should be pointer
+ assert isinstance(obj, _ptr)
result = getattr(obj, field)
# check the difference between op_getfield and op_getsubstruct:
# the former returns the real field, the latter a pointer to it
@@ -183,7 +183,7 @@
return result
def op_getsubstruct(self, obj, field):
- # assert: obj should be pointer
+ assert isinstance(obj, _ptr)
result = getattr(obj, field)
# check the difference between op_getfield and op_getsubstruct:
# the former returns the real field, the latter a pointer to it
@@ -195,12 +195,14 @@
def op_getarraysubstruct(self, array, index):
assert isinstance(array, _ptr)
- return array[index]
+ result = array[index]
+ return result
# the diff between op_getarrayitem and op_getarraysubstruct
# is the same as between op_getfield and op_getsubstruct
- def op_getarraysize(self,array):
+ def op_getarraysize(self, array):
#print array,type(array),dir(array)
+ assert isinstance(typeOf(array).TO, Array)
return len(array)
def op_cast_pointer(self, tp, obj):
Modified: pypy/dist/pypy/rpython/test/test_llinterp.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_llinterp.py (original)
+++ pypy/dist/pypy/rpython/test/test_llinterp.py Fri Jun 17 19:46:41 2005
@@ -136,6 +136,16 @@
assert len(res.items) == len([1,2,3])
for i in range(3):
assert res.items[i] == i+1
+
+def test_list_operations():
+ def f(i):
+ l = [1, i]
+ l[0] = len(l)
+ l += [i + 1, 9]
+# l *= 2
+ return l[0] + l[1] + l[2]# + len(l)
+ res = interpret(f, [3])
+ assert res == 2 + 3 + 4# + 8
#__________________________________________________________________
# example functions for testing the LLInterpreter
_snap = globals().copy()
More information about the Pypy-commit
mailing list