MCPcopy Create free account
hub / github.com/anjo76/angelscript / Test

Function Test

sdk/tests/test_feature/source/test_debug.cpp:333–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

331}
332
333bool Test()
334{
335 int r;
336 bool fail = Test2();
337
338 // Test GetAddressOfVar for object variables whose stack position is reused in multiple scopes
339 // Reported by Paril
340 SKIP_ON_MAX_PORT
341 {
342 asIScriptEngine* engine = asCreateScriptEngine();
343 CBufferedOutStream bout;
344 engine->SetMessageCallback(asMETHOD(CBufferedOutStream, Callback), &bout, asCALL_THISCALL);
345 bout.buffer = "";
346
347 engine->RegisterObjectType("vec3_t", sizeof(vec3_t), asOBJ_VALUE | asOBJ_POD);
348 engine->RegisterObjectBehaviour("vec3_t", asBEHAVE_CONSTRUCT, "void vec3_t(float, float, float)", asFUNCTION(vec3_fff), asCALL_CDECL_OBJLAST);
349 engine->RegisterObjectBehaviour("vec3_t", asBEHAVE_CONSTRUCT, "void vec3_t(const vec3_t &in)", asFUNCTION(vec3_v3), asCALL_CDECL_OBJLAST);
350 engine->RegisterObjectProperty("vec3_t", "float x", asOFFSET(vec3_t, x));
351 engine->RegisterObjectProperty("vec3_t", "float y", asOFFSET(vec3_t, y));
352 engine->RegisterObjectProperty("vec3_t", "float z", asOFFSET(vec3_t, z));
353
354
355 asIScriptModule* mod = engine->GetModule("test", asGM_ALWAYS_CREATE);
356 mod->AddScriptSection("test", R"script(
357void Test(vec3_t v)
358{
359 vec3_t a, b, c;
360
361 v.x = 50 + b.x + a.x + c.x;
362}
363
364bool Check() { return true; }
365
366void main(bool is_cgame)
367{
368 vec3_t(1, 2, 3);
369 vec3_t(1, 2, 3);
370
371 {
372 vec3_t test_a(1,2,3);
373 test_a.x++;
374 }
375
376 if (Check())
377 {
378 if (!is_cgame)
379 {
380 vec3_t test(3,2,1);
381 Test(test);
382 }
383 }
384}
385)script");
386 r = mod->Build();
387 if (r < 0)
388 TEST_FAILED;
389
390 printBuffer = "";

Callers

nothing calls this directly

Calls 15

SetMessageCallbackMethod · 0.80
AddScriptSectionMethod · 0.80
CreateContextMethod · 0.80
SetLineCallbackMethod · 0.80
SetExceptionCallbackMethod · 0.80
GetFunctionByDeclMethod · 0.80
SetArgByteMethod · 0.80
ExecuteMethod · 0.80
ShutDownAndReleaseMethod · 0.80
Test2Function · 0.70

Tested by

no test coverage detected