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

Function TestModuleRef

sdk/tests/test_feature/source/testmoduleref.cpp:12–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10static const char *script = "int global; void Test() {global = 0;}";
11
12bool TestModuleRef()
13{
14 bool fail = false;
15
16 asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
17
18 asIScriptModule *mod = engine->GetModule("a", asGM_ALWAYS_CREATE);
19 mod->AddScriptSection("script", script);
20 if( mod->Build() < 0 )
21 {
22 PRINTF("%s: failed to build module a\n", TESTNAME);
23 TEST_FAILED;
24 }
25
26 asIScriptFunction *func = engine->GetModule("a")->GetFunctionByDecl("void Test()");
27 asIScriptContext *ctx = engine->CreateContext();
28 ctx->Prepare(func);
29
30 if( engine->GetModule("a")->GetFunctionCount() < 0 )
31 {
32 PRINTF("%s: Failed to get function count\n", TESTNAME);
33 TEST_FAILED;
34 }
35
36 engine->DiscardModule("a");
37 if( engine->GetModule("a") )
38 {
39 PRINTF("%s: Module was not discarded\n", TESTNAME);
40 TEST_FAILED;
41 }
42
43 int r = ctx->Execute();
44 if( r != asEXECUTION_FINISHED )
45 {
46 PRINTF("%s: Execution failed\n", TESTNAME);
47 TEST_FAILED;
48 }
49
50 ctx->Release();
51
52 engine->Release();
53
54 return fail;
55}

Callers 1

allTestsFunction · 0.85

Calls 10

AddScriptSectionMethod · 0.80
GetFunctionByDeclMethod · 0.80
CreateContextMethod · 0.80
GetFunctionCountMethod · 0.80
DiscardModuleMethod · 0.80
ExecuteMethod · 0.80
GetModuleMethod · 0.45
BuildMethod · 0.45
PrepareMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected