| Index: test/mjsunit/wasm/asm-wasm.js
|
| diff --git a/test/mjsunit/wasm/asm-wasm.js b/test/mjsunit/wasm/asm-wasm.js
|
| index adb37d1268a387410fa1b17582ceca2cbc0d826d..d08ff01bbcf8f38d2c48f0bc6f9921ec39d4d277 100644
|
| --- a/test/mjsunit/wasm/asm-wasm.js
|
| +++ b/test/mjsunit/wasm/asm-wasm.js
|
| @@ -551,3 +551,119 @@ function TestGlobalsWithInit() {
|
| var module = WASM.instantiateModuleFromAsm(TestGlobalsWithInit.toString());
|
| module.__init__();
|
| assertEquals(77.5, module.add());
|
| +
|
| +function TestForLoop() {
|
| + "use asm"
|
| +
|
| + function caller() {
|
| + var ret = 0;
|
| + var i = 0;
|
| + for (i = 2; i <= 10; i = (i+1)|0) {
|
| + ret = (ret + i) | 0;
|
| + }
|
| + return ret|0;
|
| + }
|
| +
|
| + return {caller:caller};
|
| +}
|
| +
|
| +assertEquals(54, WASM.asmCompileRun(TestForLoop.toString()));
|
| +
|
| +function TestForLoopWithoutInit() {
|
| + "use asm"
|
| +
|
| + function caller() {
|
| + var ret = 0;
|
| + var i = 0;
|
| + for (; i < 10; i = (i+1)|0) {
|
| + ret = (ret + 10) | 0;
|
| + }
|
| + return ret|0;
|
| + }
|
| +
|
| + return {caller:caller};
|
| +}
|
| +
|
| +assertEquals(100, WASM.asmCompileRun(TestForLoopWithoutInit.toString()));
|
| +
|
| +function TestForLoopWithoutCondition() {
|
| + "use asm"
|
| +
|
| + function caller() {
|
| + var ret = 0;
|
| + var i = 0;
|
| + for (i=1;; i = (i+1)|0) {
|
| + ret = (ret + i) | 0;
|
| + if (i == 11) {
|
| + break;
|
| + }
|
| + }
|
| + return ret|0;
|
| + }
|
| +
|
| + return {caller:caller};
|
| +}
|
| +
|
| +assertEquals(66, WASM.asmCompileRun(TestForLoopWithoutCondition.toString()));
|
| +
|
| +function TestForLoopWithoutNext() {
|
| + "use asm"
|
| +
|
| + function caller() {
|
| + var i = 0;
|
| + for (i=1; i < 41;) {
|
| + i = (i + 1) | 0;
|
| + }
|
| + return i|0;
|
| + }
|
| +
|
| + return {caller:caller};
|
| +}
|
| +
|
| +assertEquals(41, WASM.asmCompileRun(TestForLoopWithoutNext.toString()));
|
| +
|
| +function TestForLoopWithoutBody() {
|
| + "use asm"
|
| +
|
| + function caller() {
|
| + var i = 0;
|
| + for (i=1; i < 45 ; i = (i+1)|0) {
|
| + }
|
| + return i|0;
|
| + }
|
| +
|
| + return {caller:caller};
|
| +}
|
| +
|
| +assertEquals(45, WASM.asmCompileRun(TestForLoopWithoutBody.toString()));
|
| +
|
| +function TestDoWhile() {
|
| + "use asm"
|
| +
|
| + function caller() {
|
| + var i = 0;
|
| + var ret = 21;
|
| + do {
|
| + ret = (ret + ret)|0;
|
| + i = (i + 1)|0;
|
| + } while (i < 2);
|
| + return ret|0;
|
| + }
|
| +
|
| + return {caller:caller};
|
| +}
|
| +
|
| +assertEquals(84, WASM.asmCompileRun(TestDoWhile.toString()));
|
| +
|
| +function TestConditional() {
|
| + "use asm"
|
| +
|
| + function caller() {
|
| + var x = 1;
|
| + return ((x > 0) ? 41 : 71)|0;
|
| + }
|
| +
|
| + return {caller:caller};
|
| +}
|
| +
|
| +assertEquals(41, WASM.asmCompileRun(TestConditional.toString()));
|
|
|