Merge from master

This commit is contained in:
Jakob Lykke Andersen
2015-02-07 00:55:19 +01:00
383 changed files with 24054 additions and 18699 deletions
+44 -13
View File
@@ -5,7 +5,7 @@
Tests the C++ Domain
:copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
:copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -15,6 +15,8 @@ from util import raises
from sphinx.domains.cpp import DefinitionParser, DefinitionError
ids = []
def parse(name, string):
parser = DefinitionParser(string)
res = getattr(parser, "parse_" + name + "_object")()
@@ -27,7 +29,8 @@ def parse(name, string):
def check(name, input, output=None):
# first a simple check of the AST
if output == None: output = input
if output is None:
output = input
ast = parse(name, input)
res = text_type(ast)
if res != output:
@@ -36,8 +39,12 @@ def check(name, input, output=None):
print("Expected: ", output)
raise DefinitionError("")
ast.describe_signature([], 'lastIsName', None)
ast.prefixedName = ast.name # otherwise the get_id fails, it would be set in handle_signarue
ast.get_id()
# Artificially set the prefixedName, otherwise the get_id fails.
# It would usually have been set in handle_signarue.
ast.prefixedName = ast.name
ast.get_id_v1()
ast.get_id_v2()
ids.append(ast.get_id_v2())
#print ".. %s:: %s" % (name, input)
def test_type_definitions():
@@ -49,7 +56,7 @@ def test_type_definitions():
check("type", "bool *volatile const b")
check("type", "bool *volatile const *b")
check("type", "bool &b")
check("type", "bool b[]")
check("type", "bool b[]")
check("type", "std::pair<int, int> coord")
check("type", "long long int foo")
check("type", 'std::vector<std::pair<std::string, long long>> module::blah')
@@ -57,32 +64,49 @@ def test_type_definitions():
check("type", "std::function<R(A1, A2, A3)> F")
check("type", "std::function<R(A1, A2, A3, As...)> F")
check("type", "MyContainer::const_iterator")
check("type", "public MyContainer::const_iterator", "MyContainer::const_iterator")
check('member', ' const std::string & name = 42', 'const std::string &name = 42')
check("type",
"public MyContainer::const_iterator",
"MyContainer::const_iterator")
# test decl specs on right
check("type", "bool const b")
check('member',
' const std::string & name = 42',
'const std::string &name = 42')
check('member', ' const std::string & name', 'const std::string &name')
check('member', ' const std::string & name [ n ]', 'const std::string &name[n]')
check('member', 'const std::vector< unsigned int, long> &name', 'const std::vector<unsigned int, long> &name')
check('member',
' const std::string & name [ n ]',
'const std::string &name[n]')
check('member',
'const std::vector< unsigned int, long> &name',
'const std::vector<unsigned int, long> &name')
check('member', 'module::myclass foo[n]')
check('function', 'operator bool() const')
check('function', 'A::operator bool() const')
check('function', 'A::operator bool() volatile const &')
check('function', 'A::operator bool() volatile const &&')
check('function', 'bool namespaced::theclass::method(arg1, arg2)')
x = 'std::vector<std::pair<std::string, int>> &module::test(register ' \
'foo, bar, std::string baz = "foobar, blah, bleh") const = 0'
check('function', x)
check('function', 'void f(std::pair<A, B>)')
check('function', 'explicit module::myclass::foo::foo()')
check('function', 'module::myclass::foo::~foo()')
check('function', 'int printf(const char *fmt, ...)')
check('function', 'int foo(const unsigned int j)')
check('function', 'int foo(const int *const ptr)')
check('function', 'module::myclass::operator std::vector<std::string>()')
check('function', 'void operator()(const boost::array<VertexID, 2> &v) const')
check('function', 'void operator()(const boost::array<VertexID, 2, "foo, bar"> &v) const')
check('function',
'void operator()(const boost::array<VertexID, 2> &v) const')
check('function',
'void operator()(const boost::array<VertexID, 2, "foo, bar"> &v) const')
check('function', 'MyClass::MyClass(MyClass::MyClass&&)')
check('function', 'constexpr int get_value()')
check('function', 'static constexpr int get_value()')
check('function', 'int get_value() const noexcept')
check('function', 'int get_value() const noexcept = delete')
check('function', 'int get_value() volatile const')
check('function', 'MyClass::MyClass(MyClass::MyClass&&) = default')
check('function', 'virtual MyClass::a_virtual_function() const override')
check('function', 'A B() override')
@@ -101,7 +125,8 @@ def test_type_definitions():
x = 'std::vector<std::pair<std::string, int>> &module::test(register ' \
'foo, bar[n], std::string baz = "foobar, blah, bleh") const = 0'
check('function', x)
check('function', 'int foo(Foo f = Foo(double(), std::make_pair(int(2), double(3.4))))')
check('function',
'int foo(Foo f = Foo(double(), std::make_pair(int(2), double(3.4))))')
check('function', 'int foo(A a = x(a))')
raises(DefinitionError, parse, 'function', 'int foo(B b=x(a)')
raises(DefinitionError, parse, 'function', 'int foo)C c=x(a))')
@@ -140,3 +165,9 @@ def test_operators():
check('function', 'void operator bool() const', 'void operator bool() const')
for op in '*-+=/%!':
check('function', 'void operator %s ()' % op, 'void operator%s()' % op)
#def test_print():
# # used for getting all the ids out for checking
# for a in ids:
# print(a)
# raise DefinitionError("")