| 138 | } |
| 139 | |
| 140 | bool Test() |
| 141 | { |
| 142 | RET_ON_MAX_PORT |
| 143 | |
| 144 | bool fail = false; |
| 145 | |
| 146 | asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); |
| 147 | RegisterScriptArray(engine, true); |
| 148 | RegisterStdString(engine); |
| 149 | |
| 150 | engine->RegisterGlobalFunction("int a_int()", asFUNCTION(a_int), asCALL_CDECL); |
| 151 | engine->RegisterGlobalFunction("int b_int()", asFUNCTION(b_int), asCALL_CDECL); |
| 152 | engine->RegisterGlobalFunction("string a_str()", asFUNCTION(a_str), asCALL_CDECL); |
| 153 | engine->RegisterGlobalFunction("string b_str()", asFUNCTION(b_str), asCALL_CDECL); |
| 154 | |
| 155 | engine->RegisterGlobalFunction("int &b_intref()", asFUNCTION(b_intref), asCALL_CDECL); |
| 156 | engine->RegisterGlobalFunction("string &b_strref()", asFUNCTION(b_strref), asCALL_CDECL); |
| 157 | |
| 158 | engine->RegisterGlobalFunction("string &complex(string &out)", asFUNCTION(complex), asCALL_CDECL); |
| 159 | engine->RegisterGlobalFunction("string &complex2()", asFUNCTION(complex2), asCALL_CDECL); |
| 160 | engine->RegisterGlobalFunction("int &complex3(string &out)", asFUNCTION(complex3), asCALL_CDECL); |
| 161 | |
| 162 | string str; |
| 163 | engine->RegisterGlobalProperty("string str", &str); |
| 164 | |
| 165 | engine->RegisterObjectType("prop", sizeof(CProp), asOBJ_REF); |
| 166 | engine->RegisterObjectBehaviour("prop", asBEHAVE_ADDREF, "void f()", asMETHOD(CProp, AddRef), asCALL_THISCALL); |
| 167 | engine->RegisterObjectBehaviour("prop", asBEHAVE_RELEASE, "void f()", asMETHOD(CProp, Release), asCALL_THISCALL); |
| 168 | engine->RegisterObjectMethod("prop", "void Get(string &out)", asMETHOD(CProp,Get), asCALL_THISCALL); |
| 169 | engine->RegisterGlobalFunction("prop @GetProp(string &in)", asFUNCTION(GetProp), asCALL_CDECL); |
| 170 | |
| 171 | COutStream out; |
| 172 | |
| 173 | asIScriptModule *mod = engine->GetModule(0, asGM_ALWAYS_CREATE); |
| 174 | mod->AddScriptSection("1", script1); |
| 175 | mod->AddScriptSection("2", script2); |
| 176 | mod->AddScriptSection("3", script3); |
| 177 | mod->AddScriptSection("4", script4); |
| 178 | mod->AddScriptSection("5", script5); |
| 179 | engine->SetMessageCallback(asMETHOD(COutStream,Callback), &out, asCALL_THISCALL); |
| 180 | mod->Build(); |
| 181 | |
| 182 | |
| 183 | // Verify order of calculations |
| 184 | output = ""; |
| 185 | ExecuteString(engine, "a_str() + b_str()", mod); |
| 186 | if( output != "ab" ) TEST_FAILED; |
| 187 | |
| 188 | output = ""; |
| 189 | ExecuteString(engine, "b_strref() = a_str()", mod); |
| 190 | if( output != "ab" ) TEST_FAILED; |
| 191 | |
| 192 | output = ""; |
| 193 | ExecuteString(engine, "b_strref() += a_str()", mod); |
| 194 | if( output != "ab" ) TEST_FAILED; |
| 195 | |
| 196 | output = ""; |
| 197 | ExecuteString(engine, "a_int() + b_int()", mod); |
nothing calls this directly
no test coverage detected