Commit 3074c1a4 authored by Stefan Behnel's avatar Stefan Behnel

additional tests for cascading assignments

parent 1b0c3ae8
# mode: run
# ticket: 466
# extension to T409
def simple_parallel_typed():
......@@ -19,3 +21,49 @@ def simple_parallel_int_mix():
cdef object ao, bo
ai, bi = al, bl = ao, bo = c = d = [1,2]
return ao, bo, ai, bi, al, bl, c, d
cdef int called = 0
cdef char* get_string():
global called
called += 1
return "abcdefg"
def non_simple_rhs():
"""
>>> non_simple_rhs()
1
"""
cdef char *a, *b
cdef int orig_called = called
a = b = <char*>get_string()
assert a is b
return called - orig_called
from libc.stdlib cimport malloc, free
def non_simple_rhs_malloc():
"""
>>> non_simple_rhs_malloc()
"""
cdef char *a, *b, **c
c = &b
c[0] = a = <char*>malloc(2)
a[0] = c'X'
b[1] = c'\0'
# copy from different pointers to make sure they all point to the
# same memory
cdef char[2] x
x[0] = b[0]
x[1] = a[1]
# clean up
free(a)
if b is not a: # shouldn't happen
free(b)
# check copied values
assert x[0] == c'X'
assert x[1] == c'\0'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment