| 216 | |
| 217 | |
| 218 | void Test(double *testTime) |
| 219 | { |
| 220 | asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); |
| 221 | COutStream out; |
| 222 | engine->SetMessageCallback(asMETHOD(COutStream,Callback), &out, asCALL_THISCALL); |
| 223 | |
| 224 | RegisterScriptString2(engine); |
| 225 | |
| 226 | asIScriptModule *mod = engine->GetModule(0, asGM_ALWAYS_CREATE); |
| 227 | mod->AddScriptSection(TESTNAME, script, strlen(script), 0); |
| 228 | int r = mod->Build(); |
| 229 | if( r >= 0 ) |
| 230 | { |
| 231 | #ifndef _DEBUG |
| 232 | asIScriptContext *ctx = engine->CreateContext(); |
| 233 | ctx->Prepare(mod->GetFunctionByDecl("void TestStringP()")); |
| 234 | |
| 235 | double time = GetSystemTimer(); |
| 236 | |
| 237 | r = ctx->Execute(); |
| 238 | |
| 239 | time = GetSystemTimer() - time; |
| 240 | |
| 241 | if( r != 0 ) |
| 242 | { |
| 243 | printf("Execution didn't terminate with asEXECUTION_FINISHED\n"); |
| 244 | if( r == asEXECUTION_EXCEPTION ) |
| 245 | { |
| 246 | printf("Script exception\n"); |
| 247 | asIScriptFunction *func = ctx->GetExceptionFunction(); |
| 248 | printf("Func: %s\n", func->GetName()); |
| 249 | printf("Line: %d\n", ctx->GetExceptionLineNumber()); |
| 250 | printf("Desc: %s\n", ctx->GetExceptionString()); |
| 251 | } |
| 252 | } |
| 253 | else |
| 254 | *testTime = time; |
| 255 | |
| 256 | ctx->Release(); |
| 257 | #endif |
| 258 | } |
| 259 | else |
| 260 | printf("Build failed\n"); |
| 261 | engine->Release(); |
| 262 | |
| 263 | // Clean up the string pool |
| 264 | for( asUINT n = 0; n < pool.size(); n++ ) |
| 265 | delete pool[n]; |
| 266 | pool.clear(); |
| 267 | } |
| 268 | |
| 269 | } // namespace |
| 270 |
nothing calls this directly
no test coverage detected