summaryrefslogtreecommitdiff
path: root/tests/run/cpp_enums.pyx
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run/cpp_enums.pyx')
-rw-r--r--tests/run/cpp_enums.pyx58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/run/cpp_enums.pyx b/tests/run/cpp_enums.pyx
new file mode 100644
index 000000000..ac5ea9fe7
--- /dev/null
+++ b/tests/run/cpp_enums.pyx
@@ -0,0 +1,58 @@
+# tag: cpp
+# mode: run, no-cpp-locals
+
+cdef extern from *:
+ """
+ enum Enum1 {
+ Item1,
+ Item2
+ };
+
+ """
+ cdef enum Enum1:
+ Item1
+ Item2
+
+a = Item1
+b = Item2
+
+cdef Enum1 x, y
+x = Item1
+y = Item2
+
+
+def compare_enums():
+ """
+ >>> compare_enums()
+ (True, True, True, True)
+ """
+ return x == a, a == Item1, b == y, y == Item2
+
+
+cdef extern from * namespace "Namespace1":
+ """
+ namespace Namespace1 {
+ enum Enum2 {
+ Item3,
+ Item4
+ };
+ }
+ """
+ cdef enum Enum2:
+ Item3
+ Item4
+
+c = Item3
+d = Item4
+
+cdef Enum2 z, w
+z = Item3
+w = Item4
+
+
+def compare_namespace_enums():
+ """
+ >>> compare_namespace_enums()
+ (True, True, True, True)
+ """
+ return z == c, c == Item3, d == w, d == Item4