diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2015-10-12 03:10:20 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2015-10-12 03:10:20 +0000 |
commit | d79eec97fcfeac61cd4f8d38dd4d6ce27ee4a36c (patch) | |
tree | 90082ca6b6af52437919922b42961adcb58ccaa5 /clang/bindings/python/tests | |
parent | 7c6a3b4c479228e6608382ea1ab90a621622ce4f (diff) | |
download | bcm5719-llvm-d79eec97fcfeac61cd4f8d38dd4d6ce27ee4a36c.tar.gz bcm5719-llvm-d79eec97fcfeac61cd4f8d38dd4d6ce27ee4a36c.zip |
bindings: add new C++ function attribute accessors
Add methods to index Cursor to see if a cxx method is pure_virtual,
virtual or const methods.
Patch by Jonathan B Coe!
llvm-svn: 250008
Diffstat (limited to 'clang/bindings/python/tests')
-rw-r--r-- | clang/bindings/python/tests/cindex/test_cursor.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/clang/bindings/python/tests/cindex/test_cursor.py b/clang/bindings/python/tests/cindex/test_cursor.py index a5224aafabc..68fc8fa4aca 100644 --- a/clang/bindings/python/tests/cindex/test_cursor.py +++ b/clang/bindings/python/tests/cindex/test_cursor.py @@ -97,6 +97,21 @@ def test_canonical(): assert len(cursors) == 3 assert cursors[1].canonical == cursors[2].canonical +def test_is_const_method(): + """Ensure Cursor.is_const_method works.""" + source = 'class X { void foo() const; void bar(); };' + tu = get_tu(source, lang='cpp') + + cls = get_cursor(tu, 'X') + foo = get_cursor(tu, 'foo') + bar = get_cursor(tu, 'bar') + assert cls is not None + assert foo is not None + assert bar is not None + + assert foo.is_const_method() + assert not bar.is_const_method() + def test_is_static_method(): """Ensure Cursor.is_static_method works.""" @@ -113,6 +128,36 @@ def test_is_static_method(): assert foo.is_static_method() assert not bar.is_static_method() +def test_is_pure_virtual_method(): + """Ensure Cursor.is_pure_virtual_method works.""" + source = 'class X { virtual void foo() = 0; virtual void bar(); };' + tu = get_tu(source, lang='cpp') + + cls = get_cursor(tu, 'X') + foo = get_cursor(tu, 'foo') + bar = get_cursor(tu, 'bar') + assert cls is not None + assert foo is not None + assert bar is not None + + assert foo.is_pure_virtual_method() + assert not bar.is_pure_virtual_method() + +def test_is_virtual_method(): + """Ensure Cursor.is_virtual_method works.""" + source = 'class X { virtual void foo(); void bar(); };' + tu = get_tu(source, lang='cpp') + + cls = get_cursor(tu, 'X') + foo = get_cursor(tu, 'foo') + bar = get_cursor(tu, 'bar') + assert cls is not None + assert foo is not None + assert bar is not None + + assert foo.is_virtual_method() + assert not bar.is_virtual_method() + def test_underlying_type(): tu = get_tu('typedef int foo;') typedef = get_cursor(tu, 'foo') |