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

Function Test2

sdk/tests/test_feature/source/test_arrayobject.cpp:340–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

338
339
340bool Test2()
341{
342 int nRet;
343 bool fail = false;
344 COutStream out;
345
346 asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
347 engine->SetMessageCallback(asMETHOD(COutStream, Callback), &out, asCALL_THISCALL);
348 RegisterScriptArray(engine, true);
349
350 nRet = engine->RegisterObjectType("Value", sizeof(Value), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CK); assert( nRet >= 0 );
351
352 nRet = engine->RegisterObjectType("A", sizeof(A), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CK); assert( nRet >= 0 );
353 nRet = engine->RegisterObjectMethod("A", "Value &opIndex(int)", asMETHODPR(A, operator[], (int ), Value &), asCALL_THISCALL); assert( nRet >= 0 );
354 nRet = engine->RegisterObjectType("A[]", sizeof(AArray), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CK); assert( nRet >= 0 );
355 nRet = engine->RegisterObjectMethod("A[]", "A opIndex( int )", asMETHODPR(AArray, operator[], (int ), A), asCALL_THISCALL); assert( nRet >= 0 );
356 nRet = engine->RegisterObjectType("A[][]", sizeof(AArrayArray), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CK); assert( nRet >= 0 );
357 nRet = engine->RegisterObjectMethod("A[][]", "A[] opIndex(int)", asMETHODPR(AArrayArray, operator[], (int ), AArray), asCALL_THISCALL); assert( nRet >= 0 );
358
359 nRet = ExecuteString(engine, "A[][] f;"); assert( nRet >= 0 );
360 nRet = ExecuteString(engine, "A[][] f; f[0];"); assert( nRet >= 0 );
361 nRet = ExecuteString(engine, "A[][] f; f[0][0];"); assert( nRet >= 0 );
362 nRet = ExecuteString(engine, "A[][] f; f[0][0][0];"); assert( nRet >= 0 );
363
364 engine->Release();
365
366 return fail;
367}
368
369} // namespace
370

Callers 1

TestFunction · 0.70

Calls 5

RegisterScriptArrayFunction · 0.85
ExecuteStringFunction · 0.85
SetMessageCallbackMethod · 0.80
RegisterObjectMethodMethod · 0.80
ReleaseMethod · 0.45

Tested by

no test coverage detected