summaryrefslogtreecommitdiff
path: root/tests/run/final_method_T586.pyx
blob: 8fa1ba25cce8f6feb51ec5eb709dec92d603f307 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# mode: run
# ticket: 568

cimport cython

@cython.final
cdef class FinalType(object):
    """
    >>> obj = FinalType()
    >>> obj.test_cdef()
    >>> obj.test_cpdef()
    """

    @cython.test_assert_path_exists("//CFuncDefNode[@entry.is_final_cmethod=True]")
    cdef cdef_method(self):
        pass

    @cython.test_assert_path_exists("//CFuncDefNode[@entry.is_final_cmethod=True]")
    @cython.test_fail_if_path_exists("//CFuncDefNode//OverrideCheckNode")
    cpdef cpdef_method(self):
        pass

    @cython.test_assert_path_exists("//AttributeNode[@entry.is_final_cmethod=True]")
    def test_cdef(self):
        self.cdef_method()

    @cython.test_assert_path_exists("//AttributeNode[@entry.is_final_cmethod=True]")
    def test_cpdef(self):
        self.cpdef_method()


def test_external_call():
    """
    >>> test_external_call()
    """
    f = FinalType()
    return f.cpdef_method()

def test_external_call_in_temp():
    """
    >>> test_external_call_in_temp()
    """
    return FinalType().cpdef_method()


cdef class BaseTypeWithFinalMethods(object):
    """
    >>> obj = BaseTypeWithFinalMethods()
    >>> obj.test_cdef()
    """

    @cython.test_assert_path_exists("//CFuncDefNode[@entry.is_final_cmethod=True]")
    @cython.final
    cdef cdef_method(self):
        pass

    @cython.test_assert_path_exists("//AttributeNode[@entry.is_final_cmethod=True]")
    def test_cdef(self):
        self.cdef_method()


cdef class SubType(BaseTypeWithFinalMethods):
    """
    >>> obj = SubType()
    >>> obj.test_cdef()
    """
    @cython.test_assert_path_exists("//AttributeNode[@entry.is_final_cmethod=True]")
    def test_cdef(self):
        self.cdef_method()