| 22 | static asIScriptEngine *engine; |
| 23 | |
| 24 | bool TestExecuteScript() |
| 25 | { |
| 26 | bool fail = false; |
| 27 | COutStream out; |
| 28 | |
| 29 | engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); |
| 30 | engine->SetMessageCallback(asMETHOD(COutStream,Callback), &out, asCALL_THISCALL); |
| 31 | |
| 32 | RegisterStdString(engine); |
| 33 | engine->RegisterGlobalFunction("void assert(bool)", asFUNCTION(Assert), asCALL_GENERIC); |
| 34 | |
| 35 | CScriptBuilder builder; |
| 36 | |
| 37 | int r = builder.StartNewModule(engine, 0); |
| 38 | if( r >= 0 ) |
| 39 | r = builder.AddSectionFromFile("scripts/TestExecuteScript.as"); |
| 40 | if( r >= 0 ) |
| 41 | r = builder.BuildModule(); |
| 42 | if( r >= 0 ) |
| 43 | { |
| 44 | fail = ExecuteScript(); |
| 45 | } |
| 46 | |
| 47 | // Create a second engine before releasing the first |
| 48 | asIScriptEngine *en2 = asCreateScriptEngine(ANGELSCRIPT_VERSION); |
| 49 | |
| 50 | engine->Release(); |
| 51 | engine = NULL; |
| 52 | |
| 53 | // Release the second engine after the first |
| 54 | en2->Release(); |
| 55 | |
| 56 | return fail; |
| 57 | } |
| 58 | |
| 59 | |
| 60 | static bool ExecuteScript() |
no test coverage detected