test/cli/test-clang-import: Improved testing
This commit is contained in:
parent
115ad374ba
commit
5cd92a0eb1
|
@ -1095,16 +1095,21 @@ void clangimport::AstNode::createTokensFunctionDecl(TokenList *tokenList)
|
||||||
symbolDatabase->scopeList.push_back(Scope(nullptr, nullptr, nestedIn));
|
symbolDatabase->scopeList.push_back(Scope(nullptr, nullptr, nestedIn));
|
||||||
scope = &symbolDatabase->scopeList.back();
|
scope = &symbolDatabase->scopeList.back();
|
||||||
scope->function = function;
|
scope->function = function;
|
||||||
|
scope->classDef = nameToken;
|
||||||
scope->type = Scope::ScopeType::eFunction;
|
scope->type = Scope::ScopeType::eFunction;
|
||||||
scope->className = nameToken->str();
|
scope->className = nameToken->str();
|
||||||
nestedIn->nestedList.push_back(scope);
|
nestedIn->nestedList.push_back(scope);
|
||||||
function->hasBody(true);
|
function->hasBody(true);
|
||||||
|
function->functionScope = scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token *par1 = addtoken(tokenList, "(");
|
Token *par1 = addtoken(tokenList, "(");
|
||||||
if (!function->arg)
|
if (!function->arg)
|
||||||
function->arg = par1;
|
function->arg = par1;
|
||||||
function->token = nameToken;
|
function->token = nameToken;
|
||||||
|
if (!function->nestedIn)
|
||||||
|
function->nestedIn = nestedIn;
|
||||||
|
function->argDef = par1;
|
||||||
// Function arguments
|
// Function arguments
|
||||||
for (int i = 0; i < children.size(); ++i) {
|
for (int i = 0; i < children.size(); ++i) {
|
||||||
AstNodePtr child = children[i];
|
AstNodePtr child = children[i];
|
||||||
|
|
|
@ -8,12 +8,13 @@ from testutils import create_gui_project_file, cppcheck
|
||||||
|
|
||||||
def get_debug_section(title, stdout):
|
def get_debug_section(title, stdout):
|
||||||
s = re.sub(r'0x[0-9a-fA-F]+', '0x12345678', 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'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'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)
|
pos1 = s.find(title)
|
||||||
assert pos1 > 0
|
assert pos1 > 0
|
||||||
pos1 = s.find('\n', pos1) + 1
|
pos1 = s.find('\n', pos1) + 1
|
||||||
|
@ -37,4 +38,9 @@ def check_symbol_database(code):
|
||||||
def test1():
|
def test1():
|
||||||
check_symbol_database('int main(){return 0;}')
|
check_symbol_database('int main(){return 0;}')
|
||||||
|
|
||||||
|
def test2():
|
||||||
|
code = 'struct Foo { void f(); }; void Foo::f() {}'
|
||||||
|
check_symbol_database(code)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue