mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22: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)
|
if (typeInstance == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (typeInstance->mTypeDef->IsGlobalsContainer())
|
|
||||||
{
|
|
||||||
NOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeInstance->mTypeDef->mProject->mName == "BeefTest")
|
|
||||||
{
|
|
||||||
NOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeInstance->IsUnspecializedType())
|
if (typeInstance->IsUnspecializedType())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1035,7 +1025,10 @@ void BfCompiler::EmitTestMethod(BfVDataModule* bfModule, Array<TestMethod>& test
|
||||||
{
|
{
|
||||||
for (int defaultIdx = 0; defaultIdx < (int)methodInstance->mDefaultValues.size(); defaultIdx++)
|
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)
|
if (castedVal)
|
||||||
{
|
{
|
||||||
BfExprEvaluator exprEvaluator(bfModule);
|
BfExprEvaluator exprEvaluator(bfModule);
|
||||||
|
@ -7035,27 +7028,34 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
|
||||||
|
|
||||||
if (hasTests)
|
if (hasTests)
|
||||||
{
|
{
|
||||||
|
HashSet<BfProject*> projectSet;
|
||||||
|
|
||||||
for (auto type : mContext->mResolvedTypes)
|
for (auto type : mContext->mResolvedTypes)
|
||||||
{
|
{
|
||||||
auto typeInstance = type->ToTypeInstance();
|
auto typeInstance = type->ToTypeInstance();
|
||||||
if ((typeInstance != NULL) &&
|
if (typeInstance != NULL)
|
||||||
(typeInstance->mTypeDef->mProject->mTargetType == BfTargetType_BeefTest))
|
|
||||||
{
|
{
|
||||||
bool typeHasTest = false;
|
|
||||||
for (auto& methodInstanceGroup : typeInstance->mMethodInstanceGroups)
|
for (auto& methodInstanceGroup : typeInstance->mMethodInstanceGroups)
|
||||||
{
|
{
|
||||||
if (methodInstanceGroup.mDefault != NULL)
|
if (methodInstanceGroup.mDefault != NULL)
|
||||||
{
|
{
|
||||||
auto methodInstance = methodInstanceGroup.mDefault;
|
auto methodInstance = methodInstanceGroup.mDefault;
|
||||||
|
auto project = methodInstance->mMethodDef->mDeclaringType->mProject;
|
||||||
|
if (project->mTargetType != BfTargetType_BeefTest)
|
||||||
|
continue;
|
||||||
if ((methodInstance->GetCustomAttributes() != NULL) &&
|
if ((methodInstance->GetCustomAttributes() != NULL) &&
|
||||||
(methodInstance->GetCustomAttributes()->Contains(mTestAttributeTypeDef)))
|
(methodInstance->GetCustomAttributes()->Contains(mTestAttributeTypeDef)))
|
||||||
{
|
{
|
||||||
typeHasTest = true;
|
projectSet.Add(project);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (typeHasTest)
|
if (!projectSet.IsEmpty())
|
||||||
mContext->MarkUsedModules(typeInstance->mTypeDef->mProject, typeInstance->mModule);
|
{
|
||||||
|
for (auto project : projectSet)
|
||||||
|
mContext->MarkUsedModules(project, typeInstance->mModule);
|
||||||
|
projectSet.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue