| 71 | } |
| 72 | |
| 73 | void 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 |
nothing calls this directly
no test coverage detected