mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Fixed default args with test methods
This commit is contained in:
parent
0204e666da
commit
deae8fe1e3
1 changed files with 19 additions and 19 deletions
|
@ -897,16 +897,6 @@ void BfCompiler::GetTestMethods(BfVDataModule* bfModule, Array<TestMethod>& test
|
|||
if (typeInstance == NULL)
|
||||
continue;
|
||||
|
||||
if (typeInstance->mTypeDef->IsGlobalsContainer())
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
||||
if (typeInstance->mTypeDef->mProject->mName == "BeefTest")
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
||||
if (typeInstance->IsUnspecializedType())
|
||||
continue;
|
||||
|
||||
|
@ -1034,8 +1024,11 @@ void BfCompiler::EmitTestMethod(BfVDataModule* bfModule, Array<TestMethod>& test
|
|||
else
|
||||
{
|
||||
for (int defaultIdx = 0; defaultIdx < (int)methodInstance->mDefaultValues.size(); defaultIdx++)
|
||||
{
|
||||
auto castedVal = bfModule->Cast(methodInstance->mMethodDef->GetRefNode(), methodInstance->mDefaultValues[defaultIdx], methodInstance->GetParamType(defaultIdx));
|
||||
{
|
||||
auto constHolder = methodInstance->GetOwner()->mConstHolder;
|
||||
auto defaultTypedValue = methodInstance->mDefaultValues[defaultIdx];
|
||||
auto defaultVal = bfModule->ConstantToCurrent(constHolder->GetConstant(defaultTypedValue.mValue), constHolder, defaultTypedValue.mType);
|
||||
auto castedVal = bfModule->Cast(methodInstance->mMethodDef->GetRefNode(), BfTypedValue(defaultVal, defaultTypedValue.mType), methodInstance->GetParamType(defaultIdx));
|
||||
if (castedVal)
|
||||
{
|
||||
BfExprEvaluator exprEvaluator(bfModule);
|
||||
|
@ -7035,27 +7028,34 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
|
|||
|
||||
if (hasTests)
|
||||
{
|
||||
HashSet<BfProject*> projectSet;
|
||||
|
||||
for (auto type : mContext->mResolvedTypes)
|
||||
{
|
||||
auto typeInstance = type->ToTypeInstance();
|
||||
if ((typeInstance != NULL) &&
|
||||
(typeInstance->mTypeDef->mProject->mTargetType == BfTargetType_BeefTest))
|
||||
{
|
||||
bool typeHasTest = false;
|
||||
if (typeInstance != NULL)
|
||||
{
|
||||
for (auto& methodInstanceGroup : typeInstance->mMethodInstanceGroups)
|
||||
{
|
||||
if (methodInstanceGroup.mDefault != NULL)
|
||||
{
|
||||
auto methodInstance = methodInstanceGroup.mDefault;
|
||||
auto project = methodInstance->mMethodDef->mDeclaringType->mProject;
|
||||
if (project->mTargetType != BfTargetType_BeefTest)
|
||||
continue;
|
||||
if ((methodInstance->GetCustomAttributes() != NULL) &&
|
||||
(methodInstance->GetCustomAttributes()->Contains(mTestAttributeTypeDef)))
|
||||
{
|
||||
typeHasTest = true;
|
||||
projectSet.Add(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typeHasTest)
|
||||
mContext->MarkUsedModules(typeInstance->mTypeDef->mProject, typeInstance->mModule);
|
||||
if (!projectSet.IsEmpty())
|
||||
{
|
||||
for (auto project : projectSet)
|
||||
mContext->MarkUsedModules(project, typeInstance->mModule);
|
||||
projectSet.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue