summaryrefslogtreecommitdiffstats
path: root/clang/bindings/python/tests
diff options
context:
space:
mode:
authorTobias Grosser <grosser@fim.uni-passau.de>2011-10-31 00:31:32 +0000
committerTobias Grosser <grosser@fim.uni-passau.de>2011-10-31 00:31:32 +0000
commite15496f1d7dca724e4d62b462fa1630da6c7dacf (patch)
tree28b7f70a4648d646b443a99b6e754a1eae2fa8e3 /clang/bindings/python/tests
parent80c4b81f54f561d8af292c2b11d6feebea4da506 (diff)
downloadbcm5719-llvm-e15496f1d7dca724e4d62b462fa1630da6c7dacf.tar.gz
bcm5719-llvm-e15496f1d7dca724e4d62b462fa1630da6c7dacf.zip
cindex.py: Allow to create a cursor from file/row/column
We add a constructor to create a SourceLocation from a position in a file and we use this SourceLocation to retrieve a cursor. llvm-svn: 143322
Diffstat (limited to 'clang/bindings/python/tests')
-rw-r--r--clang/bindings/python/tests/cindex/test_location.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/clang/bindings/python/tests/cindex/test_location.py b/clang/bindings/python/tests/cindex/test_location.py
index 47c1c6021f5..300136f0cdc 100644
--- a/clang/bindings/python/tests/cindex/test_location.py
+++ b/clang/bindings/python/tests/cindex/test_location.py
@@ -1,4 +1,4 @@
-from clang.cindex import Index
+from clang.cindex import Index, File, SourceLocation, Cursor
baseInput="int one;\nint two;\n"
@@ -35,6 +35,18 @@ def test_location():
if n.spelling == 'two':
assert_location(n.location,line=2,column=5,offset=14)
+ # define the expected location ourselves and see if it matches
+ # the returned location
+ tu = index.parse('t.c', unsaved_files = [('t.c',baseInput)])
+
+ file = File.from_name(tu, 't.c')
+ location = SourceLocation.from_position(tu, file, 1, 5)
+ cursor = Cursor.from_location(tu, location)
+
+ for n in tu.cursor.get_children():
+ if n.spelling == 'one':
+ assert n == cursor
+
def test_extent():
index = Index.create()
tu = index.parse('t.c', unsaved_files = [('t.c',baseInput)])
OpenPOWER on IntegriCloud