Testcase for C array inplace operators
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Fri, 15 Aug 2008 16:12:37 +0000 (18:12 +0200)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Fri, 15 Aug 2008 16:12:37 +0000 (18:12 +0200)
tests/run/inplace.pyx

index 7c9ba9cec5e929e2e74997561e186453b8578ea2..41528d635a89b9c06027e93b67f2d2f6ea990af6 100644 (file)
@@ -7,6 +7,9 @@ __doc__ = u"""
 
     >>> h(56, 7)
     105.0
+
+    >>> arrays()
+    19
 """
 
 def f(a,b):
@@ -26,3 +29,16 @@ def h(double a, double b):
     a += b
     a *= b
     return a
+
+cimport stdlib
+
+def arrays():
+    cdef char* buf = <char*>stdlib.malloc(10)
+    cdef int i = 2
+    cdef object j = 2
+    buf[2] = 0
+    buf[i] += 2
+    buf[2] *= 10
+    buf[j] -= 1
+    print buf[2]
+    stdlib.free(buf)