Slight tweaks to writing byte code to file.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -30,7 +30,7 @@ TEST_CASE("Get a script resolver, initialize it, then delete it") {
|
||||
TEST_CASE("Get a script resolver, set script load function, load script, then build module") {
|
||||
auto lib = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
lib->Initialize(TestLibrary::GetLibrary());
|
||||
lib->CreateScript("testScript1" , _scripts["testScript1"]);
|
||||
lib->CreateScript("testScript1", _scripts["testScript1"]);
|
||||
lib->FinalizeModule();
|
||||
delete lib;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ TEST_CASE("Get a script resolver, set script load function, load script, then bu
|
||||
TEST_CASE("Build script resolver, then create object") {
|
||||
auto lib = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
lib->Initialize(TestLibrary::GetLibrary());
|
||||
lib->CreateScript("testScript1" , _scripts["testScript1"]);
|
||||
lib->CreateScript("testScript1", _scripts["testScript1"]);
|
||||
lib->FinalizeModule();
|
||||
|
||||
auto obj = lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc);
|
||||
@@ -50,11 +50,10 @@ TEST_CASE("Build script resolver, then create object") {
|
||||
TEST_CASE("Build script resolver, create object, invoke addition method") {
|
||||
auto lib = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
lib->Initialize(TestLibrary::GetLibrary());
|
||||
lib->CreateScript("testScript1" , _scripts["testScript1"]);
|
||||
lib->CreateScript("testScript1", _scripts["testScript1"]);
|
||||
lib->FinalizeModule();
|
||||
|
||||
auto obj =
|
||||
dynamic_cast<AngelScriptScript*>(lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc));
|
||||
auto obj = dynamic_cast<AngelScriptScript*>(lib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc));
|
||||
REQUIRE(obj != nullptr);
|
||||
auto ctxPool = obj->GetContextPool();
|
||||
auto ctx = ctxPool->RequestContext();
|
||||
@@ -82,16 +81,16 @@ TEST_CASE("Build script resolver, create object, invoke addition method") {
|
||||
TEST_CASE("Get a script resolver, save the byte code to memory, create new script resolver from it") {
|
||||
auto originLib = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
originLib->Initialize(TestLibrary::GetLibrary());
|
||||
originLib->CreateScript("testScript1" , _scripts["testScript1"]);
|
||||
originLib->CreateScript("testScript1", _scripts["testScript1"]);
|
||||
originLib->FinalizeModule();
|
||||
size_t size;
|
||||
auto byteCode = originLib->WriteByteCodeToMemory(size);
|
||||
auto typeDatabase = originLib->GetTypeDatabase();
|
||||
|
||||
Dictionary<ScriptCategory, Dictionary<ConstString, const char*>> types;
|
||||
for (auto& innerDb: typeDatabase){
|
||||
for (auto& innerDb : typeDatabase) {
|
||||
Dictionary<ConstString, const char*> newInnerDb;
|
||||
for (auto& kv : innerDb.second){
|
||||
for (auto& kv : innerDb.second) {
|
||||
INFO(kv.second->GetDecl());
|
||||
newInnerDb.Insert(kv.first, kv.second->GetDecl());
|
||||
}
|
||||
@@ -101,46 +100,11 @@ TEST_CASE("Get a script resolver, save the byte code to memory, create new scrip
|
||||
auto newLib = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
newLib->Initialize(TestLibrary::GetLibrary());
|
||||
newLib->LoadByteCodeFromMemory(byteCode, size, types);
|
||||
auto obj =
|
||||
dynamic_cast<AngelScriptScript*>(newLib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc));
|
||||
auto obj = dynamic_cast<AngelScriptScript*>(newLib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc));
|
||||
REQUIRE(obj != nullptr);
|
||||
delete obj;
|
||||
delete originLib;
|
||||
delete newLib;
|
||||
free(byteCode);
|
||||
}
|
||||
|
||||
TEST_CASE("Get a script resolver, save the byte code to file, create new script resolver from it") {
|
||||
const char* TestFileName = "compiledAngelScriptTestFile.bin";
|
||||
auto originLib = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
originLib->Initialize(TestLibrary::GetLibrary());
|
||||
originLib->CreateScript("testScript1" , _scripts["testScript1"]);
|
||||
originLib->FinalizeModule();
|
||||
originLib->WriteByteCodeToFile(TestFileName);
|
||||
auto typeDatabase = originLib->GetTypeDatabase();
|
||||
|
||||
Dictionary<ScriptCategory, Dictionary<ConstString, const char*>> types;
|
||||
for (auto& innerDb: typeDatabase){
|
||||
Dictionary<ConstString, const char*> newInnerDb;
|
||||
for (auto& kv : innerDb.second){
|
||||
INFO(kv.second->GetDecl());
|
||||
newInnerDb.Insert(kv.first, kv.second->GetDecl());
|
||||
}
|
||||
types.Insert(innerDb.first, newInnerDb);
|
||||
}
|
||||
|
||||
auto newLib = dynamic_cast<AngelScripResolver*>(PkmnLib::Battling::BattleLibrary::CreateScriptResolver());
|
||||
newLib->Initialize(TestLibrary::GetLibrary());
|
||||
newLib->LoadByteCodeFromFile(TestFileName, types);
|
||||
auto obj =
|
||||
dynamic_cast<AngelScriptScript*>(newLib->LoadScript(ScriptCategory::Creature, "testScript1"_cnc));
|
||||
REQUIRE(obj != nullptr);
|
||||
delete obj;
|
||||
delete originLib;
|
||||
delete newLib;
|
||||
remove(TestFileName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user