summaryrefslogtreecommitdiffstats
path: root/clang/bindings/python/tests
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-07-06 03:00:34 +0000
committerDouglas Gregor <dgregor@apple.com>2011-07-06 03:00:34 +0000
commita98034a25e3084073f1068568e1d1b95ed243f71 (patch)
tree5bd40fa335f3ae0a9d8a476508778d8edc7c856b /clang/bindings/python/tests
parent75bc773be517dfed9177c7f97724eeb99e8655e3 (diff)
downloadbcm5719-llvm-a98034a25e3084073f1068568e1d1b95ed243f71.tar.gz
bcm5719-llvm-a98034a25e3084073f1068568e1d1b95ed243f71.zip
Improve the Python bindings for libclang in a few ways, from Eli
Bendersky. Specifically: * Implemented a new function in libclang: clang_isAttribute * Fixing TranslationUnit.get_includes to only go through the argument * buffer when it contains something. This fixed a crash on Windows * clang_getFileName returns CXString, not char*. Made appropriate * fixes in cindex.py - now the relevant tests pass and we can see the * full locations correctly again (previously there was garbage in * place of the file name) * Exposed clang_getCursorDisplayName to the python bindings llvm-svn: 134460
Diffstat (limited to 'clang/bindings/python/tests')
-rw-r--r--clang/bindings/python/tests/cindex/test_cursor_kind.py8
-rw-r--r--clang/bindings/python/tests/cindex/test_translation_unit.py15
2 files changed, 15 insertions, 8 deletions
diff --git a/clang/bindings/python/tests/cindex/test_cursor_kind.py b/clang/bindings/python/tests/cindex/test_cursor_kind.py
index bdfa3185583..d7a1cfad8f9 100644
--- a/clang/bindings/python/tests/cindex/test_cursor_kind.py
+++ b/clang/bindings/python/tests/cindex/test_cursor_kind.py
@@ -18,10 +18,14 @@ def test_kind_groups():
for k in CursorKind.get_all_kinds():
group = [n for n in ('is_declaration', 'is_reference', 'is_expression',
- 'is_statement', 'is_invalid')
+ 'is_statement', 'is_invalid', 'is_attribute')
if getattr(k, n)()]
- if k == CursorKind.TRANSLATION_UNIT:
+ if k in ( CursorKind.TRANSLATION_UNIT,
+ CursorKind.MACRO_DEFINITION,
+ CursorKind.MACRO_INSTANTIATION,
+ CursorKind.INCLUSION_DIRECTIVE,
+ CursorKind.PREPROCESSING_DIRECTIVE):
assert len(group) == 0
else:
assert len(group) == 1
diff --git a/clang/bindings/python/tests/cindex/test_translation_unit.py b/clang/bindings/python/tests/cindex/test_translation_unit.py
index f130db6aeb0..2e65d9518da 100644
--- a/clang/bindings/python/tests/cindex/test_translation_unit.py
+++ b/clang/bindings/python/tests/cindex/test_translation_unit.py
@@ -58,24 +58,27 @@ def test_unsaved_files_2():
spellings = [c.spelling for c in tu.cursor.get_children()]
assert spellings[-1] == 'x'
+def normpaths_equal(path1, path2):
+ """ Compares two paths for equality after normalizing them with
+ os.path.normpath
+ """
+ return os.path.normpath(path1) == os.path.normpath(path2)
def test_includes():
def eq(expected, actual):
if not actual.is_input_file:
- return expected[0] == actual.source.name and \
- expected[1] == actual.include.name
+ return normpaths_equal(expected[0], actual.source.name) and \
+ normpaths_equal(expected[1], actual.include.name)
else:
- return expected[1] == actual.include.name
+ return normpaths_equal(expected[1], actual.include.name)
src = os.path.join(kInputsDir, 'include.cpp')
h1 = os.path.join(kInputsDir, "header1.h")
h2 = os.path.join(kInputsDir, "header2.h")
h3 = os.path.join(kInputsDir, "header3.h")
- inc = [(None, src), (src, h1), (h1, h3), (src, h2), (h2, h3)]
+ inc = [(src, h1), (h1, h3), (src, h2), (h2, h3)]
index = Index.create()
tu = index.parse(src)
for i in zip(inc, tu.get_includes()):
assert eq(i[0], i[1])
-
-
OpenPOWER on IntegriCloud