Fixes narray::Length not being a property in angelscript.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2021-09-25 18:33:12 +02:00
parent 9fd88f6192
commit 1e10d25dbd
2 changed files with 11 additions and 2 deletions

View File

@@ -11,14 +11,17 @@
static std::unordered_map<const char*, const char*> _scripts = std::unordered_map<const char*, const char*>{
AS_CLASS(blankScript, ),
AS_CLASS(initializeScript, R"(
uint64 length = 0;
bool boolValue = false;
int64 intValue = 0;
constString stringValue;
void OnInitialize(const narray<EffectParameter@>@ parameters) override {
length = parameters.Length;
boolValue = parameters[0].AsBool();
intValue = parameters[1].AsInt();
stringValue = parameters[2].AsString();
}
uint64 GetLength() { return length; }
bool GetBoolValue() { return boolValue; }
int64 GetIntValue() { return intValue; }
constString GetStringValue() { return stringValue; }
@@ -138,8 +141,14 @@ TEST_CASE("Invoke OnInitialize script function") {
script->OnInitialize(parameters);
auto ctxPool = script->GetContextPool();
auto ctx = ctxPool->RequestContext();
auto ctx = ctxPool->RequestContext();
script->PrepareMethod("GetLength"_cnc, ctx);
REQUIRE(ctx->Execute() == asEXECUTION_FINISHED);
REQUIRE_EQ((uint64_t)ctx->GetReturnQWord(), 3);
ctxPool->ReturnContextToPool(ctx);
ctx = ctxPool->RequestContext();
script->PrepareMethod("GetBoolValue"_cnc, ctx);
REQUIRE(ctx->Execute() == asEXECUTION_FINISHED);
REQUIRE((bool)ctx->GetReturnDWord());