summaryrefslogtreecommitdiffstats
path: root/clang/bindings/python/tests/cindex/test_cursor.py
diff options
context:
space:
mode:
authorAnders Waldenborg <anders@0x63.nu>2012-05-02 20:57:33 +0000
committerAnders Waldenborg <anders@0x63.nu>2012-05-02 20:57:33 +0000
commit94c71052e7b99236c66ac933aa60bbc53c9dfbb0 (patch)
treeeabd265870f80f343120d0bde345f9faab6e62b7 /clang/bindings/python/tests/cindex/test_cursor.py
parentcd997e02b25fbda462817c35d34157bb006a119c (diff)
downloadbcm5719-llvm-94c71052e7b99236c66ac933aa60bbc53c9dfbb0.tar.gz
bcm5719-llvm-94c71052e7b99236c66ac933aa60bbc53c9dfbb0.zip
[python] Add Cursor.enum_value wrapping clang_getEnumConstantDeclValue
llvm-svn: 156017
Diffstat (limited to 'clang/bindings/python/tests/cindex/test_cursor.py')
-rw-r--r--clang/bindings/python/tests/cindex/test_cursor.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/clang/bindings/python/tests/cindex/test_cursor.py b/clang/bindings/python/tests/cindex/test_cursor.py
index 5e8d1dc5dbc..c88aec19a86 100644
--- a/clang/bindings/python/tests/cindex/test_cursor.py
+++ b/clang/bindings/python/tests/cindex/test_cursor.py
@@ -98,3 +98,40 @@ def test_objc_type_encoding():
assert i is not None
assert i.objc_type_encoding == 'i'
+
+def test_enum_values():
+ tu = get_tu('enum TEST { SPAM=1, EGG, HAM = EGG * 20};')
+ enum = get_cursor(tu, 'TEST')
+ assert enum is not None
+
+ assert enum.kind == CursorKind.ENUM_DECL
+
+ enum_constants = list(enum.get_children())
+ assert len(enum_constants) == 3
+
+ spam, egg, ham = enum_constants
+
+ assert spam.kind == CursorKind.ENUM_CONSTANT_DECL
+ assert spam.enum_value == 1
+ assert egg.kind == CursorKind.ENUM_CONSTANT_DECL
+ assert egg.enum_value == 2
+ assert ham.kind == CursorKind.ENUM_CONSTANT_DECL
+ assert ham.enum_value == 40
+
+def test_enum_values_cpp():
+ tu = get_tu('enum TEST : long long { SPAM = -1, HAM = 0x10000000000};', lang="cpp")
+ enum = get_cursor(tu, 'TEST')
+ assert enum is not None
+
+ assert enum.kind == CursorKind.ENUM_DECL
+
+ enum_constants = list(enum.get_children())
+ assert len(enum_constants) == 2
+
+ spam, ham = enum_constants
+
+ assert spam.kind == CursorKind.ENUM_CONSTANT_DECL
+ assert spam.enum_value == -1
+ assert ham.kind == CursorKind.ENUM_CONSTANT_DECL
+ assert ham.enum_value == 0x10000000000
+
OpenPOWER on IntegriCloud