MCPcopy Create free account
hub / github.com/beefytech/Beef / GetTestMethods

Method GetTestMethods

IDEHelper/Compiler/BfCompiler.cpp:848–935  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

846}
847
848void BfCompiler::GetTestMethods(BfVDataModule* bfModule, Array<TestMethod>& testMethods, HashContext& vdataHashCtx)
849{
850 vdataHashCtx.Mixin(0xBEEF0001); // Marker
851
852 auto _CheckMethod = [&](BfTypeInstance* typeInstance, BfMethodInstance* methodInstance)
853 {
854 auto project = methodInstance->mMethodDef->mDeclaringType->mProject;
855 if (project->mTargetType != BfTargetType_BeefTest)
856 return;
857 if (project != bfModule->mProject)
858 return;
859
860 bool isTest = false;
861 if ((methodInstance->GetCustomAttributes() != NULL) &&
862 (methodInstance->GetCustomAttributes()->Contains(mTestAttributeTypeDef)))
863 isTest = true;
864 if (!isTest)
865 return;
866
867 if (methodInstance->mIsUnspecialized)
868 {
869 if (!typeInstance->IsSpecializedType())
870 {
871 bfModule->Fail(StrFormat("Method '%s' cannot be used for testing because it's generic", bfModule->MethodToString(methodInstance).c_str()),
872 methodInstance->mMethodDef->GetRefNode());
873 }
874 bfModule->mHadBuildError = true;
875 return;
876 }
877
878 if (!methodInstance->mMethodDef->mIsStatic)
879 {
880 if (!typeInstance->IsSpecializedType())
881 {
882 bfModule->Fail(StrFormat("Method '%s' cannot be used for testing because it's not static", bfModule->MethodToString(methodInstance).c_str()),
883 methodInstance->mMethodDef->GetRefNode());
884 }
885 bfModule->mHadBuildError = true;
886 return;
887 }
888
889 if (methodInstance->GetParamCount() > 0)
890 {
891 if ((methodInstance->GetParamInitializer(0) == NULL) &&
892 (methodInstance->GetParamKind(0) != BfParamKind_Params))
893 {
894 if (!typeInstance->IsSpecializedType())
895 {
896 bfModule->Fail(StrFormat("Method '%s' cannot be used for testing because it contains parameters without defaults", bfModule->MethodToString(methodInstance).c_str()),
897 methodInstance->mMethodDef->GetRefNode());
898 }
899 bfModule->mHadBuildError = true;
900 return;
901 }
902 }
903
904 BF_ASSERT(typeInstance->IsReified());
905

Callers

nothing calls this directly

Calls 15

MethodToStringMethod · 0.80
GetParamInitializerMethod · 0.80
GetParamKindMethod · 0.80
MixinMethod · 0.45
GetCustomAttributesMethod · 0.45
ContainsMethod · 0.45
IsSpecializedTypeMethod · 0.45
FailMethod · 0.45
c_strMethod · 0.45
GetRefNodeMethod · 0.45
GetParamCountMethod · 0.45
IsReifiedMethod · 0.45

Tested by

no test coverage detected