summaryrefslogtreecommitdiffstats
path: root/bindings/python/tests/cindex
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2013-04-08 18:45:10 +0000
committerdim <dim@FreeBSD.org>2013-04-08 18:45:10 +0000
commitc72c57c9e9b69944e3e009cd5e209634839581d3 (patch)
tree4fc2f184c499d106f29a386c452b49e5197bf63d /bindings/python/tests/cindex
parent5b20025c30d23d521e12c1f33ec8fa6b821952cd (diff)
downloadFreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.zip
FreeBSD-src-c72c57c9e9b69944e3e009cd5e209634839581d3.tar.gz
Vendor import of clang trunk r178860:
http://llvm.org/svn/llvm-project/cfe/trunk@178860
Diffstat (limited to 'bindings/python/tests/cindex')
-rw-r--r--bindings/python/tests/cindex/test_cursor.py9
-rw-r--r--bindings/python/tests/cindex/test_translation_unit.py17
2 files changed, 26 insertions, 0 deletions
diff --git a/bindings/python/tests/cindex/test_cursor.py b/bindings/python/tests/cindex/test_cursor.py
index edb209b..a27525c 100644
--- a/bindings/python/tests/cindex/test_cursor.py
+++ b/bindings/python/tests/cindex/test_cursor.py
@@ -250,3 +250,12 @@ def test_get_arguments():
assert len(arguments) == 2
assert arguments[0].spelling == "i"
assert arguments[1].spelling == "j"
+
+def test_referenced():
+ tu = get_tu('void foo(); void bar() { foo(); }')
+ foo = get_cursor(tu, 'foo')
+ bar = get_cursor(tu, 'bar')
+ for c in bar.get_children():
+ if c.kind == CursorKind.CALL_EXPR:
+ assert c.referenced.spelling == foo.spelling
+ break
diff --git a/bindings/python/tests/cindex/test_translation_unit.py b/bindings/python/tests/cindex/test_translation_unit.py
index c91f126..f77998e 100644
--- a/bindings/python/tests/cindex/test_translation_unit.py
+++ b/bindings/python/tests/cindex/test_translation_unit.py
@@ -8,6 +8,7 @@ from clang.cindex import Index
from clang.cindex import SourceLocation
from clang.cindex import SourceRange
from clang.cindex import TranslationUnitSaveError
+from clang.cindex import TranslationUnitLoadError
from clang.cindex import TranslationUnit
from .util import get_cursor
from .util import get_tu
@@ -239,3 +240,19 @@ def test_get_tokens_gc():
del tokens
gc.collect()
gc.collect() # Just in case.
+
+def test_fail_from_source():
+ path = os.path.join(kInputsDir, 'non-existent.cpp')
+ try:
+ tu = TranslationUnit.from_source(path)
+ except TranslationUnitLoadError:
+ tu = None
+ assert tu == None
+
+def test_fail_from_ast_file():
+ path = os.path.join(kInputsDir, 'non-existent.ast')
+ try:
+ tu = TranslationUnit.from_ast_file(path)
+ except TranslationUnitLoadError:
+ tu = None
+ assert tu == None
OpenPOWER on IntegriCloud