diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2012-09-15 11:56:32 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2012-09-15 11:56:32 +0000 |
commit | 98f93adefc22c674cb0973ccb93ba77e3b5a37f4 (patch) | |
tree | 03c46adf52e55e8c5e7a4c200421420ad00a0fb4 /clang/bindings/python/tests/cindex/test_code_completion.py | |
parent | 70b44c5ccfc2bb2a9781d97062206e8671ace282 (diff) | |
download | bcm5719-llvm-98f93adefc22c674cb0973ccb93ba77e3b5a37f4.tar.gz bcm5719-llvm-98f93adefc22c674cb0973ccb93ba77e3b5a37f4.zip |
Add bindings for clang_getCompletionBriefComment to cindex.py.
llvm-svn: 163966
Diffstat (limited to 'clang/bindings/python/tests/cindex/test_code_completion.py')
-rw-r--r-- | clang/bindings/python/tests/cindex/test_code_completion.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/clang/bindings/python/tests/cindex/test_code_completion.py b/clang/bindings/python/tests/cindex/test_code_completion.py new file mode 100644 index 00000000000..b4678bd3851 --- /dev/null +++ b/clang/bindings/python/tests/cindex/test_code_completion.py @@ -0,0 +1,35 @@ +from clang.cindex import TranslationUnit + +def test_code_complete(): + files = [('fake.c', """ +/// Aaa. +int test1; + +/// Bbb. +void test2(void); + +void f() { + +} +""")] + + tu = TranslationUnit.from_source('fake.c', ['-std=c99'], unsaved_files=files, + options=TranslationUnit.PARSE_INCLUDE_BRIEF_COMMENTS_IN_CODE_COMPLETION) + + cr = tu.codeComplete('fake.c', 9, 1, unsaved_files=files, include_brief_comments=True) + assert cr is not None + assert len(cr.diagnostics) == 0 + + completions = [] + for c in cr.results: + completions.append(str(c)) + + expected = [ + "{'int', ResultType} | {'test1', TypedText} || Priority: 50 || Availability: Available || Brief comment: Aaa.", + "{'void', ResultType} | {'test2', TypedText} | {'(', LeftParen} | {')', RightParen} || Priority: 50 || Availability: Available || Brief comment: Bbb.", + "{'return', TypedText} || Priority: 40 || Availability: Available || Brief comment: None" + ] + + for c in expected: + assert c in completions + |