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

Function Test

sdk/tests/test_feature/source/test_addon_scriptgrid.cpp:9–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7{
8
9bool Test()
10{
11 RET_ON_MAX_PORT
12
13 bool fail = false;
14 int r;
15 COutStream out;
16 CBufferedOutStream bout;
17// asIScriptContext *ctx;
18 asIScriptEngine *engine;
19// asIScriptModule *mod;
20
21 // Test circular reference between grid and ref
22 {
23 engine = asCreateScriptEngine();
24 engine->SetMessageCallback(asMETHOD(COutStream, Callback), &out, asCALL_THISCALL);
25 RegisterScriptHandle(engine);
26 RegisterScriptGrid(engine);
27
28 // Create the circular reference
29 r = ExecuteString(engine, "grid<ref> a; a.resize(1,1); @a[0,0] = a;");
30 if (r != asEXECUTION_FINISHED)
31 TEST_FAILED;
32
33 engine->GarbageCollect();
34
35 asUINT currSize, totDestroy, totDetect;
36 engine->GetGCStatistics(&currSize, &totDestroy, &totDetect);
37 if (currSize != 0 || totDestroy != 1 || totDetect != 1)
38 TEST_FAILED;
39
40 engine->ShutDownAndRelease();
41 }
42
43 // Test empty initialization list
44 // http://www.gamedev.net/topic/658849-empty-array-initialization/
45 {
46 engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
47 engine->SetMessageCallback(asMETHOD(COutStream, Callback), &out, asCALL_THISCALL);
48
49 RegisterScriptGrid(engine);
50
51 r = ExecuteString(engine, "grid<int> a = {};"); // Valid 0x0 grid
52 if( r != asEXECUTION_FINISHED )
53 TEST_FAILED;
54
55 r = ExecuteString(engine, "grid<int> a = {{}};"); // Valid 0x1 grid
56 if( r != asEXECUTION_FINISHED )
57 TEST_FAILED;
58
59 r = ExecuteString(engine, "grid<int> a = {{},{}};"); // Valid 0x2 grid
60 if( r != asEXECUTION_FINISHED )
61 TEST_FAILED;
62
63 engine->Release();
64 }
65
66 // Test grid object forcibly destroyed by garbage collector

Callers

nothing calls this directly

Calls 15

RegisterScriptHandleFunction · 0.85
RegisterScriptGridFunction · 0.85
ExecuteStringFunction · 0.85
RegisterScriptAnyFunction · 0.85
RegisterScriptArrayFunction · 0.85
RegisterStdStringFunction · 0.85
SetMessageCallbackMethod · 0.80
GetGCStatisticsMethod · 0.80
ShutDownAndReleaseMethod · 0.80
AddScriptSectionMethod · 0.80
GetFlagsMethod · 0.80

Tested by

no test coverage detected