Compare commits
16 Commits
Author | SHA1 | Date |
---|---|---|
Deukhoofd | 71d77350d5 | |
Deukhoofd | 2e9248ff18 | |
Deukhoofd | 0c82ff9e82 | |
Deukhoofd | 44e850cfc7 | |
Deukhoofd | 810968354e | |
Deukhoofd | 176cb9f1c0 | |
Deukhoofd | 69404a26da | |
Deukhoofd | e4cf12137a | |
Deukhoofd | 8e5f196d37 | |
Deukhoofd | 9685037cf3 | |
Deukhoofd | 2a4ec47d15 | |
Deukhoofd | 367bd01474 | |
Deukhoofd | 42080a3c95 | |
Deukhoofd | 7342cf8a56 | |
Deukhoofd | fbbfbfd3b3 | |
Deukhoofd | 3b2e4f20ac |
|
@ -1,3 +1,4 @@
|
||||||
/cmake-build-debug/
|
/cmake-build-debug/
|
||||||
/cmake-build-release/
|
/cmake-build-release/
|
||||||
|
/build-release-windows/
|
||||||
/.idea/
|
/.idea/
|
|
@ -1,14 +1,42 @@
|
||||||
cmake_minimum_required(VERSION 3.18)
|
cmake_minimum_required(VERSION 3.18)
|
||||||
project(PokemonScriptTester)
|
project(PokemonScriptTester)
|
||||||
|
|
||||||
|
include(CPM.cmake)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(BUILD_SHARED_LIBS OFF)
|
set(BUILD_SHARED_LIBS OFF)
|
||||||
|
|
||||||
option(WINDOWS "Whether the build target is Windows or not." OFF)
|
option(WINDOWS "Whether the build target is Windows or not." OFF)
|
||||||
set(SHARED OFF)
|
set(SHARED OFF)
|
||||||
|
|
||||||
include(CMakeLists.txt.in)
|
if (WINDOWS)
|
||||||
include_pkmnlib()
|
SET(ANGELSCRIPT_DEBUGGER OFF)
|
||||||
|
else()
|
||||||
|
SET(ANGELSCRIPT_DEBUGGER ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/include)
|
||||||
|
CPMAddPackage(
|
||||||
|
NAME PkmnLib
|
||||||
|
GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/PkmnLib.git
|
||||||
|
GIT_TAG master
|
||||||
|
OPTIONS
|
||||||
|
"SHARED=${SHARED}"
|
||||||
|
"WINDOWS=${WINDOWS}"
|
||||||
|
"ANGELSCRIPT_DEBUGGER=${ANGELSCRIPT_DEBUGGER}"
|
||||||
|
)
|
||||||
|
execute_process(COMMAND ln -sf ${PkmnLib_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/include/PkmnLib)
|
||||||
|
|
||||||
|
CPMAddPackage(
|
||||||
|
NAME Angelscript
|
||||||
|
GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/Angelscript.git
|
||||||
|
GIT_TAG master
|
||||||
|
DOWNLOAD_ONLY YES
|
||||||
|
)
|
||||||
|
include_directories(${Angelscript_SOURCE_DIR}/angelscript/include)
|
||||||
|
include_directories(${Angelscript_SOURCE_DIR}/add_on)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
add_compile_options(-fconcepts)
|
add_compile_options(-fconcepts)
|
||||||
|
@ -18,13 +46,32 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
add_link_options(-fuse-ld=lld)
|
add_link_options(-fuse-ld=lld)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
set(SRC_FILES_PATTERN src/*.cpp src/*.hpp)
|
||||||
file(GLOB_RECURSE SRC_FILES src/*.cpp src/*.hpp extern/AngelscriptDebugger/src/*.cpp)
|
if (NOT WINDOWS)
|
||||||
|
set(SRC_FILES_PATTERN ${SRC_FILES_PATTERN} extern/AngelscriptDebugger/src/*.cpp)
|
||||||
|
endif()
|
||||||
|
file(GLOB_RECURSE SRC_FILES ${SRC_FILES_PATTERN})
|
||||||
add_executable(PokemonScriptTester ${SRC_FILES})
|
add_executable(PokemonScriptTester ${SRC_FILES})
|
||||||
target_precompile_headers(PokemonScriptTester PUBLIC src/Precompiled.hxx)
|
|
||||||
add_definitions(-DLEVEL_U8)
|
|
||||||
|
|
||||||
SET(_LINKS -static pkmnLib)
|
target_include_directories(PokemonScriptTester PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include/)
|
||||||
|
target_include_directories(PokemonScriptTester PUBLIC ${PkmnLib_BINARY_DIR}/include/)
|
||||||
|
target_link_directories(PokemonScriptTester PUBLIC ${Angelscript_BINARY_DIR})
|
||||||
|
|
||||||
|
add_definitions(-DLEVEL_U8)
|
||||||
|
if (NOT WINDOWS)
|
||||||
|
ADD_DEFINITIONS(-DANGELSCRIPT_DEBUGGER)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
SET(_LINKS -static pkmnLib Arbutils)
|
||||||
|
|
||||||
|
if (NOT WINDOWS)
|
||||||
|
SET(_LINKS ${_LINKS} AngelscriptDebugger)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (WINDOWS)
|
||||||
|
SET(_LINKS ${_LINKS} -Wl,-Bstatic -lgcc -lstdc++ -lpthread -Wl,-Bdynamic)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(PokemonScriptTester PUBLIC ${_LINKS})
|
target_link_libraries(PokemonScriptTester PUBLIC ${_LINKS})
|
||||||
target_compile_options(PokemonScriptTester PRIVATE -Wall -Wextra -Werror)
|
target_compile_options(PokemonScriptTester PRIVATE -Wall -Wextra -Werror)
|
||||||
|
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
cmake_minimum_required(VERSION 2.8.12)
|
|
||||||
|
|
||||||
project(PokemonScriptTester NONE)
|
|
||||||
|
|
||||||
include(ExternalProject)
|
|
||||||
ExternalProject_Add(pkmnlib
|
|
||||||
GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/PkmnLib
|
|
||||||
GIT_TAG master
|
|
||||||
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/PkmnLib"
|
|
||||||
CONFIGURE_COMMAND ""
|
|
||||||
BUILD_COMMAND ""
|
|
||||||
INSTALL_COMMAND ""
|
|
||||||
TEST_COMMAND ""
|
|
||||||
CMAKE_ARGS "-DSHARED=${SHARED} -DWINDOWS=${WINDOWS} -DSTATICC=${STATICC}"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
function(include_pkmnlib)
|
|
||||||
# Download and unpack googletest at configure time
|
|
||||||
configure_file(CMakeLists.txt.in PkmnLib/download/CMakeLists.txt)
|
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
|
||||||
RESULT_VARIABLE result
|
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/download)
|
|
||||||
if (result)
|
|
||||||
message(FATAL_ERROR "CMake step for pkmnlib failed: ${result}")
|
|
||||||
endif ()
|
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
|
||||||
RESULT_VARIABLE result
|
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/download)
|
|
||||||
if (result)
|
|
||||||
message(FATAL_ERROR "Build step for pkmnlib failed: ${result}")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
# Add googletest directly to our build. This defines
|
|
||||||
# the gtest and gtest_main targets.
|
|
||||||
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/src/pkmnlib
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/bin
|
|
||||||
EXCLUDE_FROM_ALL)
|
|
||||||
|
|
||||||
execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/include)
|
|
||||||
execute_process(COMMAND ln -s ${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/src/pkmnlib/src
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/include/PkmnLib)
|
|
||||||
execute_process(COMMAND cp -r ${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/src/pkmnlib/extern
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/include/PkmnLib/extern)
|
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/include
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/src/pkmnlib/extern/AngelscriptDebuggerServer/extern/asio-1.18.2/include
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/bin/CreatureLib/include
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/bin/Angelscript/src/AngelscriptProj/angelscript/include
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/PkmnLib/bin/CreatureLib/bin/Arbutils/include)
|
|
||||||
|
|
||||||
|
|
||||||
endfunction()
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit d3e95dad61c5ce60db17db905fec4eeb4f65fdce
|
Subproject commit fd24ce63c1113eef37d6153ad295928b700545fa
|
|
@ -1,6 +0,0 @@
|
||||||
#ifndef POKEMONSCRIPTTESTER_PRECOMPILED_HXX
|
|
||||||
#define POKEMONSCRIPTTESTER_PRECOMPILED_HXX
|
|
||||||
|
|
||||||
#include <PkmnLib/Precompiled.hxx>
|
|
||||||
|
|
||||||
#endif // POKEMONSCRIPTTESTER_PRECOMPILED_HXX
|
|
|
@ -31,6 +31,21 @@ class BattleFunctions {
|
||||||
return p1;
|
return p1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CreatureLib::Battling::CreatureParty* CreateParty(CScriptArray* mons) {
|
||||||
|
auto* ctx = asGetActiveContext();
|
||||||
|
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
|
||||||
|
|
||||||
|
auto p1 = new PkmnLib::Battling::PokemonParty(mons->GetSize());
|
||||||
|
for (u32 i = 0; i < mons->GetSize(); ++i) {
|
||||||
|
auto s = *reinterpret_cast<PkmnLib::Battling::Pokemon**>(mons->At(i));
|
||||||
|
p1->SwapInto(i, s);
|
||||||
|
// Party becomes owner of mon, so take it from GC.
|
||||||
|
env->TakeOwnershipOfGarbage(s);
|
||||||
|
}
|
||||||
|
env->AddGarbage(p1);
|
||||||
|
return p1;
|
||||||
|
}
|
||||||
|
|
||||||
static PkmnLib::Battling::Battle* CreateSimpleBattle(u32 seed, const ArbUt::StringView& species1,
|
static PkmnLib::Battling::Battle* CreateSimpleBattle(u32 seed, const ArbUt::StringView& species1,
|
||||||
const ArbUt::StringView& species2, u8 level) {
|
const ArbUt::StringView& species2, u8 level) {
|
||||||
auto* ctx = asGetActiveContext();
|
auto* ctx = asGetActiveContext();
|
||||||
|
@ -140,7 +155,7 @@ class BattleFunctions {
|
||||||
static void LearnMove(PkmnLib::Battling::Pokemon* user, const ArbUt::StringView& moveName) {
|
static void LearnMove(PkmnLib::Battling::Pokemon* user, const ArbUt::StringView& moveName) {
|
||||||
auto move = Globals::Library.GetValue()->GetMoveLibrary()->TryGet(moveName);
|
auto move = Globals::Library.GetValue()->GetMoveLibrary()->TryGet(moveName);
|
||||||
if (!move.has_value()) {
|
if (!move.has_value()) {
|
||||||
THROW("Unknown move: " << moveName);
|
THROW("Unknown move: ", moveName);
|
||||||
}
|
}
|
||||||
user->AddAttack(
|
user->AddAttack(
|
||||||
new PkmnLib::Battling::LearnedMove(move.value(), CreatureLib::Battling::AttackLearnMethod::Unknown));
|
new PkmnLib::Battling::LearnedMove(move.value(), CreatureLib::Battling::AttackLearnMethod::Unknown));
|
||||||
|
@ -152,6 +167,8 @@ public:
|
||||||
Ensure(
|
Ensure(
|
||||||
engine->RegisterGlobalFunction("Party@ CreateSimpleParty(const array<constString>&in species, uint8 level)",
|
engine->RegisterGlobalFunction("Party@ CreateSimpleParty(const array<constString>&in species, uint8 level)",
|
||||||
asFUNCTION(CreateSimpleParty), asCALL_CDECL) >= 0);
|
asFUNCTION(CreateSimpleParty), asCALL_CDECL) >= 0);
|
||||||
|
Ensure(engine->RegisterGlobalFunction("Party@ CreateParty(const array<Pokemon@>&in mons)",
|
||||||
|
asFUNCTION(CreateParty), asCALL_CDECL) >= 0);
|
||||||
Ensure(engine->RegisterGlobalFunction("Battle@ CreateSimpleBattle(uint seed, const constString&in species1, "
|
Ensure(engine->RegisterGlobalFunction("Battle@ CreateSimpleBattle(uint seed, const constString&in species1, "
|
||||||
"const constString&in species2, uint8 level)",
|
"const constString&in species2, uint8 level)",
|
||||||
asFUNCTION(CreateSimpleBattle), asCALL_CDECL) >= 0);
|
asFUNCTION(CreateSimpleBattle), asCALL_CDECL) >= 0);
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
#ifndef POKEMONSCRIPTTESTER_MISCMOCKFUNCTIONS_HPP
|
#ifndef POKEMONSCRIPTTESTER_MISCMOCKFUNCTIONS_HPP
|
||||||
#define POKEMONSCRIPTTESTER_MISCMOCKFUNCTIONS_HPP
|
#define POKEMONSCRIPTTESTER_MISCMOCKFUNCTIONS_HPP
|
||||||
|
|
||||||
#include <PkmnLib/extern/angelscript_addons/scripthandle/scripthandle.h>
|
#include <scripthandle/scripthandle.h>
|
||||||
|
|
||||||
class MiscMockFunctions {
|
class MiscMockFunctions {
|
||||||
static CScriptHandle CreateMoveScript(const ArbUt::StringView& name) {
|
static CScriptHandle CreateMoveScript(const ArbUt::StringView& name) {
|
||||||
auto script = Globals::Library.GetValue()->GetScriptResolver()->LoadScript(ScriptCategory::Attack, name);
|
auto script =
|
||||||
|
Globals::Library.GetValue()->GetScriptResolver()->LoadScript(nullptr, ScriptCategory::Attack, name);
|
||||||
if (script != nullptr) {
|
if (script != nullptr) {
|
||||||
auto* ctx = asGetActiveContext();
|
auto* ctx = asGetActiveContext();
|
||||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
|
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
|
||||||
|
@ -25,7 +26,7 @@ class MiscMockFunctions {
|
||||||
|
|
||||||
auto move = Globals::Library.GetValue()->GetMoveLibrary()->TryGet(moveName);
|
auto move = Globals::Library.GetValue()->GetMoveLibrary()->TryGet(moveName);
|
||||||
if (!move.has_value()) {
|
if (!move.has_value()) {
|
||||||
return {};
|
THROW("Unknown move: ", moveName);
|
||||||
}
|
}
|
||||||
auto learnedMove =
|
auto learnedMove =
|
||||||
new PkmnLib::Battling::LearnedMove(move.value(), CreatureLib::Battling::AttackLearnMethod::Unknown);
|
new PkmnLib::Battling::LearnedMove(move.value(), CreatureLib::Battling::AttackLearnMethod::Unknown);
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
#ifndef POKEMONSCRIPTTESTER_POKEMONBUILDER_HPP
|
||||||
|
#define POKEMONSCRIPTTESTER_POKEMONBUILDER_HPP
|
||||||
|
#include <PkmnLib/Battling/Pokemon/CreatePokemon.hpp>
|
||||||
|
#include <angelscript.h>
|
||||||
|
|
||||||
|
class PokemonBuilderRegistration {
|
||||||
|
public:
|
||||||
|
static PkmnLib::Battling::CreatePokemon* CreatePokemonBuilder(const ArbUt::StringView& species, uint8_t level) {
|
||||||
|
auto* ctx = asGetActiveContext();
|
||||||
|
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
|
||||||
|
auto lib = Globals::Library.GetValue();
|
||||||
|
|
||||||
|
auto builder = new PkmnLib::Battling::CreatePokemon(lib, species, level);
|
||||||
|
env->AddGarbage(builder);
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PkmnLib::Battling::CreatePokemon& WithGenderWrapper(PkmnLib::Battling::CreatePokemon* builder, i32 gender) {
|
||||||
|
return builder->WithGender((CreatureLib::Library::Gender)gender);
|
||||||
|
}
|
||||||
|
|
||||||
|
static PkmnLib::Battling::Pokemon* BuildWrapper(PkmnLib::Battling::CreatePokemon* builder, u32 seed) {
|
||||||
|
auto rand = ArbUt::Random(seed);
|
||||||
|
auto p = builder->Build(rand);
|
||||||
|
auto* ctx = asGetActiveContext();
|
||||||
|
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
|
||||||
|
env->AddGarbage(p);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Register(AngelScriptResolver* resolver) {
|
||||||
|
auto engine = resolver->GetEngine();
|
||||||
|
Ensure(engine->RegisterObjectType("PokemonBuilder", 0, asOBJ_REF | asOBJ_NOCOUNT) >= 0);
|
||||||
|
Ensure(engine->RegisterGlobalFunction(
|
||||||
|
"PokemonBuilder@ CreatePokemonBuilder(const constString&in species, uint8 level)",
|
||||||
|
asFUNCTION(CreatePokemonBuilder), asCALL_CDECL) >= 0);
|
||||||
|
|
||||||
|
Ensure(engine->RegisterObjectMethod("PokemonBuilder", "PokemonBuilder@ WithForme(const constString&in forme)",
|
||||||
|
asMETHODPR(PkmnLib::Battling::CreatePokemon, WithForme,
|
||||||
|
(const ArbUt::StringView&), PkmnLib::Battling::CreatePokemon&),
|
||||||
|
asCALL_THISCALL));
|
||||||
|
Ensure(engine->RegisterObjectMethod("PokemonBuilder", "PokemonBuilder@ WithGender(Gender gender)",
|
||||||
|
asFUNCTION(WithGenderWrapper), asCALL_CDECL_OBJFIRST));
|
||||||
|
Ensure(engine->RegisterObjectMethod(
|
||||||
|
"PokemonBuilder", "PokemonBuilder@ IsShiny(bool value)",
|
||||||
|
asMETHODPR(PkmnLib::Battling::CreatePokemon, IsShiny, (bool), PkmnLib::Battling::CreatePokemon&),
|
||||||
|
asCALL_THISCALL));
|
||||||
|
Ensure(engine->RegisterObjectMethod("PokemonBuilder", "PokemonBuilder@ WithHeldItem(const constString&in item)",
|
||||||
|
asMETHODPR(PkmnLib::Battling::CreatePokemon, WithHeldItem,
|
||||||
|
(const ArbUt::StringView&), PkmnLib::Battling::CreatePokemon&),
|
||||||
|
asCALL_THISCALL));
|
||||||
|
Ensure(engine->RegisterObjectMethod(
|
||||||
|
"PokemonBuilder", "PokemonBuilder@ LearnMove(const constString&in move, MoveLearnMethod method)",
|
||||||
|
asMETHODPR(PkmnLib::Battling::CreatePokemon, LearnMove,
|
||||||
|
(const ArbUt::StringView&, CreatureLib::Battling::AttackLearnMethod),
|
||||||
|
PkmnLib::Battling::CreatePokemon&),
|
||||||
|
asCALL_THISCALL));
|
||||||
|
Ensure(engine->RegisterObjectMethod(
|
||||||
|
"PokemonBuilder",
|
||||||
|
"PokemonBuilder@ WithIndividualValues(uint8 hp,uint8 att,uint8 def,uint8 spa,uint8 spd,uint8 speed)",
|
||||||
|
asMETHODPR(PkmnLib::Battling::CreatePokemon, WithIndividualValues, (u8, u8, u8, u8, u8, u8),
|
||||||
|
PkmnLib::Battling::CreatePokemon&),
|
||||||
|
asCALL_THISCALL));
|
||||||
|
Ensure(engine->RegisterObjectMethod(
|
||||||
|
"PokemonBuilder",
|
||||||
|
"PokemonBuilder@ WithEffortValues(uint8 hp,uint8 att,uint8 def,uint8 spa,uint8 spd,uint8 speed)",
|
||||||
|
asMETHODPR(PkmnLib::Battling::CreatePokemon, WithEffortValues, (u8, u8, u8, u8, u8, u8),
|
||||||
|
PkmnLib::Battling::CreatePokemon&),
|
||||||
|
asCALL_THISCALL));
|
||||||
|
Ensure(engine->RegisterObjectMethod("PokemonBuilder", "PokemonBuilder@ WithNature(const constString&in nature)",
|
||||||
|
asMETHODPR(PkmnLib::Battling::CreatePokemon, WithNature,
|
||||||
|
(const ArbUt::StringView&), PkmnLib::Battling::CreatePokemon&),
|
||||||
|
asCALL_THISCALL));
|
||||||
|
Ensure(engine->RegisterObjectMethod("PokemonBuilder", "PokemonBuilder@ WithNickname(const string&in name)",
|
||||||
|
asMETHODPR(PkmnLib::Battling::CreatePokemon, WithNickname,
|
||||||
|
(const std::string&), PkmnLib::Battling::CreatePokemon&),
|
||||||
|
asCALL_THISCALL));
|
||||||
|
Ensure(engine->RegisterObjectMethod("PokemonBuilder", "Pokemon@ Build(uint seed = 0)", asFUNCTION(BuildWrapper),
|
||||||
|
asCALL_CDECL_OBJFIRST));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // POKEMONSCRIPTTESTER_POKEMONBUILDER_HPP
|
|
@ -26,7 +26,13 @@ public:
|
||||||
|
|
||||||
_env->CollectGarbage();
|
_env->CollectGarbage();
|
||||||
if (e == asEXECUTION_EXCEPTION) {
|
if (e == asEXECUTION_EXCEPTION) {
|
||||||
_errorMessage = ctx->GetExceptionString();
|
std::stringstream error;
|
||||||
|
const char* exceptionSection = "";
|
||||||
|
int exceptionColumn = 0;
|
||||||
|
auto exceptionLine = ctx->GetExceptionLineNumber(&exceptionColumn, &exceptionSection);
|
||||||
|
error << "[" << exceptionSection << ":" << exceptionLine << "," << exceptionColumn << "] "
|
||||||
|
<< ctx->GetExceptionString();
|
||||||
|
_errorMessage = error.str();
|
||||||
_result = TestResult::Failed;
|
_result = TestResult::Failed;
|
||||||
ctx->PopState();
|
ctx->PopState();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -6,6 +6,13 @@ struct TestEnvironment {
|
||||||
size_t FailedRequirements = 0;
|
size_t FailedRequirements = 0;
|
||||||
|
|
||||||
template <typename T> void AddGarbage(T* data) { _garbage.Append(GarbageObject(data)); }
|
template <typename T> void AddGarbage(T* data) { _garbage.Append(GarbageObject(data)); }
|
||||||
|
template <typename T> void TakeOwnershipOfGarbage(T* data) {
|
||||||
|
for (auto& g : _garbage) {
|
||||||
|
if (g.Ptr == data) {
|
||||||
|
g.Ptr = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CollectGarbage() {
|
void CollectGarbage() {
|
||||||
for (auto& o : _garbage) {
|
for (auto& o : _garbage) {
|
||||||
|
|
|
@ -34,9 +34,10 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i32 RunAll(bool waitForDebugger) {
|
i32 RunAll([[maybe_unused]]bool waitForDebugger) {
|
||||||
auto ctx = _scriptResolver->GetContextPool()->RequestContext();
|
auto ctx = _scriptResolver->GetContextPool()->RequestContext();
|
||||||
ctx->SetUserData(_scriptResolver->GetUserdata());
|
ctx->SetUserData(_scriptResolver->GetUserdata());
|
||||||
|
#if ANGELSCRIPT_DEBUGGER
|
||||||
_scriptResolver->SetDebugger(new AngelscriptDebugger());
|
_scriptResolver->SetDebugger(new AngelscriptDebugger());
|
||||||
auto& debugger = *_scriptResolver->GetDebugger().GetValue();
|
auto& debugger = *_scriptResolver->GetDebugger().GetValue();
|
||||||
debugger.Run(8684);
|
debugger.Run(8684);
|
||||||
|
@ -48,6 +49,7 @@ public:
|
||||||
}
|
}
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
for (auto& test : _tests) {
|
for (auto& test : _tests) {
|
||||||
test.second->Run(ctx);
|
test.second->Run(ctx);
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "Globals.hpp"
|
#include "Globals.hpp"
|
||||||
#include "Tester/AngelScript/BattleFunctions.hpp"
|
#include "Tester/AngelScript/BattleFunctions.hpp"
|
||||||
#include "Tester/AngelScript/MiscMockFunctions.hpp"
|
#include "Tester/AngelScript/MiscMockFunctions.hpp"
|
||||||
|
#include "Tester/AngelScript/PokemonBuilder.hpp"
|
||||||
#include "Tester/AngelScript/TestFunctions.hpp"
|
#include "Tester/AngelScript/TestFunctions.hpp"
|
||||||
#include "Tester/TestRunner.hpp"
|
#include "Tester/TestRunner.hpp"
|
||||||
#include "git.h"
|
#include "git.h"
|
||||||
|
@ -23,7 +24,8 @@ int main(int argc, char** argv) {
|
||||||
{"workdir"});
|
{"workdir"});
|
||||||
args::Flag logTimeFlag(parser, "time-log", "Whether to show time logging.", {'t', "time-log"});
|
args::Flag logTimeFlag(parser, "time-log", "Whether to show time logging.", {'t', "time-log"});
|
||||||
args::Flag forceColorFlag(parser, "force-color", "Whether to force color text output.", {'c', "force-color"});
|
args::Flag forceColorFlag(parser, "force-color", "Whether to force color text output.", {'c', "force-color"});
|
||||||
args::Flag waitForDebuggerFlag(parser, "wait-for-debugger", "Whether to wait until a debugger is connected or not.", {'w', "wait-for-debugger"});
|
args::Flag waitForDebuggerFlag(parser, "wait-for-debugger", "Whether to wait until a debugger is connected or not.",
|
||||||
|
{'w', "wait-for-debugger"});
|
||||||
try {
|
try {
|
||||||
parser.ParseCLI(argc, argv);
|
parser.ParseCLI(argc, argv);
|
||||||
} catch (args::Help&) {
|
} catch (args::Help&) {
|
||||||
|
@ -44,7 +46,7 @@ int main(int argc, char** argv) {
|
||||||
if (!workingDirectory.empty()) {
|
if (!workingDirectory.empty()) {
|
||||||
chdir((const char*)std::filesystem::path(workingDirectory).c_str());
|
chdir((const char*)std::filesystem::path(workingDirectory).c_str());
|
||||||
}
|
}
|
||||||
if (forceColorFlag.Get()){
|
if (forceColorFlag.Get()) {
|
||||||
termcolor::colorize(std::cout);
|
termcolor::colorize(std::cout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +58,7 @@ int main(int argc, char** argv) {
|
||||||
TestFunctions::Register(scriptResolver);
|
TestFunctions::Register(scriptResolver);
|
||||||
BattleFunctions::Register(scriptResolver);
|
BattleFunctions::Register(scriptResolver);
|
||||||
MiscMockFunctions::Register(scriptResolver);
|
MiscMockFunctions::Register(scriptResolver);
|
||||||
|
PokemonBuilderRegistration::Register(scriptResolver);
|
||||||
};
|
};
|
||||||
|
|
||||||
Globals::Library = BuildLibrary::Build("", initialize);
|
Globals::Library = BuildLibrary::Build("", initialize);
|
||||||
|
|
Loading…
Reference in New Issue