Debian Codegraph @

tests/run/cpdef_scoped_enums_import.srctree

raw
1 # mode: run
2 # tag: cpp, cpp11
3
4 """
5 PYTHON setup.py build_ext --inplace
6 PYTHON -c "import runner"
7 """
8
9 ######## setup.py ########
10
11 from Cython.Build.Dependencies import cythonize
12 from distutils.core import setup
13 setup(ext_modules=cythonize("*.pyx", language='c++'))
14
15 setup(
16 ext_modules = cythonize([
17 "cheese.pyx",
18 "import_scoped_enum_test.pyx",
19 "dotted_import_scoped_enum_test.pyx"
20 ])
21 )
22
23 ######## cheese.pxd ########
24 # distutils: language = c++
25 # distutils: extra_compile_args = -std=c++11
26
27
28 cdef extern from * namespace "Namespace":
29 """
30 namespace Namespace {
31 enum class Cheese {
32 cheddar = 1,
33 camembert = 2
34 };
35 }
36 """
37 cpdef enum class Cheese:
38 cheddar
39 camembert
40
41 ######## cheese.pyx ########
42 # distutils: language = c++
43 # distutils: extra_compile_args = -std=c++11
44
45 pass
46
47 ######## import_scoped_enum_test.pyx ########
48 # distutils: language = c++
49 # distutils: extra_compile_args = -std=c++11
50
51 from cheese import Cheese
52 from cheese cimport Cheese
53
54 cdef Cheese c = Cheese.cheddar
55 assert list(Cheese) == [1, 2]
56
57 ######## dotted_import_scoped_enum_test.pyx ########
58 # distutils: language = c++
59 # distutils: extra_compile_args = -std=c++11
60
61
62 cimport cheese
63
64 cdef cheese.Cheese c = cheese.Cheese.cheddar
65 assert [cheese.Cheese.cheddar, cheese.Cheese.camembert] == [1, 2]
66 cdef cheese.Cheese d = int(1)
67
68 ######## runner.py ########
69
70 import import_scoped_enum_test
71 import dotted_import_scoped_enum_test