# mode: run
# tag: cpp, cpp11, pthread
# cython: experimental_cpp_class_def=True, language_level=2

cdef cypclass A:
    pass 

def test_consume():
    """
    >>> test_consume()
    0
    """
    a = A()
    old_a = a
    b = consume a
    if a is not NULL:
        return -1
    if b is not old_a:
        return -2
    return 0

cdef cypclass Origin:
    A field
    __init__(self):
        self.field = A()

def test_consume_field():
    o = Origin()
    old_field = o.field
    a = consume o.field
    if o.field is not NULL:
        return -1
    if a is not old_field:
        return -2
    return 0

