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

Function Test

sdk/tests/test_multithread/source/test_sharedstring.cpp:32–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32bool Test()
33{
34 bool fail = false;
35
36 engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
37
38 COutStream out;
39 engine->SetMessageCallback(asMETHOD(COutStream,Callback),&out,asCALL_THISCALL);
40
41 asIScriptModule *mod = engine->GetModule(0, asGM_ALWAYS_CREATE);
42 mod->AddScriptSection(TESTNAME, script, strlen(script), 0);
43 mod->Build();
44
45 // Get a function declaration, this should be the same after the other thread terminates
46 asIScriptFunction *func = mod->GetFunctionByIndex(0);
47 const char *str = func->GetDeclaration();
48
49 // Create the second thread that in turn will get the declaration of another function
50 HANDLE threadId = (HANDLE)_beginthread(Thread, 0, 0);
51
52 // Make sure the other thread completes execution
53 WaitForSingleObject(threadId, INFINITE);
54
55 // Verify that the string we retrieved before is still the same
56 if( strcmp(str, "void TestSharedString1()") != 0 )
57 {
58 printf("%s: Shared strings don't work as they should\n", TESTNAME);
59 fail = true;
60 }
61
62 engine->Release();
63
64 // Success
65 return fail;
66}
67
68} // namespace
69

Callers

nothing calls this directly

Calls 7

SetMessageCallbackMethod · 0.80
AddScriptSectionMethod · 0.80
GetFunctionByIndexMethod · 0.80
GetDeclarationMethod · 0.80
GetModuleMethod · 0.45
BuildMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected