cython
1# cython: test_assert_c_code_has = Generated by Cython
2# cython: test_assert_c_code_has = goto __pyx_L0;\n
3
4"""
5>>> from codecs import open
6>>> import os.path as os_path
7>>> module_path = os_path.join(os_path.dirname(__file__), os_path.basename(__file__).split('.', 1)[0])
8>>> assert module_path.endswith('annotate_html')
9>>> assert os_path.exists(module_path + '.c') or os_path.exists(module_path + '.cpp'), module_path
10>>> assert os_path.exists(module_path + '.html'), module_path
11
12>>> with open(module_path + '.html', 'r', 'utf8') as html_file:
13... html = html_file.read()
14
15>>> import re
16>>> assert re.search('<pre .*def.* .*mixed_test.*</pre>', html)
17>>> from Cython.Compiler.Annotate import AnnotationCCodeWriter
18>>> assert (AnnotationCCodeWriter.COMPLETE_CODE_TITLE not in html) # per default no complete c code
19"""
20
21
22def mixed_test():
23"""docstring
24"""
25cdef int int1, int2, int3
26cdef char *ptr1, *ptr2 = "test", *ptr3 = "toast"
27int2 = 10
28int3 = 20
29obj1 = 1
30obj2 = 2
31obj3 = 3
32int1 = int2 + int3
33ptr1 = ptr2 + int3
34ptr1 = int2 + ptr3
35obj1 = obj2 + int3
36return int1, obj1
37
38
39def add_x_1(int x):
40return x + 1
41
42
43def add_x_1f(x):
44return x + 1.0
45
46
47def add_x_large(x):
48return x + 2**30
49
50
51def add_1_x(x):
52return 1 + x
53
54
55def add_1f_x(double x):
56return 1.0 + x
57
58
59def add_large_x(x):
60return 2**30 + x
61
62
63class PythonClass(object):
64def call(self, x):
65return add_1_x(x)
66
67
68cdef class ExtensionType(object):
69@classmethod
70def new(cls):
71return cls()
72