| 2512 | } |
| 2513 | |
| 2514 | bool Test2() |
| 2515 | { |
| 2516 | bool fail = false; |
| 2517 | COutStream out; |
| 2518 | |
| 2519 | const char *script = |
| 2520 | "class A \n" |
| 2521 | "{ \n" |
| 2522 | " int x; \n" |
| 2523 | "} \n" |
| 2524 | "int sum(const array<A>& a) \n" |
| 2525 | "{ \n" |
| 2526 | " int s = 0; \n" |
| 2527 | " for (uint i=0; i<a.length(); i++) \n" |
| 2528 | " s+=a[i].x; \n" |
| 2529 | " return s; \n" |
| 2530 | "} \n"; |
| 2531 | |
| 2532 | const char *exec = |
| 2533 | "array<A> As; \n" |
| 2534 | "As.resize(2); \n" |
| 2535 | "As[0].x = 1; \n" |
| 2536 | "As[1].x = 2; \n" |
| 2537 | "sum(As); \n"; |
| 2538 | |
| 2539 | asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); |
| 2540 | engine->SetMessageCallback(asMETHOD(COutStream, Callback), &out, asCALL_THISCALL); |
| 2541 | RegisterScriptArray(engine, false); |
| 2542 | asIScriptModule *module = engine->GetModule("module", asGM_ALWAYS_CREATE); |
| 2543 | |
| 2544 | module->AddScriptSection("script", script); |
| 2545 | |
| 2546 | int r = module->Build(); |
| 2547 | if( r < 0 ) |
| 2548 | { |
| 2549 | TEST_FAILED; |
| 2550 | } |
| 2551 | |
| 2552 | r = ExecuteString(engine, exec, module); |
| 2553 | if( r != asEXECUTION_FINISHED ) |
| 2554 | { |
| 2555 | TEST_FAILED; |
| 2556 | } |
| 2557 | |
| 2558 | engine->Release(); |
| 2559 | |
| 2560 | return fail; |
| 2561 | } |
| 2562 | |
| 2563 | } // namespace |
| 2564 |
no test coverage detected