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

Function Test2

sdk/tests/test_feature/source/test_dynamicconfig.cpp:795–859  ·  view source on GitHub ↗

This test was reported by Zeu5 on 2009-03-24 It used to crash on the second call to Build(), and also on ExecuteString()

Source from the content-addressed store, hash-verified

793// This test was reported by Zeu5 on 2009-03-24
794// It used to crash on the second call to Build(), and also on ExecuteString()
795bool Test2()
796{
797 bool fail = false;
798 int r;
799
800 asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
801 engine->BeginConfigGroup("MyGroup");
802 engine->RegisterInterface("MyHostDefinedInterface");
803 engine->RegisterInterfaceMethod("MyHostDefinedInterface", "void doSomething()");
804 engine->EndConfigGroup();
805
806 const char *script = "class MyScriptedClass : MyHostDefinedInterface\n"
807 "{\n"
808 " void doSomething() { /* nothing */ }\n"
809 "} \n"
810 "void Test() \n"
811 "{ \n"
812 " MyScriptedClass @b = MyScriptedClass(); \n"
813 "} \n";
814
815 asIScriptModule *mod = engine->GetModule(0, asGM_ALWAYS_CREATE);
816 mod->AddScriptSection("script", script);
817 r = mod->Build();
818 if( r < 0 )
819 {
820 TEST_FAILED;
821 }
822
823 r = ExecuteString(engine, "Test()", mod);
824 if( r != asEXECUTION_FINISHED )
825 {
826 TEST_FAILED;
827 }
828
829 engine->DiscardModule(0);
830 r = engine->RemoveConfigGroup("MyGroup");
831 if( r < 0 )
832 {
833 TEST_FAILED;
834 }
835
836 // Now do everything again
837 engine->BeginConfigGroup("MyGroup");
838 engine->RegisterInterface("MyHostDefinedInterface");
839 engine->RegisterInterfaceMethod("MyHostDefinedInterface", "void doSomething()");
840 engine->EndConfigGroup();
841
842 mod = engine->GetModule(0, asGM_ALWAYS_CREATE);
843 mod->AddScriptSection("script", script);
844 r = mod->Build();
845 if( r < 0 )
846 {
847 TEST_FAILED;
848 }
849
850 r = ExecuteString(engine, "Test()", mod);
851 if( r != asEXECUTION_FINISHED )
852 {

Callers 1

TestFunction · 0.70

Calls 11

ExecuteStringFunction · 0.85
BeginConfigGroupMethod · 0.80
EndConfigGroupMethod · 0.80
AddScriptSectionMethod · 0.80
DiscardModuleMethod · 0.80
RemoveConfigGroupMethod · 0.80
RegisterInterfaceMethod · 0.45
GetModuleMethod · 0.45
BuildMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected