summaryrefslogtreecommitdiffstats
path: root/bindings/python/tests
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-01-24 02:02:07 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-01-24 02:02:07 +0000
commit30c0f2637c4ba5d8764ff6e1ee6cbc89b89c63db (patch)
tree9dba4466e422e25a50e8f052966190a2bc697b80 /bindings/python/tests
parent7e52de4b45286d057b367bb1f9283a1e32d79252 (diff)
Initial checkin of CIndex Python bindings, by Andrew Sutton!
- Some tweaks by me for API changes, Darwin, and x86_64 support. Still needs substantial updating to match recent CIndex API changes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94349 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings/python/tests')
-rw-r--r--bindings/python/tests/__init__.py0
-rw-r--r--bindings/python/tests/cindex/INPUTS/hello.cpp6
-rw-r--r--bindings/python/tests/cindex/__init__.py0
-rw-r--r--bindings/python/tests/cindex/test_index.py15
-rw-r--r--bindings/python/tests/cindex/test_translation_unit.py10
5 files changed, 31 insertions, 0 deletions
diff --git a/bindings/python/tests/__init__.py b/bindings/python/tests/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/bindings/python/tests/__init__.py
diff --git a/bindings/python/tests/cindex/INPUTS/hello.cpp b/bindings/python/tests/cindex/INPUTS/hello.cpp
new file mode 100644
index 0000000000..7ef086e56b
--- /dev/null
+++ b/bindings/python/tests/cindex/INPUTS/hello.cpp
@@ -0,0 +1,6 @@
+#include "stdio.h"
+
+int main(int argc, char* argv[]) {
+ printf("hello world\n");
+ return 0;
+}
diff --git a/bindings/python/tests/cindex/__init__.py b/bindings/python/tests/cindex/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/bindings/python/tests/cindex/__init__.py
diff --git a/bindings/python/tests/cindex/test_index.py b/bindings/python/tests/cindex/test_index.py
new file mode 100644
index 0000000000..dc173f04d2
--- /dev/null
+++ b/bindings/python/tests/cindex/test_index.py
@@ -0,0 +1,15 @@
+from clang.cindex import *
+import os
+
+kInputsDir = os.path.join(os.path.dirname(__file__), 'INPUTS')
+
+def test_create():
+ index = Index.create()
+
+# FIXME: test Index.read
+
+def test_parse():
+ index = Index.create()
+ assert isinstance(index, Index)
+ tu = index.parse(os.path.join(kInputsDir, 'hello.cpp'))
+ assert isinstance(tu, TranslationUnit)
diff --git a/bindings/python/tests/cindex/test_translation_unit.py b/bindings/python/tests/cindex/test_translation_unit.py
new file mode 100644
index 0000000000..e101247460
--- /dev/null
+++ b/bindings/python/tests/cindex/test_translation_unit.py
@@ -0,0 +1,10 @@
+from clang.cindex import *
+import os
+
+kInputsDir = os.path.join(os.path.dirname(__file__), 'INPUTS')
+
+def test_spelling():
+ path = os.path.join(kInputsDir, 'hello.cpp')
+ index = Index.create()
+ tu = index.parse(path)
+ assert str(tu.spelling) == path