Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(563)

Unified Diff: test/mjsunit/wasm/asm-wasm.js

Issue 1523843003: Add for loop to asm-to-wasm (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/wasm/asm-wasm-builder.cc ('K') | « src/wasm/asm-wasm-builder.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..13c05bb71a76b3acf79b45016c82159ad77c5198 100644
--- a/test/mjsunit/wasm/asm-wasm.js
+++ b/test/mjsunit/wasm/asm-wasm.js
@@ -551,3 +551,88 @@ 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()));
« src/wasm/asm-wasm-builder.cc ('K') | « src/wasm/asm-wasm-builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698