added template return type test and more
This commit is contained in:
parent
3f921a0d76
commit
ee6f8a867f
|
|
@ -375,9 +375,6 @@ struct DSymbol
|
|||
// TODO: assert that the type is not a function
|
||||
DSymbol* type;
|
||||
|
||||
// Return type symbol, if symbol currently is of function kind
|
||||
DSymbol* returnType;
|
||||
|
||||
// Is alias this symbols
|
||||
DSymbol*[] aliasThisSymbols;
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -169,6 +169,56 @@ unittest
|
|||
assert(meaningOfLife.type is null);
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
ModuleCache cache;
|
||||
writeln("Templated return type should be deduced correctly");
|
||||
auto source = q{
|
||||
struct AnswerToLife(T) {
|
||||
T life;
|
||||
}
|
||||
AnswerToLife!int meaningOfLife() { return AnswerToLife!int(42); }
|
||||
|
||||
};
|
||||
ScopeSymbolPair pair = generateAutocompleteTrees(source, cache);
|
||||
auto answerToLife = pair.symbol.getFirstPartNamed(istring("AnswerToLife"));
|
||||
DSymbol* meaningOfLife = pair.symbol.getFirstPartNamed(istring("meaningOfLife"));
|
||||
assert(meaningOfLife.type.name == "AnswerToLife");
|
||||
assert(meaningOfLife.type is answerToLife);
|
||||
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
ModuleCache cache;
|
||||
writeln("Array return type should be deduced correctly");
|
||||
auto source = q{
|
||||
int[] meaningOfLife() { return [42]; }
|
||||
|
||||
};
|
||||
ScopeSymbolPair pair = generateAutocompleteTrees(source, cache);
|
||||
DSymbol* meaningOfLife = pair.symbol.getFirstPartNamed(istring("meaningOfLife"));
|
||||
assert(meaningOfLife.type.name == "*arr*");
|
||||
|
||||
}
|
||||
|
||||
unittest
|
||||
{
|
||||
ModuleCache cache;
|
||||
writeln("Int* return type should be deduced correctly");
|
||||
auto source = q{
|
||||
int* meaningOfLife()
|
||||
{
|
||||
auto life = 42;
|
||||
return &life;
|
||||
}
|
||||
|
||||
};
|
||||
ScopeSymbolPair pair = generateAutocompleteTrees(source, cache);
|
||||
DSymbol* meaningOfLife = pair.symbol.getFirstPartNamed(istring("meaningOfLife"));
|
||||
writeln(meaningOfLife.type.name);
|
||||
assert(meaningOfLife.type.name == "int");
|
||||
}
|
||||
|
||||
|
||||
unittest
|
||||
|
|
|
|||
Loading…
Reference in New Issue