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

Function Test

sdk/tests/test_feature/source/test_scriptmath.cpp:33–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31
32
33bool Test()
34{
35 bool fail = false;
36 COutStream out;
37 int r;
38
39 //----------------------
40 // Make sure the native interface works (where supported)
41 asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
42 engine->SetMessageCallback(asMETHOD(COutStream,Callback), &out, asCALL_THISCALL);
43 RegisterScriptMath(engine);
44
45 engine->RegisterGlobalFunction("void assert(bool)", asFUNCTION(Assert), asCALL_GENERIC);
46
47 asIScriptModule *mod = engine->GetModule(0, asGM_ALWAYS_CREATE);
48 mod->AddScriptSection("script", script, strlen(script));
49 r = mod->Build();
50 if( r < 0 )
51 TEST_FAILED;
52
53 r = ExecuteString(engine, "test()", mod);
54 if( r != asEXECUTION_FINISHED )
55 TEST_FAILED;
56
57 engine->Release();
58
59 //------------------
60 // Make sure the generic interface works as well
61 engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
62 RegisterScriptMath_Generic(engine);
63
64 engine->RegisterGlobalFunction("void assert(bool)", asFUNCTION(Assert), asCALL_GENERIC);
65
66 mod = engine->GetModule(0, asGM_ALWAYS_CREATE);
67 mod->AddScriptSection("script", script, strlen(script));
68 r = mod->Build();
69 if( r < 0 )
70 TEST_FAILED;
71
72 r = ExecuteString(engine, "test()", mod);
73 if( r != asEXECUTION_FINISHED )
74 TEST_FAILED;
75
76 engine->Release();
77
78 return fail;
79}
80
81} // namespace
82

Callers

nothing calls this directly

Calls 9

RegisterScriptMathFunction · 0.85
ExecuteStringFunction · 0.85
SetMessageCallbackMethod · 0.80
AddScriptSectionMethod · 0.80
GetModuleMethod · 0.45
BuildMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected