This test was reported by Zeu5 on 2009-03-24 It used to crash on the second call to Build(), and also on ExecuteString()
| 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() |
| 795 | bool 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 | { |
no test coverage detected