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