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

Function Test

sdk/tests/test_feature/source/test_scriptclassmethod.cpp:157–527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157bool Test()
158{
159 bool fail = false;
160 int r;
161 asIScriptEngine *engine;
162 COutStream out;
163 CBufferedOutStream bout;
164
165 // Test conflicting method name and class name with scoping
166 // https://www.gamedev.net/topic/679898-cant-call-base-function-if-the-function-name-is-the-same-as-a-class-name/
167 {
168 engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
169 engine->SetMessageCallback(asMETHOD(CBufferedOutStream, Callback), &bout, asCALL_THISCALL);
170 bout.buffer = "";
171
172 asIScriptModule *mod = engine->GetModule("test", asGM_ALWAYS_CREATE);
173 mod->AddScriptSection("test",
174 "class Cat \n"
175 "{ \n"
176 "} \n"
177 "class Foo \n"
178 "{ \n"
179 " int Cat() \n" // Method has the same name as another class
180 " { \n"
181 " return 0; \n"
182 " } \n"
183 " int Dog() \n" // No name conflict
184 " { \n"
185 " return 0; \n"
186 " } \n"
187 "} \n"
188 "class Bar : Foo \n"
189 "{ \n"
190 " int Cat() override \n"
191 " { \n"
192 " return Foo::Cat(); \n" // Calling method 'Cat' on parent class 'Foo'
193 " } \n"
194 " int Dog() override \n"
195 " { \n"
196 " return Foo::Dog(); \n" // OK
197 " } \n"
198 "} \n");
199 r = mod->Build();
200 if (r < 0)
201 TEST_FAILED;
202
203 if (bout.buffer != "")
204 {
205 PRINTF("%s", bout.buffer.c_str());
206 TEST_FAILED;
207 }
208
209 engine->ShutDownAndRelease();
210 }
211
212 {
213 engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
214

Callers

nothing calls this directly

Calls 15

RegisterScriptAnyFunction · 0.85
ExecuteStringFunction · 0.85
GetExceptionInfoFunction · 0.85
SetMessageCallbackMethod · 0.80
AddScriptSectionMethod · 0.80
ShutDownAndReleaseMethod · 0.80
CreateContextMethod · 0.80
CreateScriptObjectMethod · 0.80
GetPropertyNameMethod · 0.80
GetAddressOfPropertyMethod · 0.80
SetObjectMethod · 0.80

Tested by

no test coverage detected