diff options
| author | Jakob Lykke Andersen <Jakob@caput.dk> | 2016-08-07 18:37:31 +0200 |
|---|---|---|
| committer | Jakob Lykke Andersen <Jakob@caput.dk> | 2016-08-07 18:37:31 +0200 |
| commit | 1b251797bbc7c8d760e6472268a38d9f12d9be6c (patch) | |
| tree | 1a2b670e3343cb65575522f941bc1c18a1cf0b3f /tests/test_domain_cpp.py | |
| parent | 5728e5e8374094e2f2c91f5960925646740cb3eb (diff) | |
| parent | a9da999d71fb37a8d683ab604f0eaa340b557f14 (diff) | |
| download | sphinx-git-1b251797bbc7c8d760e6472268a38d9f12d9be6c.tar.gz | |
Merge branch 'master' into cpp-concepts
Diffstat (limited to 'tests/test_domain_cpp.py')
| -rw-r--r-- | tests/test_domain_cpp.py | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/tests/test_domain_cpp.py b/tests/test_domain_cpp.py index 4febe4239..b4e5ef073 100644 --- a/tests/test_domain_cpp.py +++ b/tests/test_domain_cpp.py @@ -24,7 +24,10 @@ ids = [] def parse(name, string): - parser = DefinitionParser(string, None) + class Config(object): + cpp_id_attributes = ["id_attr"] + cpp_paren_attributes = ["paren_attr"] + parser = DefinitionParser(string, None, Config()) ast = parser.parse_declaration(name) if not parser.eof: print("Parsing stopped at", parser.pos) @@ -77,7 +80,7 @@ def check(name, input, idv1output=None, idv2output=None, output=None): print(rootSymbol.dump(0)) raise DefinitionError("") ids.append(ast.get_id_v2()) - #print ".. %s:: %s" % (name, input) + # print ".. %s:: %s" % (name, input) def test_fundamental_types(): @@ -132,6 +135,11 @@ def test_type_definitions(): check('type', 'A = B', None, '1A') + # from breathe#267 (named function parameters for function pointers + check('type', 'void (*gpio_callback_t)(struct device *port, uint32_t pin)', + 'gpio_callback_t', '15gpio_callback_t') + check('type', 'void (*f)(std::function<void(int i)> g)', 'f', '1f') + def test_concept_definitions(): check('concept', 'template<typename Param> A::B::Concept', @@ -443,11 +451,43 @@ def test_templates(): None, 'IDpE8Numerics') -#def test_print(): -# # used for getting all the ids out for checking -# for a in ids: -# print(a) -# raise DefinitionError("") +def test_attributes(): + # style: C++ + check('member', '[[]] int f', 'f__i', '1f') + check('member', '[ [ ] ] int f', 'f__i', '1f', + # this will fail when the proper grammar is implemented + output='[[ ]] int f') + check('member', '[[a]] int f', 'f__i', '1f') + # style: GNU + check('member', '__attribute__(()) int f', 'f__i', '1f') + check('member', '__attribute__((a)) int f', 'f__i', '1f') + check('member', '__attribute__((a, b)) int f', 'f__i', '1f') + # style: user-defined id + check('member', 'id_attr int f', 'f__i', '1f') + # style: user-defined paren + check('member', 'paren_attr() int f', 'f__i', '1f') + check('member', 'paren_attr(a) int f', 'f__i', '1f') + check('member', 'paren_attr("") int f', 'f__i', '1f') + check('member', 'paren_attr(()[{}][]{}) int f', 'f__i', '1f') + raises(DefinitionError, parse, 'member', 'paren_attr(() int f') + raises(DefinitionError, parse, 'member', 'paren_attr([) int f') + raises(DefinitionError, parse, 'member', 'paren_attr({) int f') + raises(DefinitionError, parse, 'member', 'paren_attr([)]) int f') + raises(DefinitionError, parse, 'member', 'paren_attr((])) int f') + raises(DefinitionError, parse, 'member', 'paren_attr({]}) int f') + + # position: decl specs + check('function', 'static inline __attribute__(()) void f()', + 'f', '1fv', + output='__attribute__(()) static inline void f()') + + + +# def test_print(): +# # used for getting all the ids out for checking +# for a in ids: +# print(a) +# raise DefinitionError("") @with_app(testroot='domain-cpp', confoverrides={'add_function_parentheses': True}) |
