| 553 | } |
| 554 | |
| 555 | bool Test2() |
| 556 | { |
| 557 | bool fail = false; |
| 558 | |
| 559 | const char *script = |
| 560 | "class A \n" |
| 561 | "{ \n" |
| 562 | " int x; \n" |
| 563 | "} \n" |
| 564 | "int sum(const A[]& a) \n" |
| 565 | "{ \n" |
| 566 | " int s = 0; \n" |
| 567 | " for (uint i=0; i<a.length(); i++) \n" |
| 568 | " s+=a[i].x; \n" |
| 569 | " return s; \n" |
| 570 | "} \n"; |
| 571 | |
| 572 | const char *exec = |
| 573 | "A[] As; \n" |
| 574 | "As.resize(2); \n" |
| 575 | "As[0].x = 1; \n" |
| 576 | "As[1].x = 2; \n" |
| 577 | "sum(As); \n"; |
| 578 | |
| 579 | asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); |
| 580 | RegisterScriptArray(engine, true); |
| 581 | |
| 582 | asIScriptModule *module = engine->GetModule("module", asGM_ALWAYS_CREATE); |
| 583 | |
| 584 | module->AddScriptSection("script", script); |
| 585 | int r = module->Build(); |
| 586 | if( r < 0 ) |
| 587 | { |
| 588 | TEST_FAILED; |
| 589 | } |
| 590 | |
| 591 | r = ExecuteString(engine, exec, module); |
| 592 | if( r != asEXECUTION_FINISHED ) |
| 593 | { |
| 594 | TEST_FAILED; |
| 595 | } |
| 596 | |
| 597 | engine->Release(); |
| 598 | |
| 599 | return fail; |
| 600 | } |
| 601 | |
| 602 | } // namespace |
| 603 |
no test coverage detected