| 10 | static const char *script = "int global; void Test() {global = 0;} float Test2() {Test(); return 0;}"; |
| 11 | |
| 12 | bool Test2Modules() |
| 13 | { |
| 14 | bool fail = false; |
| 15 | int r; |
| 16 | |
| 17 | asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); |
| 18 | |
| 19 | asIScriptModule *mod = engine->GetModule("a", asGM_ALWAYS_CREATE); |
| 20 | mod->AddScriptSection("script", script, strlen(script), 0); |
| 21 | if( mod->Build() < 0 ) |
| 22 | { |
| 23 | PRINTF("%s: failed to build module a\n", TESTNAME); |
| 24 | TEST_FAILED; |
| 25 | } |
| 26 | |
| 27 | mod = engine->GetModule("b", asGM_ALWAYS_CREATE); |
| 28 | mod->AddScriptSection("script", script, strlen(script), 0); |
| 29 | if( mod->Build() < 0 ) |
| 30 | { |
| 31 | PRINTF("%s: failed to build module b\n", TESTNAME); |
| 32 | TEST_FAILED; |
| 33 | } |
| 34 | |
| 35 | if( !fail ) |
| 36 | { |
| 37 | asIScriptFunction *aFunc = engine->GetModule("a")->GetFunctionByName("Test"); |
| 38 | if( aFunc == 0 ) |
| 39 | { |
| 40 | PRINTF("%s: failed to retrieve func ID for module a\n", TESTNAME); |
| 41 | TEST_FAILED; |
| 42 | } |
| 43 | |
| 44 | asIScriptFunction *bFunc = engine->GetModule("b")->GetFunctionByName("Test"); |
| 45 | if( bFunc == 0 ) |
| 46 | { |
| 47 | PRINTF("%s: failed to retrieve func ID for module b\n", TESTNAME); |
| 48 | TEST_FAILED; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | engine->Release(); |
| 53 | |
| 54 | // Test using an object created in another module |
| 55 | engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); |
| 56 | engine->RegisterInterface("ITest"); |
| 57 | engine->RegisterInterfaceMethod("ITest", "void test()"); |
| 58 | const char *scriptA = "ITest @obj;"; |
| 59 | const char *scriptB = |
| 60 | "class CTest : ITest \n" |
| 61 | "{ \n" |
| 62 | " void test() {glob = 42;} \n" |
| 63 | "} \n" |
| 64 | "int glob = 0; \n"; |
| 65 | |
| 66 | mod = engine->GetModule("a", asGM_ALWAYS_CREATE); |
| 67 | mod->AddScriptSection("scriptA", scriptA, strlen(scriptA)); |
| 68 | r = mod->Build(); |
| 69 | if( r < 0 ) TEST_FAILED; |
no test coverage detected