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

Function Test

sdk/tests/test_performance/source/test_basic.cpp:73–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73void Test(double *testTime)
74{
75 asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
76 COutStream out;
77 engine->SetMessageCallback(asMETHOD(COutStream,Callback), &out, asCALL_THISCALL);
78 engine->RegisterGlobalFunction("float Average(float, float)", asFUNCTION(Average), asCALL_CDECL);
79
80 asIScriptModule *mod = engine->GetModule(0, asGM_ALWAYS_CREATE);
81 mod->AddScriptSection(TESTNAME, script, strlen(script), 0);
82 mod->Build();
83
84#ifndef _DEBUG
85 asIScriptContext *ctx = engine->CreateContext();
86 ctx->Prepare(mod->GetFunctionByDecl("int TestBasic()"));
87
88 double time = GetSystemTimer();
89
90 int r = ctx->Execute();
91
92 time = GetSystemTimer() - time;
93
94 if( r != 0 )
95 {
96 printf("Execution didn't terminate with asEXECUTION_FINISHED\n");
97 if( r == asEXECUTION_EXCEPTION )
98 {
99 printf("Script exception\n");
100 asIScriptFunction *func = ctx->GetExceptionFunction();
101 printf("Func: %s\n", func->GetName());
102 printf("Line: %d\n", ctx->GetExceptionLineNumber());
103 printf("Desc: %s\n", ctx->GetExceptionString());
104 }
105 }
106 else
107 *testTime = time;
108
109 ctx->Release();
110#endif
111 engine->Release();
112}
113
114} // namespace
115

Callers

nothing calls this directly

Calls 15

SetMessageCallbackMethod · 0.80
AddScriptSectionMethod · 0.80
CreateContextMethod · 0.80
GetFunctionByDeclMethod · 0.80
ExecuteMethod · 0.80
GetExceptionFunctionMethod · 0.80
GetExceptionStringMethod · 0.80
GetSystemTimerFunction · 0.70
GetModuleMethod · 0.45
BuildMethod · 0.45

Tested by

no test coverage detected