diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-01-24 21:20:39 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-01-24 21:20:39 +0000 |
commit | a6a6499a904441fc9e82ba9dd4155b8bc33f38f9 (patch) | |
tree | ddbb87227d5f95684ffe8226ca3737b61df4ee21 /bindings/python/tests | |
parent | 12bf15c48a007bc6cc36f3d2e8a0d2e67ccf9886 (diff) |
cindex/Python: Move Cursor.is_ methods to CursorKind, and add test.
Also, add CursorKind.get_all_kinds().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94389 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings/python/tests')
-rw-r--r-- | bindings/python/tests/cindex/test_cursor_kind.py | 27 | ||||
-rw-r--r-- | bindings/python/tests/cindex/test_translation_unit.py | 2 |
2 files changed, 28 insertions, 1 deletions
diff --git a/bindings/python/tests/cindex/test_cursor_kind.py b/bindings/python/tests/cindex/test_cursor_kind.py new file mode 100644 index 0000000000..bdfa318558 --- /dev/null +++ b/bindings/python/tests/cindex/test_cursor_kind.py @@ -0,0 +1,27 @@ +from clang.cindex import CursorKind + +def test_name(): + assert CursorKind.UNEXPOSED_DECL.name is 'UNEXPOSED_DECL' + +def test_get_all_kinds(): + assert CursorKind.UNEXPOSED_DECL in CursorKind.get_all_kinds() + assert CursorKind.TRANSLATION_UNIT in CursorKind.get_all_kinds() + +def test_kind_groups(): + """Check that every kind classifies to exactly one group.""" + + assert CursorKind.UNEXPOSED_DECL.is_declaration() + assert CursorKind.TYPE_REF.is_reference() + assert CursorKind.DECL_REF_EXPR.is_expression() + assert CursorKind.UNEXPOSED_STMT.is_statement() + assert CursorKind.INVALID_FILE.is_invalid() + + for k in CursorKind.get_all_kinds(): + group = [n for n in ('is_declaration', 'is_reference', 'is_expression', + 'is_statement', 'is_invalid') + if getattr(k, n)()] + + if k == CursorKind.TRANSLATION_UNIT: + assert len(group) == 0 + else: + assert len(group) == 1 diff --git a/bindings/python/tests/cindex/test_translation_unit.py b/bindings/python/tests/cindex/test_translation_unit.py index 510119135b..e0b16f5345 100644 --- a/bindings/python/tests/cindex/test_translation_unit.py +++ b/bindings/python/tests/cindex/test_translation_unit.py @@ -15,4 +15,4 @@ def test_cursor(): tu = index.parse(path) c = tu.cursor assert isinstance(c, Cursor) - assert c.is_translation_unit + assert c.kind is CursorKind.TRANSLATION_UNIT |