| 846 | } |
| 847 | |
| 848 | void 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 |
nothing calls this directly
no test coverage detected