test/cli/test-clang-import: Improved testing

This commit is contained in:
Daniel Marjamäki 2020-09-03 19:49:02 +02:00
parent 115ad374ba
commit 5cd92a0eb1
2 changed files with 15 additions and 4 deletions

View File

@ -1095,16 +1095,21 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList *tokenList)
symbolDatabase->scopeList.push_back(Scope(nullptr, nullptr, nestedIn));
scope = &symbolDatabase->scopeList.back();
scope->function = function;
scope->classDef = nameToken;
scope->type = Scope::ScopeType::eFunction;
scope->className = nameToken->str();
nestedIn->nestedList.push_back(scope);
function->hasBody(true);
function->functionScope = scope;
}
Token *par1 = addtoken(tokenList, "(");
if (!function->arg)
function->arg = par1;
function->token = nameToken;
if (!function->nestedIn)
function->nestedIn = nestedIn;
function->argDef = par1;
// Function arguments
for (int i = 0; i < children.size(); ++i) {
AstNodePtr child = children[i];

View File

@ -8,12 +8,13 @@ from testutils import create_gui_project_file, cppcheck
def get_debug_section(title, stdout):
s = re.sub(r'0x[0-9a-fA-F]+', '0x12345678', stdout)
s = re.sub(r'nestedIn: Struct', 'nestedIn: Class', s)
s = re.sub(r'classDef: struct', 'classDef: class', s)
s = re.sub(r'isInline: [a-z]+', 'isInline: ---', s)
s = re.sub(r'argDef: .*', 'argDef: ---', s)
s = re.sub(r'nestedIn: .*', 'nestedIn: ---', s)
s = re.sub(r'functionScope: .*', 'functionScope: ---', s)
s = re.sub(r'definedType: .*', 'definedType: ---', s)
s = re.sub(r'classDef: .*', 'classDef: ---', s)
s = re.sub(r'needInitialization: .*', 'needInitialization: ---', s)
s = re.sub(r'functionOf: .*', 'functionOf: ---', s)
s = re.sub(r'0x12345678 Struct', '0x12345678 Class', s)
pos1 = s.find(title)
assert pos1 > 0
pos1 = s.find('\n', pos1) + 1
@ -37,4 +38,9 @@ def check_symbol_database(code):
def test1():
check_symbol_database('int main(){return 0;}')
def test2():
code = 'struct Foo { void f(); }; void Foo::f() {}'
check_symbol_database(code)