summaryrefslogtreecommitdiff
path: root/tests/run/annotate_html.pyx
blob: 765c2e13f042e39d6d75379b11468c1387507121 (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
"""
>>> from codecs import open
>>> import os.path as os_path
>>> module_path = os_path.join(os_path.dirname(__file__), os_path.basename(__file__).split('.', 1)[0])
>>> assert module_path.endswith('annotate_html')
>>> assert os_path.exists(module_path + '.c') or os_path.exists(module_path + '.cpp'), module_path
>>> assert os_path.exists(module_path + '.html'), module_path

>>> with open(module_path + '.html', 'r', 'utf8') as html_file:
...     html = html_file.read()

>>> import re
>>> assert re.search('<pre .*def.* .*mixed_test.*</pre>', html)
"""


def mixed_test():
    """docstring
    """
    cdef int int1, int2, int3
    cdef char *ptr1, *ptr2 = "test", *ptr3 = "toast"
    int2 = 10
    int3 = 20
    obj1 = 1
    obj2 = 2
    obj3 = 3
    int1 = int2 + int3
    ptr1 = ptr2 + int3
    ptr1 = int2 + ptr3
    obj1 = obj2 + int3
    return int1, obj1


def add_x_1(int x):
    return x + 1


def add_x_1f(x):
    return x + 1.0


def add_x_large(x):
    return x + 2**30


def add_1_x(x):
    return 1 + x


def add_1f_x(double x):
    return 1.0 + x


def add_large_x(x):
    return 2**30 + x


class PythonClass(object):
    def call(self, x):
        return add_1_x(x)


cdef class ExtensionType(object):
    @classmethod
    def new(cls):
        return cls()