From b5ea630dfd1a0d3e5c08d8959158608dd213d9aa Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 2 Dec 2017 12:46:48 +0000 Subject: Vendor import of clang release_50 branch r319231: https://llvm.org/svn/llvm-project/cfe/branches/release_50@319231 --- bindings/python/tests/cindex/test_diagnostics.py | 8 +++++++ .../cindex/test_exception_specification_kind.py | 27 ++++++++++++++++++++++ .../tests/test_exception_specification_kind.py | 27 ---------------------- 3 files changed, 35 insertions(+), 27 deletions(-) create mode 100644 bindings/python/tests/cindex/test_exception_specification_kind.py delete mode 100644 bindings/python/tests/test_exception_specification_kind.py (limited to 'bindings/python/tests') diff --git a/bindings/python/tests/cindex/test_diagnostics.py b/bindings/python/tests/cindex/test_diagnostics.py index ba6e545e8b1a..23cbe89f6581 100644 --- a/bindings/python/tests/cindex/test_diagnostics.py +++ b/bindings/python/tests/cindex/test_diagnostics.py @@ -92,3 +92,11 @@ def test_diagnostic_children(): assert children[0].spelling.endswith('declared here') assert children[0].location.line == 1 assert children[0].location.column == 1 + +def test_diagnostic_string_repr(): + tu = get_tu('struct MissingSemicolon{}') + assert len(tu.diagnostics) == 1 + d = tu.diagnostics[0] + + assert repr(d) == ', spelling "expected \';\' after struct">' + diff --git a/bindings/python/tests/cindex/test_exception_specification_kind.py b/bindings/python/tests/cindex/test_exception_specification_kind.py new file mode 100644 index 000000000000..543d47f7db97 --- /dev/null +++ b/bindings/python/tests/cindex/test_exception_specification_kind.py @@ -0,0 +1,27 @@ +import clang.cindex +from clang.cindex import ExceptionSpecificationKind +from .util import get_tu + + +def find_function_declarations(node, declarations=[]): + if node.kind == clang.cindex.CursorKind.FUNCTION_DECL: + declarations.append((node.spelling, node.exception_specification_kind)) + for child in node.get_children(): + declarations = find_function_declarations(child, declarations) + return declarations + + +def test_exception_specification_kind(): + source = """int square1(int x); + int square2(int x) noexcept; + int square3(int x) noexcept(noexcept(x * x));""" + + tu = get_tu(source, lang='cpp', flags=['-std=c++14']) + + declarations = find_function_declarations(tu.cursor) + expected = [ + ('square1', ExceptionSpecificationKind.NONE), + ('square2', ExceptionSpecificationKind.BASIC_NOEXCEPT), + ('square3', ExceptionSpecificationKind.COMPUTED_NOEXCEPT) + ] + assert declarations == expected diff --git a/bindings/python/tests/test_exception_specification_kind.py b/bindings/python/tests/test_exception_specification_kind.py deleted file mode 100644 index 543d47f7db97..000000000000 --- a/bindings/python/tests/test_exception_specification_kind.py +++ /dev/null @@ -1,27 +0,0 @@ -import clang.cindex -from clang.cindex import ExceptionSpecificationKind -from .util import get_tu - - -def find_function_declarations(node, declarations=[]): - if node.kind == clang.cindex.CursorKind.FUNCTION_DECL: - declarations.append((node.spelling, node.exception_specification_kind)) - for child in node.get_children(): - declarations = find_function_declarations(child, declarations) - return declarations - - -def test_exception_specification_kind(): - source = """int square1(int x); - int square2(int x) noexcept; - int square3(int x) noexcept(noexcept(x * x));""" - - tu = get_tu(source, lang='cpp', flags=['-std=c++14']) - - declarations = find_function_declarations(tu.cursor) - expected = [ - ('square1', ExceptionSpecificationKind.NONE), - ('square2', ExceptionSpecificationKind.BASIC_NOEXCEPT), - ('square3', ExceptionSpecificationKind.COMPUTED_NOEXCEPT) - ] - assert declarations == expected -- cgit v1.3