19 if (
Result ==
TFR.PENDING || other.Result ==
TFR.PENDING)
20 ErrorEx(
"Trying to And while one of the results are PENDING.");
22 if (
Result ==
TFR.SUCCESS && other.Result ==
TFR.SUCCESS)
32 if (
Result ==
TFR.PENDING || other.Result ==
TFR.PENDING)
33 ErrorEx(
"Trying to Or while one of the results are PENDING.");
35 if (
Result ==
TFR.SUCCESS || other.Result ==
TFR.SUCCESS)
47 private Class m_Instance;
48 private string m_Test;
53 m_Instance = instance;
60 bool callResult =
GetGame().GameScript.CallFunction(m_Instance, m_Test, m_Result, dt);
63 ErrorEx(
string.Format(
"Failed to call function \'%1\' on \'%2\'", m_Test, m_Instance.GetDebugName()));
64 m_Result.Result =
TFR.FAIL;
77 return string.Format(
"%1::%2", m_Instance.ClassName(), m_Test);
86 private int m_Success;
88 private ref TFCallerArr m_Tests;
99 m_SucceededTests = {};
120 return m_Count - (m_Failed + m_Success);
123 void AddTest(
Class instance,
string test,
bool repeat)
128 m_Results.Insert(result);
130 m_Tests.Insert(
new TFCaller(instance, test, result));
133 bool Run(
bool fatal,
float dt)
138 int runningTests = m_Tests.Count();
139 for (
int i = 0; i < runningTests; ++i)
141 TFCaller t = m_Tests[i];
147 foreach (TFCaller doneT : done)
148 m_Tests.RemoveItem(doneT);
151 if (fatal && m_Tests.Count() > 0)
153 Print(
"- Active tests -------------------------");
154 foreach (TFCaller rTest : m_Tests)
155 Print(rTest.GetTest());
156 Print(
"----------------------------------------");
158 ErrorEx(
"Not all tests are done while run was fatal.");
162 return m_Tests.Count() == 0;
165 private bool RunTest(TFCaller caller,
float dt)
167 TFR res = caller.Run(dt).Result;
173 m_FailedTests.Insert(caller.GetTestEx());
177 m_SucceededTests.Insert(caller.GetTestEx());
181 return res !=
TFR.PENDING;
186 return string.Format(
"{ [TFModule] :: Tests: %1 | Success: %2 | Failed: %3 | Pending: %4 }", Count(), Success(), Failed(), Pending());
189 void PrintResult(
string prefix =
"",
TestFramework caller =
null,
string function =
"")
191 Debug.TFLog(
string.Format(
"%1%2", prefix, Result()), caller,
function);
192 if (m_SucceededTests.Count())
194 Debug.TFLog(
" |-[SUCCESS]", caller,
function);
195 foreach (
string success : m_SucceededTests)
197 Debug.TFLog(
string.Format(
" |- %1", success), caller,
function);
200 if (m_FailedTests.Count())
202 Debug.TFLog(
" |-[FAILED]", caller,
function);
203 foreach (
string fail : m_FailedTests)
205 Debug.TFLog(
string.Format(
" |- %1", fail), caller,
function);