Unittests and demos update

-fixed bug in EntityManager
-added better support for non-betterC unittests
-added many new unittests
-slightly improved JUnit xml output
-fixed WASM compile script
-added new textures
-fixed model texture coordinaes in demos
-some minor bug fixes in demo
TODO: demos cpu usage in non-betterC mode
This commit is contained in:
Mergul 2020-04-16 22:16:20 +02:00
parent 46530ff45b
commit 84e04191c8
13 changed files with 453 additions and 51 deletions

View file

@ -60,6 +60,11 @@ string copyString(const char* str)
return cast(string) Mallocator.makeArray(arr);
}
string copyString(string str)
{
return cast(string) Mallocator.makeArray((cast(char*)str)[0 .. str.length + 1]);
}
struct TestRunner(Args...)
{
void generateJUnit()
@ -90,10 +95,10 @@ struct TestRunner(Args...)
write(test.name);
write("\" classname=\"");
write(suite.name);
write("\">\n");
write("\">");
if (test.msg)
{
write("\t\t\t<failure type=\"Fail\" message=\"");
write("\n\t\t\t<failure type=\"Fail\" message=\"");
write(test.msg[0 .. $ - 1]);
write("\">");
write("Assert! File: ");
@ -103,8 +108,10 @@ struct TestRunner(Args...)
write(" Message: ");
write(test.msg[0 .. $ - 1]);
write("</failure>\n");
write("\t\t</testcase>\n");
}
write("\t\t</testcase>\n");
else write("</testcase>\n");
}
write("\t</testsuite>\n");
@ -168,21 +175,39 @@ struct TestRunner(Args...)
static if (__traits(hasMember, module_, "beforeEveryTest"))
module_.beforeEveryTest();
// Save calling environment for longjmp
int jmp_ret = setjmp(gEnvBuffer);
if (jmp_ret == ASSERTED)
version(D_BetterC)
{
passed = false;
test.passed = false;
test.file = copyString(gAssertInfo.file);
test.file_line = gAssertInfo.line;
test.msg = copyString(gAssertInfo.msg);
// Save calling environment for longjmp
int jmp_ret = setjmp(gEnvBuffer);
if (jmp_ret == ASSERTED)
{
test.passed = false;
test.file = copyString(gAssertInfo.file);
test.file_line = gAssertInfo.line;
test.msg = copyString(gAssertInfo.msg);
}
else
{
unittest_();
test.passed = true;
}
}
else
{
unittest_();
test.passed = true;
import core.exception : AssertError;
try
{
unittest_();
test.passed = true;
}
catch(AssertError error)
{
test.passed = false;
test.file = copyString(error.file);
test.file_line = cast(int)error.line;
test.msg = copyString(error.msg);
}
}
if (test.passed)