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

Function Test2

sdk/tests/test_feature/source/test_object.cpp:290–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288}
289
290bool Test2()
291{
292 bool fail = false;
293
294 int r;
295 CBufferedOutStream bout;
296 asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
297 engine->SetMessageCallback(asMETHOD(CBufferedOutStream, Callback), &bout, asCALL_THISCALL);
298 r = engine->RegisterObjectType("Creep", sizeof(Creep), asOBJ_VALUE | asOBJ_APP_CLASS); assert( r >= 0 );
299 r = engine->RegisterObjectBehaviour("Creep", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(dummy), asCALL_CDECL_OBJLAST); assert( r >= 0 );
300 r = engine->RegisterObjectBehaviour("Creep", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(dummy), asCALL_CDECL_OBJLAST); assert( r >= 0 );
301
302 // Must not allow a value type to be declared as object handle
303 const char *script = "void Test(Creep @c) {}";
304 asIScriptModule *mod = engine->GetModule("mod", asGM_ALWAYS_CREATE);
305 mod->AddScriptSection("script", script);
306 r = mod->Build();
307 if( r >= 0 )
308 {
309 TEST_FAILED;
310 }
311 if( bout.buffer != "script (1, 17) : Error : Object handle is not supported for this type\n" )
312 {
313 TEST_FAILED;
314 PRINTF("%s", bout.buffer.c_str());
315 }
316
317 engine->Release();
318
319 return fail;
320}
321
322} // namespace
323

Callers 1

TestFunction · 0.70

Calls 6

SetMessageCallbackMethod · 0.80
AddScriptSectionMethod · 0.80
GetModuleMethod · 0.45
BuildMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected