[pypy-svn] r36056 - in pypy/dist/pypy/rpython/lltypesystem: . test

arigo at codespeak.net arigo at codespeak.net
Sat Dec 30 11:44:06 CET 2006


Author: arigo
Date: Sat Dec 30 11:44:04 2006
New Revision: 36056

Modified:
   pypy/dist/pypy/rpython/lltypesystem/llmemory.py
   pypy/dist/pypy/rpython/lltypesystem/test/test_llmemory.py
Log:
Fix previous check-in for FixedSizeArray instead of Array.


Modified: pypy/dist/pypy/rpython/lltypesystem/llmemory.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/llmemory.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/llmemory.py	Sat Dec 30 11:44:04 2006
@@ -54,6 +54,9 @@
                                 " of an array")
             A = lltype.typeOf(parent)
             assert isinstance(A, (lltype.Array, lltype.FixedSizeArray))
+            if isinstance(index, str):
+                assert index.startswith("item")
+                index = int(index[4:])     # "itemN" => N
             firstitemref = _arrayitemref(parent._as_ptr(), index)
         assert isinstance(firstitemref, _arrayitemref)
         array = firstitemref.array

Modified: pypy/dist/pypy/rpython/lltypesystem/test/test_llmemory.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/test/test_llmemory.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/test/test_llmemory.py	Sat Dec 30 11:44:04 2006
@@ -95,13 +95,13 @@
 
 def test_structarray_add():
     S = lltype.Struct("S", ("x", lltype.Signed))
-    A = lltype.GcArray(S)
-    a = lltype.malloc(A, 5)
-    a[3].x = 42
-    adr_s = cast_ptr_to_adr(a[0])
-    adr_s += sizeof(S) * 3
-    s = cast_adr_to_ptr(adr_s, lltype.Ptr(S))
-    assert s.x == 42
+    for a in [lltype.malloc(lltype.GcArray(S), 5),
+              lltype.malloc(lltype.FixedSizeArray(S, 5), immortal=True)]:
+        a[3].x = 42
+        adr_s = cast_ptr_to_adr(a[0])
+        adr_s += sizeof(S) * 3
+        s = cast_adr_to_ptr(adr_s, lltype.Ptr(S))
+        assert s.x == 42
 
 def test_cast_adr_to_ptr():
     from pypy.rpython.memory.test.test_llinterpsim import interpret



More information about the Pypy-commit mailing list