diff options
author | Manuel Klimek <klimek@google.com> | 2012-05-07 05:56:03 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2012-05-07 05:56:03 +0000 |
commit | 297e9c30911cd50b6f378773fc70f5848c593ee9 (patch) | |
tree | 40bc36f1a868fd4c6f305494ab82850081dd7943 /clang/bindings/python/tests/cindex/test_cursor.py | |
parent | 470578a91b40a4391170a0bbd1ba3f8303386675 (diff) | |
download | bcm5719-llvm-297e9c30911cd50b6f378773fc70f5848c593ee9.tar.gz bcm5719-llvm-297e9c30911cd50b6f378773fc70f5848c593ee9.zip |
- Adding lexical_parent and semantic_parent properties to clang.cindex.Cursor
- Two new tests (one for each property), require libclang built from r155858 or later to pass
- New test utility function (get_cursors) that gets all the nodes with a specific spelling.
Patch by Evan Pipho.
llvm-svn: 156286
Diffstat (limited to 'clang/bindings/python/tests/cindex/test_cursor.py')
-rw-r--r-- | clang/bindings/python/tests/cindex/test_cursor.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/bindings/python/tests/cindex/test_cursor.py b/clang/bindings/python/tests/cindex/test_cursor.py index 0582d2af63f..8b12f8d94e9 100644 --- a/clang/bindings/python/tests/cindex/test_cursor.py +++ b/clang/bindings/python/tests/cindex/test_cursor.py @@ -1,6 +1,7 @@ from clang.cindex import CursorKind from clang.cindex import TypeKind from .util import get_cursor +from .util import get_cursors from .util import get_tu kInput = """\ @@ -75,6 +76,30 @@ def test_underlying_type(): underlying = typedef.underlying_typedef_type assert underlying.kind == TypeKind.INT +kParentTest = """\ + class C { + void f(); + } + + void C::f() { } + """ +def test_semantic_parent(): + tu = get_tu(kParentTest, 'cpp') + curs = get_cursors(tu, 'f') + decl = get_cursor(tu, 'C') + assert(len(curs) == 2) + assert(curs[0].semantic_parent == curs[1].semantic_parent) + assert(curs[0].semantic_parent == decl) + +def test_lexical_parent(): + tu = get_tu(kParentTest, 'cpp') + curs = get_cursors(tu, 'f') + decl = get_cursor(tu, 'C') + assert(len(curs) == 2) + assert(curs[0].lexical_parent != curs[1].lexical_parent) + assert(curs[0].lexical_parent == decl) + assert(curs[1].lexical_parent == tu.cursor) + def test_enum_type(): tu = get_tu('enum TEST { FOO=1, BAR=2 };') enum = get_cursor(tu, 'TEST') |